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>
| ... | ... |
@@ -13,6 +13,16 @@ const NetworkPluginEndpointType = "NetworkDriver" |
| 13 | 13 |
type Driver interface {
|
| 14 | 14 |
discoverapi.Discover |
| 15 | 15 |
|
| 16 |
+ // NetworkAllocate invokes the driver method to allocate network |
|
| 17 |
+ // specific resources passing network id and network specific config. |
|
| 18 |
+ // It returns a key,value pair of network specific driver allocations |
|
| 19 |
+ // to the caller and an error. |
|
| 20 |
+ NetworkAllocate(nid string, options map[string]interface{}, ipV4Data, ipV6Data []IPAMData) (map[string]string, error)
|
|
| 21 |
+ |
|
| 22 |
+ // NetworkFree invokes the driver method to free network specific resources |
|
| 23 |
+ // associated with a given network id. |
|
| 24 |
+ NetworkFree(nid string) error |
|
| 25 |
+ |
|
| 16 | 26 |
// CreateNetwork invokes the driver method to create a network passing |
| 17 | 27 |
// the network id and network specific config. The config mechanism will |
| 18 | 28 |
// eventually be replaced with labels which are yet to be introduced. |
| ... | ... |
@@ -535,6 +535,14 @@ func (d *driver) getNetworks() []*bridgeNetwork {
|
| 535 | 535 |
return ls |
| 536 | 536 |
} |
| 537 | 537 |
|
| 538 |
+func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 539 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 540 |
+} |
|
| 541 |
+ |
|
| 542 |
+func (d *driver) NetworkFree(id string) error {
|
|
| 543 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 544 |
+} |
|
| 545 |
+ |
|
| 538 | 546 |
// Create a new network using bridge plugin |
| 539 | 547 |
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
|
| 540 | 548 |
if len(ipV4Data) == 0 || ipV4Data[0].Pool.String() == "0.0.0.0/0" {
|
| ... | ... |
@@ -24,6 +24,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
| 24 | 24 |
return dc.RegisterDriver(networkType, &driver{}, c)
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
+func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 28 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 29 |
+} |
|
| 30 |
+ |
|
| 31 |
+func (d *driver) NetworkFree(id string) error {
|
|
| 32 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 33 |
+} |
|
| 34 |
+ |
|
| 27 | 35 |
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
|
| 28 | 36 |
d.Lock() |
| 29 | 37 |
defer d.Unlock() |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"github.com/docker/libnetwork/discoverapi" |
| 9 | 9 |
"github.com/docker/libnetwork/driverapi" |
| 10 | 10 |
"github.com/docker/libnetwork/osl" |
| 11 |
+ "github.com/docker/libnetwork/types" |
|
| 11 | 12 |
) |
| 12 | 13 |
|
| 13 | 14 |
const ( |
| ... | ... |
@@ -64,6 +65,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
| 64 | 64 |
return dc.RegisterDriver(ipvlanType, d, c) |
| 65 | 65 |
} |
| 66 | 66 |
|
| 67 |
+func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 68 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 69 |
+} |
|
| 70 |
+ |
|
| 71 |
+func (d *driver) NetworkFree(id string) error {
|
|
| 72 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 73 |
+} |
|
| 74 |
+ |
|
| 67 | 75 |
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
| 68 | 76 |
return make(map[string]interface{}, 0), nil
|
| 69 | 77 |
} |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"github.com/docker/libnetwork/discoverapi" |
| 9 | 9 |
"github.com/docker/libnetwork/driverapi" |
| 10 | 10 |
"github.com/docker/libnetwork/osl" |
| 11 |
+ "github.com/docker/libnetwork/types" |
|
| 11 | 12 |
) |
| 12 | 13 |
|
| 13 | 14 |
const ( |
| ... | ... |
@@ -66,6 +67,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
| 66 | 66 |
return dc.RegisterDriver(macvlanType, d, c) |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
+func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 70 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 71 |
+} |
|
| 72 |
+ |
|
| 73 |
+func (d *driver) NetworkFree(id string) error {
|
|
| 74 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 75 |
+} |
|
| 76 |
+ |
|
| 69 | 77 |
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
| 70 | 78 |
return make(map[string]interface{}, 0), nil
|
| 71 | 79 |
} |
| ... | ... |
@@ -24,6 +24,14 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
| 24 | 24 |
return dc.RegisterDriver(networkType, &driver{}, c)
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
+func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 28 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 29 |
+} |
|
| 30 |
+ |
|
| 31 |
+func (d *driver) NetworkFree(id string) error {
|
|
| 32 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 33 |
+} |
|
| 34 |
+ |
|
| 27 | 35 |
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
|
| 28 | 36 |
d.Lock() |
| 29 | 37 |
defer d.Unlock() |
| ... | ... |
@@ -59,6 +59,14 @@ type network struct {
|
| 59 | 59 |
sync.Mutex |
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 |
+func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 63 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 64 |
+} |
|
| 65 |
+ |
|
| 66 |
+func (d *driver) NetworkFree(id string) error {
|
|
| 67 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 68 |
+} |
|
| 69 |
+ |
|
| 62 | 70 |
func (d *driver) CreateNetwork(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
|
| 63 | 71 |
if id == "" {
|
| 64 | 72 |
return fmt.Errorf("invalid network id")
|
| ... | ... |
@@ -83,6 +83,14 @@ func (d *driver) call(methodName string, arg interface{}, retVal maybeError) err
|
| 83 | 83 |
return nil |
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 |
+func (d *driver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 87 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 88 |
+} |
|
| 89 |
+ |
|
| 90 |
+func (d *driver) NetworkFree(id string) error {
|
|
| 91 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 92 |
+} |
|
| 93 |
+ |
|
| 86 | 94 |
func (d *driver) CreateNetwork(id string, options map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
|
| 87 | 95 |
create := &api.CreateNetworkRequest{
|
| 88 | 96 |
NetworkID: id, |
| ... | ... |
@@ -468,3 +468,11 @@ func (b *badDriver) ProgramExternalConnectivity(nid, eid string, options map[str |
| 468 | 468 |
func (b *badDriver) RevokeExternalConnectivity(nid, eid string) error {
|
| 469 | 469 |
return nil |
| 470 | 470 |
} |
| 471 |
+ |
|
| 472 |
+func (b *badDriver) NetworkAllocate(id string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 473 |
+ return nil, types.NotImplementedErrorf("not implemented")
|
|
| 474 |
+} |
|
| 475 |
+ |
|
| 476 |
+func (b *badDriver) NetworkFree(id string) error {
|
|
| 477 |
+ return types.NotImplementedErrorf("not implemented")
|
|
| 478 |
+} |