mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
2aaef377f3
- Add IPAM cotract and remote IPAM hooks - Add ipam registration in controller - Have default IPAM follow ipamapi contract Signed-off-by: Alessandro Boch <aboch@docker.com>
35 lines
792 B
Go
35 lines
792 B
Go
package builtin
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/docker/libnetwork/datastore"
|
|
"github.com/docker/libnetwork/ipam"
|
|
"github.com/docker/libnetwork/ipamapi"
|
|
)
|
|
|
|
// Init registers the built-in ipam service with libnetwork
|
|
func Init(ic ipamapi.Callback, l, g interface{}) error {
|
|
var (
|
|
ok bool
|
|
localDs, globalDs datastore.DataStore
|
|
)
|
|
|
|
if l != nil {
|
|
if localDs, ok = l.(datastore.DataStore); !ok {
|
|
return fmt.Errorf("incorrect local datastore passed to built-in ipam init")
|
|
}
|
|
}
|
|
|
|
if g != nil {
|
|
if globalDs, ok = g.(datastore.DataStore); !ok {
|
|
return fmt.Errorf("incorrect global datastore passed to built-in ipam init")
|
|
}
|
|
}
|
|
a, err := ipam.NewAllocator(localDs, globalDs)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return ic.RegisterIpamDriver(ipamapi.DefaultIPAM, a)
|
|
}
|