1 // Package null implements the null ipam driver. Null ipam driver satisfies ipamapi contract,
2 // but does not effectively reserve/allocate any address pool or address
9 "github.com/docker/libnetwork/discoverapi"
10 "github.com/docker/libnetwork/ipamapi"
11 "github.com/docker/libnetwork/types"
16 defaultPool, _ = types.ParseCIDR("0.0.0.0/0")
17 defaultPoolID = fmt.Sprintf("%s/%s", defaultAS, defaultPool.String())
20 type allocator struct{}
22 func (a *allocator) GetDefaultAddressSpaces() (string, string, error) {
23 return defaultAS, defaultAS, nil
26 func (a *allocator) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) {
27 if addressSpace != defaultAS {
28 return "", nil, nil, types.BadRequestErrorf("unknown address space: %s", addressSpace)
31 return "", nil, nil, types.BadRequestErrorf("null ipam driver does not handle specific address pool requests")
34 return "", nil, nil, types.BadRequestErrorf("null ipam driver does not handle specific address subpool requests")
37 return "", nil, nil, types.BadRequestErrorf("null ipam driver does not handle IPv6 address pool pool requests")
39 return defaultPoolID, defaultPool, nil, nil
42 func (a *allocator) ReleasePool(poolID string) error {
46 func (a *allocator) RequestAddress(poolID string, ip net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) {
47 if poolID != defaultPoolID {
48 return nil, nil, types.BadRequestErrorf("unknown pool id: %s", poolID)
53 func (a *allocator) ReleaseAddress(poolID string, ip net.IP) error {
54 if poolID != defaultPoolID {
55 return types.BadRequestErrorf("unknown pool id: %s", poolID)
60 func (a *allocator) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
64 func (a *allocator) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
68 func (a *allocator) IsBuiltIn() bool {
72 // Init registers a remote ipam when its plugin is activated
73 func Init(ic ipamapi.Callback, l, g interface{}) error {
74 return ic.RegisterIpamDriver(ipamapi.NullIPAM, &allocator{})