// InitDockerDefault registers the built-in ipam service with libnetwork func InitDockerDefault(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 errors.New("incorrect local datastore passed to built-in ipam init") } } if g != nil { if globalDs, ok = g.(datastore.DataStore); !ok { return errors.New("incorrect global datastore passed to built-in ipam init") } } ipamutils.InitNetworks() a, err := ipam.NewAllocator(localDs, globalDs) if err != nil { return err } cps := &ipamapi.Capability{RequiresRequestReplay: true} return ic.RegisterIpamDriverWithCapabilities(ipamapi.DefaultIPAM, a, cps) }
// 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") } } ipamutils.InitNetworks() a, err := ipam.NewAllocator(localDs, globalDs) if err != nil { return err } return ic.RegisterIpamDriver(ipamapi.DefaultIPAM, a) }
// Init registers a remote ipam when its plugin is activated func Init(cb ipamapi.Callback, l, g interface{}) error { plugins.Handle(ipamapi.PluginEndpointType, func(name string, client *plugins.Client) { if err := cb.RegisterIpamDriver(name, newAllocator(name, client)); err != nil { log.Errorf("error registering remote ipam %s due to %v", name, err) } }) return nil }
// Init registers a remote ipam when its plugin is activated func Init(cb ipamapi.Callback, l, g interface{}) error { plugins.Handle(ipamapi.PluginEndpointType, func(name string, client *plugins.Client) { a := newAllocator(name, client) if cps, err := a.(*allocator).getCapabilities(); err == nil { if err := cb.RegisterIpamDriverWithCapabilities(name, a, cps); err != nil { log.Errorf("error registering remote ipam driver %s due to %v", name, err) } } else { log.Infof("remote ipam driver %s does not support capabilities", name) log.Debug(err) if err := cb.RegisterIpamDriver(name, a); err != nil { log.Errorf("error registering remote ipam driver %s due to %v", name, err) } } }) return nil }
// Init registers a remote ipam when its plugin is activated func Init(cb ipamapi.Callback, l, g interface{}) error { newPluginHandler := func(name string, client *plugins.Client) { a := newAllocator(name, client) if cps, err := a.(*allocator).getCapabilities(); err == nil { if err := cb.RegisterIpamDriverWithCapabilities(name, a, cps); err != nil { logrus.Errorf("error registering remote ipam driver %s due to %v", name, err) } } else { logrus.Infof("remote ipam driver %s does not support capabilities", name) logrus.Debug(err) if err := cb.RegisterIpamDriver(name, a); err != nil { logrus.Errorf("error registering remote ipam driver %s due to %v", name, err) } } } // Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins. handleFunc := plugins.Handle if pg := cb.GetPluginGetter(); pg != nil { handleFunc = pg.Handle activePlugins := pg.GetAllManagedPluginsByCap(ipamapi.PluginEndpointType) for _, ap := range activePlugins { newPluginHandler(ap.Name(), ap.Client()) } } handleFunc(ipamapi.PluginEndpointType, newPluginHandler) return nil }
// Init registers a remote ipam when its plugin is activated func Init(ic ipamapi.Callback, l, g interface{}) error { return ic.RegisterIpamDriver(ipamapi.NullIPAM, &allocator{}) }