a08a254df3
The DatastoreConfig discovery type is unused. Remove the constant and any resulting dead code. Today's biggest loser is the IPAM Allocator: DatastoreConfig was the only type of discovery event it was listening for, and there was no other place where a non-nil datastore could be passed into the allocator. Strip out all the dead persistence code from Allocator, leaving it as purely an in-memory implementation. There is no more need to check the consistency of the allocator's bit-sequences as there is no persistent storage for inconsistent bit sequences to be loaded from. Signed-off-by: Cory Snider <csnider@mirantis.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package builtin
|
|
|
|
import (
|
|
"net"
|
|
|
|
"github.com/docker/docker/libnetwork/ipam"
|
|
"github.com/docker/docker/libnetwork/ipamapi"
|
|
"github.com/docker/docker/libnetwork/ipamutils"
|
|
)
|
|
|
|
var (
|
|
// defaultAddressPool Stores user configured subnet list
|
|
defaultAddressPool []*net.IPNet
|
|
)
|
|
|
|
// registerBuiltin registers the built-in ipam driver with libnetwork.
|
|
func registerBuiltin(ic ipamapi.Registerer) error {
|
|
var localAddressPool []*net.IPNet
|
|
if len(defaultAddressPool) > 0 {
|
|
localAddressPool = append([]*net.IPNet(nil), defaultAddressPool...)
|
|
} else {
|
|
localAddressPool = ipamutils.GetLocalScopeDefaultNetworks()
|
|
}
|
|
|
|
a, err := ipam.NewAllocator(localAddressPool, ipamutils.GetGlobalScopeDefaultNetworks())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
cps := &ipamapi.Capability{RequiresRequestReplay: true}
|
|
|
|
return ic.RegisterIpamDriverWithCapabilities(ipamapi.DefaultIPAM, a, cps)
|
|
}
|
|
|
|
// SetDefaultIPAddressPool stores default address pool.
|
|
func SetDefaultIPAddressPool(addressPool []*ipamutils.NetworkToSplit) error {
|
|
nets, err := ipamutils.SplitNetworks(addressPool)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defaultAddressPool = nets
|
|
return nil
|
|
}
|