|
@@ -48,8 +48,9 @@ import (
|
|
// NetworkController provides the interface for controller instance which manages
|
|
// NetworkController provides the interface for controller instance which manages
|
|
// networks.
|
|
// networks.
|
|
type NetworkController interface {
|
|
type NetworkController interface {
|
|
|
|
+ // NOTE: This method will go away when moving to plugin infrastructure
|
|
NewNetworkDriver(networkType string, options interface{}) (*NetworkDriver, error)
|
|
NewNetworkDriver(networkType string, options interface{}) (*NetworkDriver, error)
|
|
- // Create a new network. The options parameter carry driver specific options.
|
|
|
|
|
|
+ // Create a new network. The options parameter carries network specific options.
|
|
// Labels support will be added in the near future.
|
|
// Labels support will be added in the near future.
|
|
NewNetwork(d *NetworkDriver, name string, options interface{}) (Network, error)
|
|
NewNetwork(d *NetworkDriver, name string, options interface{}) (Network, error)
|
|
}
|
|
}
|
|
@@ -69,7 +70,7 @@ type Network interface {
|
|
// Create a new endpoint to this network symbolically identified by the
|
|
// Create a new endpoint to this network symbolically identified by the
|
|
// specified unique name. The options parameter carry driver specific options.
|
|
// specified unique name. The options parameter carry driver specific options.
|
|
// Labels support will be added in the near future.
|
|
// Labels support will be added in the near future.
|
|
- CreateEndpoint(name string, sboxKey string, options interface{}) (Endpoint, *driverapi.SandboxInfo, error)
|
|
|
|
|
|
+ CreateEndpoint(name string, sboxKey string, options interface{}) (Endpoint, error)
|
|
|
|
|
|
// Delete the network.
|
|
// Delete the network.
|
|
Delete() error
|
|
Delete() error
|
|
@@ -77,10 +78,19 @@ type Network interface {
|
|
|
|
|
|
// Endpoint represents a logical connection between a network and a sandbox.
|
|
// Endpoint represents a logical connection between a network and a sandbox.
|
|
type Endpoint interface {
|
|
type Endpoint interface {
|
|
- // A system generated id for this network.
|
|
|
|
|
|
+ // A system generated id for this endpoint.
|
|
ID() string
|
|
ID() string
|
|
|
|
|
|
- // Delete endpoint.
|
|
|
|
|
|
+ // Name returns the name of this endpoint.
|
|
|
|
+ Name() string
|
|
|
|
+
|
|
|
|
+ // Network returns the name of the network to which this endpoint is attached.
|
|
|
|
+ Network() string
|
|
|
|
+
|
|
|
|
+ // SandboxInfo returns the sandbox information for this endpoint.
|
|
|
|
+ SandboxInfo() *driverapi.SandboxInfo
|
|
|
|
+
|
|
|
|
+ // Delete and detaches this endpoint from the network.
|
|
Delete() error
|
|
Delete() error
|
|
}
|
|
}
|
|
|
|
|
|
@@ -222,7 +232,7 @@ func (n *network) Delete() error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
-func (n *network) CreateEndpoint(name string, sboxKey string, options interface{}) (Endpoint, *driverapi.SandboxInfo, error) {
|
|
|
|
|
|
+func (n *network) CreateEndpoint(name string, sboxKey string, options interface{}) (Endpoint, error) {
|
|
ep := &endpoint{name: name}
|
|
ep := &endpoint{name: name}
|
|
ep.id = driverapi.UUID(stringid.GenerateRandomID())
|
|
ep.id = driverapi.UUID(stringid.GenerateRandomID())
|
|
ep.network = n
|
|
ep.network = n
|
|
@@ -230,20 +240,35 @@ func (n *network) CreateEndpoint(name string, sboxKey string, options interface{
|
|
d := n.driver.internalDriver
|
|
d := n.driver.internalDriver
|
|
sinfo, err := d.CreateEndpoint(n.id, ep.id, sboxKey, options)
|
|
sinfo, err := d.CreateEndpoint(n.id, ep.id, sboxKey, options)
|
|
if err != nil {
|
|
if err != nil {
|
|
- return nil, nil, err
|
|
|
|
|
|
+ return nil, err
|
|
}
|
|
}
|
|
|
|
|
|
ep.sandboxInfo = sinfo
|
|
ep.sandboxInfo = sinfo
|
|
n.Lock()
|
|
n.Lock()
|
|
n.endpoints[ep.id] = ep
|
|
n.endpoints[ep.id] = ep
|
|
n.Unlock()
|
|
n.Unlock()
|
|
- return ep, sinfo, nil
|
|
|
|
|
|
+ return ep, nil
|
|
}
|
|
}
|
|
|
|
|
|
func (ep *endpoint) ID() string {
|
|
func (ep *endpoint) ID() string {
|
|
return string(ep.id)
|
|
return string(ep.id)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (ep *endpoint) Name() string {
|
|
|
|
+ return ep.name
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (ep *endpoint) Network() string {
|
|
|
|
+ return ep.network.name
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (ep *endpoint) SandboxInfo() *driverapi.SandboxInfo {
|
|
|
|
+ if ep.sandboxInfo == nil {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ return ep.sandboxInfo.GetCopy()
|
|
|
|
+}
|
|
|
|
+
|
|
func (ep *endpoint) Delete() error {
|
|
func (ep *endpoint) Delete() error {
|
|
var err error
|
|
var err error
|
|
|
|
|