2015-04-13 18:40:42 +00:00
|
|
|
package driverapi
|
|
|
|
|
2015-04-14 01:36:58 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
2015-04-17 15:42:23 -07:00
|
|
|
|
2015-04-20 08:44:06 -07:00
|
|
|
"github.com/docker/libnetwork/sandbox"
|
|
|
|
"github.com/docker/libnetwork/types"
|
2015-04-14 01:36:58 +00:00
|
|
|
)
|
2015-04-13 18:40:42 +00: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 05:25:42 +00:00
|
|
|
// Push driver specific config to the driver
|
|
|
|
Config(config interface{}) error
|
|
|
|
|
2015-04-13 18:40:42 +00:00
|
|
|
// CreateNetwork invokes the driver method to create a network passing
|
2015-04-15 05:25:42 +00:00
|
|
|
// the network id and network specific config. The config mechanism will
|
2015-04-13 18:40:42 +00:00
|
|
|
// eventually be replaced with labels which are yet to be introduced.
|
2015-04-20 08:44:06 -07:00
|
|
|
CreateNetwork(nid types.UUID, config interface{}) error
|
2015-04-13 18:40:42 +00:00
|
|
|
|
|
|
|
// DeleteNetwork invokes the driver method to delete network passing
|
|
|
|
// the network id.
|
2015-04-20 08:44:06 -07:00
|
|
|
DeleteNetwork(nid types.UUID) error
|
2015-04-13 18:40:42 +00:00
|
|
|
|
|
|
|
// CreateEndpoint invokes the driver method to create an endpoint
|
|
|
|
// passing the network id, endpoint id, sandbox key and driver
|
|
|
|
// specific config. The config mechanism will eventually be replaced
|
|
|
|
// with labels which are yet to be introduced.
|
2015-04-20 08:44:06 -07:00
|
|
|
CreateEndpoint(nid, eid types.UUID, key string, config interface{}) (*sandbox.Info, error)
|
2015-04-13 18:40:42 +00:00
|
|
|
|
|
|
|
// DeleteEndpoint invokes the driver method to delete an endpoint
|
|
|
|
// passing the network id and endpoint id.
|
2015-04-20 08:44:06 -07:00
|
|
|
DeleteEndpoint(nid, eid types.UUID) error
|
2015-04-17 15:42:23 -07:00
|
|
|
}
|