Also added an API to return list of builtin network drivers
Signed-off-by: Madhu Venugopal <madhu@docker.com>
| ... | ... |
@@ -75,6 +75,9 @@ type NetworkController interface {
|
| 75 | 75 |
// ID provides a unique identity for the controller |
| 76 | 76 |
ID() string |
| 77 | 77 |
|
| 78 |
+ // BuiltinDrivers returns list of builtin drivers |
|
| 79 |
+ BuiltinDrivers() []string |
|
| 80 |
+ |
|
| 78 | 81 |
// Config method returns the bootup configuration for the controller |
| 79 | 82 |
Config() config.Config |
| 80 | 83 |
|
| ... | ... |
@@ -463,6 +466,17 @@ func (c *controller) ID() string {
|
| 463 | 463 |
return c.id |
| 464 | 464 |
} |
| 465 | 465 |
|
| 466 |
+func (c *controller) BuiltinDrivers() []string {
|
|
| 467 |
+ drivers := []string{}
|
|
| 468 |
+ for _, i := range getInitializers() {
|
|
| 469 |
+ if i.ntype == "remote" {
|
|
| 470 |
+ continue |
|
| 471 |
+ } |
|
| 472 |
+ drivers = append(drivers, i.ntype) |
|
| 473 |
+ } |
|
| 474 |
+ return drivers |
|
| 475 |
+} |
|
| 476 |
+ |
|
| 466 | 477 |
func (c *controller) validateHostDiscoveryConfig() bool {
|
| 467 | 478 |
if c.cfg == nil || c.cfg.Cluster.Discovery == "" || c.cfg.Cluster.Address == "" {
|
| 468 | 479 |
return false |
| ... | ... |
@@ -27,6 +27,38 @@ type GetCapabilityResponse struct {
|
| 27 | 27 |
Scope string |
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
+// AllocateNetworkRequest requests allocation of new network by manager |
|
| 31 |
+type AllocateNetworkRequest struct {
|
|
| 32 |
+ // A network ID that remote plugins are expected to store for future |
|
| 33 |
+ // reference. |
|
| 34 |
+ NetworkID string |
|
| 35 |
+ |
|
| 36 |
+ // A free form map->object interface for communication of options. |
|
| 37 |
+ Options map[string]string |
|
| 38 |
+ |
|
| 39 |
+ // IPAMData contains the address pool information for this network |
|
| 40 |
+ IPv4Data, IPv6Data []driverapi.IPAMData |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+// AllocateNetworkResponse is the response to the AllocateNetworkRequest. |
|
| 44 |
+type AllocateNetworkResponse struct {
|
|
| 45 |
+ Response |
|
| 46 |
+ // A free form plugin specific string->string object to be sent in |
|
| 47 |
+ // CreateNetworkRequest call in the libnetwork agents |
|
| 48 |
+ Options map[string]string |
|
| 49 |
+} |
|
| 50 |
+ |
|
| 51 |
+// FreeNetworkRequest is the request to free allocated network in the manager |
|
| 52 |
+type FreeNetworkRequest struct {
|
|
| 53 |
+ // The ID of the network to be freed. |
|
| 54 |
+ NetworkID string |
|
| 55 |
+} |
|
| 56 |
+ |
|
| 57 |
+// FreeNetworkResponse is the response to a request for freeing a network. |
|
| 58 |
+type FreeNetworkResponse struct {
|
|
| 59 |
+ Response |
|
| 60 |
+} |
|
| 61 |
+ |
|
| 30 | 62 |
// CreateNetworkRequest requests a new network. |
| 31 | 63 |
type CreateNetworkRequest struct {
|
| 32 | 64 |
// A network ID that remote plugins are expected to store for future |
| ... | ... |
@@ -88,12 +88,21 @@ func (d *driver) call(methodName string, arg interface{}, retVal maybeError) err
|
| 88 | 88 |
return nil |
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 |
-func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 92 |
- return nil, types.NotImplementedErrorf("not implemented")
|
|
| 91 |
+func (d *driver) NetworkAllocate(id string, options map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
|
| 92 |
+ create := &api.AllocateNetworkRequest{
|
|
| 93 |
+ NetworkID: id, |
|
| 94 |
+ Options: options, |
|
| 95 |
+ IPv4Data: ipV4Data, |
|
| 96 |
+ IPv6Data: ipV6Data, |
|
| 97 |
+ } |
|
| 98 |
+ retVal := api.AllocateNetworkResponse{}
|
|
| 99 |
+ err := d.call("AllocateNetwork", create, &retVal)
|
|
| 100 |
+ return retVal.Options, err |
|
| 93 | 101 |
} |
| 94 | 102 |
|
| 95 | 103 |
func (d *driver) NetworkFree(id string) error {
|
| 96 |
- return types.NotImplementedErrorf("not implemented")
|
|
| 104 |
+ fr := &api.FreeNetworkRequest{NetworkID: id}
|
|
| 105 |
+ return d.call("FreeNetwork", fr, &api.FreeNetworkResponse{})
|
|
| 97 | 106 |
} |
| 98 | 107 |
|
| 99 | 108 |
func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) {
|