2015-04-13 14:40:42 -04:00
|
|
|
package driverapi
|
|
|
|
|
2015-04-13 21:36:58 -04:00
|
|
|
import (
|
|
|
|
"errors"
|
2015-04-17 18:42:23 -04:00
|
|
|
|
2015-04-20 11:44:06 -04:00
|
|
|
"github.com/docker/libnetwork/sandbox"
|
|
|
|
"github.com/docker/libnetwork/types"
|
2015-04-13 21:36:58 -04:00
|
|
|
)
|
2015-04-13 14:40:42 -04:00
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrEndpointExists is returned if more than one endpoint is added to the network
|
|
|
|
ErrEndpointExists = errors.New("Endpoint already exists (Only one endpoint allowed)")
|
|
|
|
// ErrNoNetwork is returned if no network with the specified id exists
|
|
|
|
ErrNoNetwork = errors.New("No network exists")
|
|
|
|
// ErrNoEndpoint is returned if no endpoint with the specified id exists
|
|
|
|
ErrNoEndpoint = errors.New("No endpoint exists")
|
|
|
|
)
|
|
|
|
|
|
|
|
// Driver is an interface that every plugin driver needs to implement.
|
|
|
|
type Driver interface {
|
2015-04-15 01:25:42 -04:00
|
|
|
// Push driver specific config to the driver
|
2015-04-30 20:57:06 -04:00
|
|
|
Config(options map[string]interface{}) error
|
2015-04-15 01:25:42 -04:00
|
|
|
|
2015-04-13 14:40:42 -04:00
|
|
|
// CreateNetwork invokes the driver method to create a network passing
|
2015-04-15 01:25:42 -04:00
|
|
|
// the network id and network specific config. The config mechanism will
|
2015-04-13 14:40:42 -04:00
|
|
|
// eventually be replaced with labels which are yet to be introduced.
|
2015-04-30 20:57:06 -04:00
|
|
|
CreateNetwork(nid types.UUID, options map[string]interface{}) error
|
2015-04-13 14:40:42 -04:00
|
|
|
|
|
|
|
// DeleteNetwork invokes the driver method to delete network passing
|
|
|
|
// the network id.
|
2015-04-20 11:44:06 -04:00
|
|
|
DeleteNetwork(nid types.UUID) error
|
2015-04-13 14:40:42 -04:00
|
|
|
|
|
|
|
// CreateEndpoint invokes the driver method to create an endpoint
|
2015-04-28 01:57:36 -04:00
|
|
|
// passing the network id, endpoint id and driver
|
2015-04-13 14:40:42 -04:00
|
|
|
// specific config. The config mechanism will eventually be replaced
|
|
|
|
// with labels which are yet to be introduced.
|
2015-04-30 20:57:06 -04:00
|
|
|
CreateEndpoint(nid, eid types.UUID, options map[string]interface{}) (*sandbox.Info, error)
|
2015-04-13 14:40:42 -04:00
|
|
|
|
|
|
|
// DeleteEndpoint invokes the driver method to delete an endpoint
|
|
|
|
// passing the network id and endpoint id.
|
2015-04-20 11:44:06 -04:00
|
|
|
DeleteEndpoint(nid, eid types.UUID) error
|
2015-04-22 19:47:07 -04:00
|
|
|
|
2015-05-04 14:49:53 -04:00
|
|
|
// EndpointInfo retrieves from the driver the operational data related to the specified endpoint
|
|
|
|
EndpointInfo(nid, eid types.UUID) (map[string]interface{}, error)
|
|
|
|
|
2015-04-30 17:52:46 -04:00
|
|
|
// Join method is invoked when a Sandbox is attached to an endpoint.
|
|
|
|
Join(nid, eid types.UUID, sboxKey string, options map[string]interface{}) error
|
|
|
|
|
|
|
|
// Leave method is invoked when a Sandbox detaches from an endpoint.
|
|
|
|
Leave(nid, eid types.UUID, options map[string]interface{}) error
|
|
|
|
|
2015-04-22 19:47:07 -04:00
|
|
|
// Type returns the the type of this driver, the network type this driver manages
|
|
|
|
Type() string
|
2015-04-17 18:42:23 -04:00
|
|
|
}
|