1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/libnetwork/driverapi/driverapi.go
Jana Radhakrishnan 68ae284db5 Libnetwork refactor for container network model
- Added controller, network, endpoint and sandbox interfaces
    - Created netutils package for miscallaneous network utilities
    - Created driverapi package to break cyclic dependency b/w driver and libnetwork
    - Made libnetwork multithread safe
    - Made bridge driver multithread safe
    - Fixed README.md

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-04-13 21:40:50 +00:00

72 lines
2.5 KiB
Go

package driverapi
import "errors"
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")
)
// UUID represents a globally unique ID of various resources like network and endpoint
type UUID string
// Driver is an interface that every plugin driver needs to implement.
type Driver interface {
// CreateNetwork invokes the driver method to create a network passing
// the network id and driver specific config. The config mechanism will
// eventually be replaced with labels which are yet to be introduced.
CreateNetwork(nid UUID, config interface{}) error
// DeleteNetwork invokes the driver method to delete network passing
// the network id.
DeleteNetwork(nid UUID) error
// 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.
CreateEndpoint(nid, eid UUID, key string, config interface{}) (*SandboxInfo, error)
// DeleteEndpoint invokes the driver method to delete an endpoint
// passing the network id and endpoint id.
DeleteEndpoint(nid, eid UUID) error
}
// Interface represents the settings and identity of a network device. It is
// used as a return type for Network.Link, and it is common practice for the
// caller to use this information when moving interface SrcName from host
// namespace to DstName in a different net namespace with the appropriate
// network settings.
type Interface struct {
// The name of the interface in the origin network namespace.
SrcName string
// The name that will be assigned to the interface once moves inside a
// network namespace.
DstName string
// IPv4 address for the interface.
Address string
// IPv6 address for the interface.
AddressIPv6 string
}
// SandboxInfo represents all possible information that
// the driver wants to place in the sandbox which includes
// interfaces, routes and gateway
type SandboxInfo struct {
Interfaces []*Interface
// IPv4 gateway for the sandbox.
Gateway string
// IPv6 gateway for the sandbox.
GatewayIPv6 string
// TODO: Add routes and ip tables etc.
}