2015-04-13 14:40:42 -04:00
|
|
|
package driverapi
|
|
|
|
|
2016-01-28 14:54:03 -05:00
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/docker/libnetwork/discoverapi"
|
|
|
|
)
|
2015-04-13 14:40:42 -04:00
|
|
|
|
2015-05-15 21:14:36 -04:00
|
|
|
// NetworkPluginEndpointType represents the Endpoint Type used by Plugin system
|
|
|
|
const NetworkPluginEndpointType = "NetworkDriver"
|
|
|
|
|
2015-04-13 14:40:42 -04:00
|
|
|
// Driver is an interface that every plugin driver needs to implement.
|
|
|
|
type Driver interface {
|
2016-01-28 14:54:03 -05:00
|
|
|
discoverapi.Discover
|
|
|
|
|
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-10-03 19:11:50 -04:00
|
|
|
CreateNetwork(nid string, options map[string]interface{}, ipV4Data, ipV6Data []IPAMData) error
|
2015-04-13 14:40:42 -04:00
|
|
|
|
|
|
|
// DeleteNetwork invokes the driver method to delete network passing
|
|
|
|
// the network id.
|
2015-07-02 01:00:48 -04:00
|
|
|
DeleteNetwork(nid string) error
|
2015-04-13 14:40:42 -04:00
|
|
|
|
|
|
|
// CreateEndpoint invokes the driver method to create an endpoint
|
2015-05-14 02:23:45 -04:00
|
|
|
// passing the network id, endpoint id endpoint information and driver
|
|
|
|
// specific config. The endpoint information can be either consumed by
|
|
|
|
// the driver or populated by the driver. The config mechanism will
|
|
|
|
// eventually be replaced with labels which are yet to be introduced.
|
2015-10-03 19:11:50 -04:00
|
|
|
CreateEndpoint(nid, eid string, ifInfo InterfaceInfo, options map[string]interface{}) 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-07-02 01:00:48 -04:00
|
|
|
DeleteEndpoint(nid, eid string) error
|
2015-04-22 19:47:07 -04:00
|
|
|
|
2015-05-14 02:23:45 -04:00
|
|
|
// EndpointOperInfo retrieves from the driver the operational data related to the specified endpoint
|
2015-07-02 01:00:48 -04:00
|
|
|
EndpointOperInfo(nid, eid string) (map[string]interface{}, error)
|
2015-05-04 14:49:53 -04:00
|
|
|
|
2015-04-30 17:52:46 -04:00
|
|
|
// Join method is invoked when a Sandbox is attached to an endpoint.
|
2015-07-02 01:00:48 -04:00
|
|
|
Join(nid, eid string, sboxKey string, jinfo JoinInfo, options map[string]interface{}) error
|
2015-04-30 17:52:46 -04:00
|
|
|
|
|
|
|
// Leave method is invoked when a Sandbox detaches from an endpoint.
|
2015-07-02 01:00:48 -04:00
|
|
|
Leave(nid, eid string) error
|
2015-04-30 17:52:46 -04:00
|
|
|
|
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
|
|
|
}
|
2015-05-03 16:29:43 -04:00
|
|
|
|
2015-05-14 02:23:45 -04:00
|
|
|
// InterfaceInfo provides a go interface for drivers to retrive
|
|
|
|
// network information to interface resources.
|
|
|
|
type InterfaceInfo interface {
|
2015-10-03 19:11:50 -04:00
|
|
|
// SetMacAddress allows the driver to set the mac address to the endpoint interface
|
|
|
|
// during the call to CreateEndpoint, if the mac address is not already set.
|
|
|
|
SetMacAddress(mac net.HardwareAddr) error
|
|
|
|
|
|
|
|
// SetIPAddress allows the driver to set the ip address to the endpoint interface
|
|
|
|
// during the call to CreateEndpoint, if the address is not already set.
|
|
|
|
// The API is to be used to assign both the IPv4 and IPv6 address types.
|
|
|
|
SetIPAddress(ip *net.IPNet) error
|
|
|
|
|
2015-05-14 02:23:45 -04:00
|
|
|
// MacAddress returns the MAC address.
|
|
|
|
MacAddress() net.HardwareAddr
|
|
|
|
|
|
|
|
// Address returns the IPv4 address.
|
2015-10-03 19:11:50 -04:00
|
|
|
Address() *net.IPNet
|
2015-05-14 02:23:45 -04:00
|
|
|
|
|
|
|
// AddressIPv6 returns the IPv6 address.
|
2015-10-03 19:11:50 -04:00
|
|
|
AddressIPv6() *net.IPNet
|
2015-05-14 02:23:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// InterfaceNameInfo provides a go interface for the drivers to assign names
|
|
|
|
// to interfaces.
|
|
|
|
type InterfaceNameInfo interface {
|
2015-05-21 14:04:49 -04:00
|
|
|
// SetNames method assigns the srcName and dstPrefix for the interface.
|
|
|
|
SetNames(srcName, dstPrefix string) error
|
2015-05-14 02:23:45 -04:00
|
|
|
}
|
|
|
|
|
2015-05-03 16:29:43 -04:00
|
|
|
// JoinInfo represents a set of resources that the driver has the ability to provide during
|
|
|
|
// join time.
|
2015-05-14 02:23:45 -04:00
|
|
|
type JoinInfo interface {
|
2015-09-09 19:06:35 -04:00
|
|
|
// InterfaceName returns a InterfaceNameInfo go interface to facilitate
|
|
|
|
// setting the names for the interface.
|
|
|
|
InterfaceName() InterfaceNameInfo
|
2015-05-14 02:23:45 -04:00
|
|
|
|
|
|
|
// SetGateway sets the default IPv4 gateway when a container joins the endpoint.
|
|
|
|
SetGateway(net.IP) error
|
|
|
|
|
|
|
|
// SetGatewayIPv6 sets the default IPv6 gateway when a container joins the endpoint.
|
|
|
|
SetGatewayIPv6(net.IP) error
|
|
|
|
|
2015-05-19 20:08:56 -04:00
|
|
|
// AddStaticRoute adds a routes to the sandbox.
|
|
|
|
// It may be used in addtion to or instead of a default gateway (as above).
|
2015-09-09 19:06:35 -04:00
|
|
|
AddStaticRoute(destination *net.IPNet, routeType int, nextHop net.IP) error
|
2015-12-02 21:07:44 -05:00
|
|
|
|
|
|
|
// DisableGatewayService tells libnetwork not to provide Default GW for the container
|
|
|
|
DisableGatewayService()
|
2015-05-03 16:29:43 -04:00
|
|
|
}
|
2015-05-06 19:57:38 -04:00
|
|
|
|
|
|
|
// DriverCallback provides a Callback interface for Drivers into LibNetwork
|
|
|
|
type DriverCallback interface {
|
|
|
|
// RegisterDriver provides a way for Remote drivers to dynamically register new NetworkType and associate with a driver instance
|
2015-06-06 13:21:51 -04:00
|
|
|
RegisterDriver(name string, driver Driver, capability Capability) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Capability represents the high level capabilities of the drivers which libnetwork can make use of
|
|
|
|
type Capability struct {
|
2015-10-05 07:21:15 -04:00
|
|
|
DataScope string
|
2015-05-06 19:57:38 -04:00
|
|
|
}
|
2015-09-18 15:54:08 -04:00
|
|
|
|
2015-10-03 19:11:50 -04:00
|
|
|
// IPAMData represents the per-network ip related
|
|
|
|
// operational information libnetwork will send
|
|
|
|
// to the network driver during CreateNetwork()
|
|
|
|
type IPAMData struct {
|
|
|
|
AddressSpace string
|
|
|
|
Pool *net.IPNet
|
|
|
|
Gateway *net.IPNet
|
|
|
|
AuxAddresses map[string]*net.IPNet
|
|
|
|
}
|