1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add NetworkAllocate/Free to driver api

Added NetworkAllocate and NetworkFree apis to the list of
driver apis. The intention of the api is to provide a
centralized way of allocating and freeing network resources
for a network which is cross-host.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
Jana Radhakrishnan 2016-02-26 11:53:13 -08:00
parent 0251123411
commit b6d5c12ea2
9 changed files with 76 additions and 0 deletions

View file

@ -13,6 +13,16 @@ const NetworkPluginEndpointType = "NetworkDriver"
type Driver interface { type Driver interface {
discoverapi.Discover discoverapi.Discover
// NetworkAllocate invokes the driver method to allocate network
// specific resources passing network id and network specific config.
// It returns a key,value pair of network specific driver allocations
// to the caller and an error.
NetworkAllocate(nid string, options map[string]interface{}, ipV4Data, ipV6Data []IPAMData) (map[string]string, error)
// NetworkFree invokes the driver method to free network specific resources
// associated with a given network id.
NetworkFree(nid string) error
// CreateNetwork invokes the driver method to create a network passing // CreateNetwork invokes the driver method to create a network passing
// the network id and network specific config. The config mechanism will // the network id and network specific config. The config mechanism will
// eventually be replaced with labels which are yet to be introduced. // eventually be replaced with labels which are yet to be introduced.

View file

@ -535,6 +535,14 @@ func (d *driver) getNetworks() []*bridgeNetwork {
return ls return ls
} }
func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (d *driver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}
// Create a new network using bridge plugin // Create a new network using bridge plugin
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error { func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" { if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {

View file

@ -24,6 +24,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
return dc.RegisterDriver(networkType, &driver{}, c) return dc.RegisterDriver(networkType, &driver{}, c)
} }
func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (d *driver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error { func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
d.Lock() d.Lock()
defer d.Unlock() defer d.Unlock()

View file

@ -8,6 +8,7 @@ import (
"github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/discoverapi"
"github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/driverapi"
"github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/osl"
"github.com/docker/libnetwork/types"
) )
const ( const (
@ -64,6 +65,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
return dc.RegisterDriver(ipvlanType, d, c) return dc.RegisterDriver(ipvlanType, d, c)
} }
func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (d *driver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
return make(map[string]interface{}, 0), nil return make(map[string]interface{}, 0), nil
} }

View file

@ -8,6 +8,7 @@ import (
"github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/discoverapi"
"github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/driverapi"
"github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/osl"
"github.com/docker/libnetwork/types"
) )
const ( const (
@ -66,6 +67,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
return dc.RegisterDriver(macvlanType, d, c) return dc.RegisterDriver(macvlanType, d, c)
} }
func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (d *driver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
return make(map[string]interface{}, 0), nil return make(map[string]interface{}, 0), nil
} }

View file

@ -24,6 +24,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
return dc.RegisterDriver(networkType, &driver{}, c) return dc.RegisterDriver(networkType, &driver{}, c)
} }
func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (d *driver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error { func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
d.Lock() d.Lock()
defer d.Unlock() defer d.Unlock()

View file

@ -59,6 +59,14 @@ type network struct {
sync.Mutex sync.Mutex
} }
func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (d *driver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error { func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
if id == "" { if id == "" {
return fmt.Errorf("invalid network id") return fmt.Errorf("invalid network id")

View file

@ -83,6 +83,14 @@ func (d *driver) call(methodName string, arg interface{}, retVal maybeError) err
return nil return nil
} }
func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (d *driver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}
func (d *driver) CreateNetwork(id string, options map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error { func (d *driver) CreateNetwork(id string, options map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
create := &api.CreateNetworkRequest{ create := &api.CreateNetworkRequest{
NetworkID: id, NetworkID: id,

View file

@ -468,3 +468,11 @@ func (b *badDriver) ProgramExternalConnectivity(nid, eid string, options map[str
func (b *badDriver) RevokeExternalConnectivity(nid, eid string) error { func (b *badDriver) RevokeExternalConnectivity(nid, eid string) error {
return nil return nil
} }
func (b *badDriver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
return nil, types.NotImplementedErrorf("not implemented")
}
func (b *badDriver) NetworkFree(id string) error {
return types.NotImplementedErrorf("not implemented")
}