Internal interface to differentiate built-in drivers from remote
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
2b77c8ac90
commit
1b28c5e01d
21 changed files with 97 additions and 5 deletions
|
@ -79,6 +79,9 @@ type NetworkController interface {
|
|||
// BuiltinDrivers returns list of builtin drivers
|
||||
BuiltinDrivers() []string
|
||||
|
||||
// BuiltinIPAMDrivers returns list of builtin ipam drivers
|
||||
BuiltinIPAMDrivers() []string
|
||||
|
||||
// Config method returns the bootup configuration for the controller
|
||||
Config() config.Config
|
||||
|
||||
|
@ -476,12 +479,23 @@ func (c *controller) ID() string {
|
|||
|
||||
func (c *controller) BuiltinDrivers() []string {
|
||||
drivers := []string{}
|
||||
for _, i := range getInitializers(c.cfg.Daemon.Experimental) {
|
||||
if i.ntype == "remote" {
|
||||
continue
|
||||
c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
|
||||
if driver.IsBuiltIn() {
|
||||
drivers = append(drivers, name)
|
||||
}
|
||||
drivers = append(drivers, i.ntype)
|
||||
}
|
||||
return false
|
||||
})
|
||||
return drivers
|
||||
}
|
||||
|
||||
func (c *controller) BuiltinIPAMDrivers() []string {
|
||||
drivers := []string{}
|
||||
c.drvRegistry.WalkIPAMs(func(name string, driver ipamapi.Ipam, cap *ipamapi.Capability) bool {
|
||||
if driver.IsBuiltIn() {
|
||||
drivers = append(drivers, name)
|
||||
}
|
||||
return false
|
||||
})
|
||||
return drivers
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,9 @@ type Driver interface {
|
|||
|
||||
// Type returns the the type of this driver, the network type this driver manages
|
||||
Type() string
|
||||
|
||||
// IsBuiltIn returns true if it is a built-in driver
|
||||
IsBuiltIn() bool
|
||||
}
|
||||
|
||||
// NetworkInfo provides a go interface for drivers to provide network
|
||||
|
|
|
@ -1424,6 +1424,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
|
|
|
@ -86,6 +86,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
|
|
|
@ -84,6 +84,10 @@ func (d *driver) Type() string {
|
|||
return ipvlanType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -86,6 +86,10 @@ func (d *driver) Type() string {
|
|||
return macvlanType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -86,6 +86,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
|
|
|
@ -211,6 +211,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func validateSelf(node string) error {
|
||||
advIP := net.ParseIP(node)
|
||||
if advIP == nil {
|
||||
|
|
|
@ -229,6 +229,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return types.NotImplementedErrorf("not implemented")
|
||||
|
|
|
@ -312,6 +312,10 @@ func (d *driver) Type() string {
|
|||
return d.networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
if dType != discoverapi.NodeDiscovery {
|
||||
|
|
|
@ -916,6 +916,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
|
|
|
@ -200,6 +200,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func validateSelf(node string) error {
|
||||
advIP := net.ParseIP(node)
|
||||
if advIP == nil {
|
||||
|
|
|
@ -229,6 +229,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return types.NotImplementedErrorf("not implemented")
|
||||
|
|
|
@ -176,6 +176,10 @@ func (d *driver) Type() string {
|
|||
return networkType
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func validateSelf(node string) error {
|
||||
advIP := net.ParseIP(node)
|
||||
if advIP == nil {
|
||||
|
|
|
@ -698,6 +698,10 @@ func (d *driver) Type() string {
|
|||
return d.name
|
||||
}
|
||||
|
||||
func (d *driver) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
||||
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
|
|
|
@ -594,3 +594,8 @@ func (a *Allocator) DumpDatabase() string {
|
|||
|
||||
return s
|
||||
}
|
||||
|
||||
// IsBuiltIn returns true for builtin drivers
|
||||
func (a *Allocator) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -80,6 +80,9 @@ type Ipam interface {
|
|||
RequestAddress(string, net.IP, map[string]string) (*net.IPNet, map[string]string, error)
|
||||
// Release the address from the specified pool ID
|
||||
ReleaseAddress(string, net.IP) error
|
||||
|
||||
//IsBuiltIn returns true if it is a built-in driver.
|
||||
IsBuiltIn() bool
|
||||
}
|
||||
|
||||
// Capability represents the requirements and capabilities of the IPAM driver
|
||||
|
|
|
@ -65,6 +65,10 @@ func (a *allocator) DiscoverDelete(dType discoverapi.DiscoveryType, data interfa
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *allocator) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 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{})
|
||||
|
|
|
@ -149,3 +149,7 @@ func (a *allocator) DiscoverNew(dType discoverapi.DiscoveryType, data interface{
|
|||
func (a *allocator) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *allocator) IsBuiltIn() bool {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -101,3 +101,7 @@ func (a *allocator) DiscoverNew(dType discoverapi.DiscoveryType, data interface{
|
|||
func (a *allocator) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *allocator) IsBuiltIn() bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -544,6 +544,9 @@ func (b *badDriver) DiscoverDelete(dType discoverapi.DiscoveryType, data interfa
|
|||
func (b *badDriver) Type() string {
|
||||
return badDriverName
|
||||
}
|
||||
func (b *badDriver) IsBuiltIn() bool {
|
||||
return false
|
||||
}
|
||||
func (b *badDriver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue