2015-09-22 16:20:55 -04:00
|
|
|
// Package ipamapi specifies the contract the IPAM service (built-in or remote) needs to satisfy.
|
|
|
|
package ipamapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
2015-10-20 20:05:01 -04:00
|
|
|
|
2021-04-05 20:24:47 -04:00
|
|
|
"github.com/docker/docker/libnetwork/discoverapi"
|
|
|
|
"github.com/docker/docker/libnetwork/types"
|
2021-05-27 20:15:56 -04:00
|
|
|
"github.com/docker/docker/pkg/plugingetter"
|
2015-09-22 16:20:55 -04:00
|
|
|
)
|
|
|
|
|
2021-08-26 04:10:19 -04:00
|
|
|
// IPAM plugin types
|
2015-09-22 16:20:55 -04:00
|
|
|
const (
|
|
|
|
// DefaultIPAM is the name of the built-in default ipam driver
|
|
|
|
DefaultIPAM = "default"
|
2015-10-28 13:05:19 -04:00
|
|
|
// NullIPAM is the name of the built-in null ipam driver
|
|
|
|
NullIPAM = "null"
|
2015-09-22 16:20:55 -04:00
|
|
|
// PluginEndpointType represents the Endpoint Type used by Plugin system
|
2015-10-12 16:39:38 -04:00
|
|
|
PluginEndpointType = "IpamDriver"
|
2015-12-03 22:20:42 -05:00
|
|
|
// RequestAddressType represents the Address Type used when requesting an address
|
|
|
|
RequestAddressType = "RequestAddressType"
|
2015-09-22 16:20:55 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Callback provides a Callback interface for registering an IPAM instance into LibNetwork
|
|
|
|
type Callback interface {
|
2016-09-27 16:54:25 -04:00
|
|
|
// GetPluginGetter returns the pluginv2 getter.
|
2016-10-07 14:58:10 -04:00
|
|
|
GetPluginGetter() plugingetter.PluginGetter
|
2015-12-09 21:09:58 -05:00
|
|
|
// RegisterIpamDriver provides a way for Remote drivers to dynamically register with libnetwork
|
2015-09-22 16:20:55 -04:00
|
|
|
RegisterIpamDriver(name string, driver Ipam) error
|
2016-06-02 01:37:39 -04:00
|
|
|
// RegisterIpamDriverWithCapabilities provides a way for Remote drivers to dynamically register with libnetwork and specify capabilities
|
2015-12-09 21:09:58 -05:00
|
|
|
RegisterIpamDriverWithCapabilities(name string, driver Ipam, capability *Capability) error
|
2015-09-22 16:20:55 -04:00
|
|
|
}
|
|
|
|
|
2016-02-28 11:34:30 -05:00
|
|
|
// Well-known errors returned by IPAM
|
2015-09-22 16:20:55 -04:00
|
|
|
var (
|
2015-10-20 20:05:01 -04:00
|
|
|
ErrIpamInternalError = types.InternalErrorf("IPAM Internal Error")
|
|
|
|
ErrInvalidAddressSpace = types.BadRequestErrorf("Invalid Address Space")
|
|
|
|
ErrInvalidPool = types.BadRequestErrorf("Invalid Address Pool")
|
|
|
|
ErrInvalidSubPool = types.BadRequestErrorf("Invalid Address SubPool")
|
|
|
|
ErrInvalidRequest = types.BadRequestErrorf("Invalid Request")
|
|
|
|
ErrPoolNotFound = types.BadRequestErrorf("Address Pool not found")
|
|
|
|
ErrOverlapPool = types.ForbiddenErrorf("Address pool overlaps with existing pool on this address space")
|
|
|
|
ErrNoAvailablePool = types.NoServiceErrorf("No available pool")
|
|
|
|
ErrNoAvailableIPs = types.NoServiceErrorf("No available addresses on this pool")
|
2016-07-29 04:45:48 -04:00
|
|
|
ErrNoIPReturned = types.NoServiceErrorf("No address returned")
|
2015-10-20 20:05:01 -04:00
|
|
|
ErrIPAlreadyAllocated = types.ForbiddenErrorf("Address already in use")
|
|
|
|
ErrIPOutOfRange = types.BadRequestErrorf("Requested address is out of range")
|
|
|
|
ErrPoolOverlap = types.ForbiddenErrorf("Pool overlaps with other one on this address space")
|
|
|
|
ErrBadPool = types.BadRequestErrorf("Address space does not contain specified address pool")
|
2015-09-22 16:20:55 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Ipam represents the interface the IPAM service plugins must implement
|
|
|
|
// in order to allow injection/modification of IPAM database.
|
|
|
|
type Ipam interface {
|
2016-01-27 19:37:47 -05:00
|
|
|
discoverapi.Discover
|
|
|
|
|
2015-09-22 16:20:55 -04:00
|
|
|
// GetDefaultAddressSpaces returns the default local and global address spaces for this ipam
|
|
|
|
GetDefaultAddressSpaces() (string, string, error)
|
|
|
|
// RequestPool returns an address pool along with its unique id. Address space is a mandatory field
|
2015-10-12 16:39:38 -04:00
|
|
|
// which denotes a set of non-overlapping pools. pool describes the pool of addresses in CIDR notation.
|
2015-09-22 16:20:55 -04:00
|
|
|
// subpool indicates a smaller range of addresses from the pool, for now it is specified in CIDR notation.
|
|
|
|
// Both pool and subpool are non mandatory fields. When they are not specified, Ipam driver may choose to
|
|
|
|
// return a self chosen pool for this request. In such case the v6 flag needs to be set appropriately so
|
|
|
|
// that the driver would return the expected ip version pool.
|
|
|
|
RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error)
|
|
|
|
// ReleasePool releases the address pool identified by the passed id
|
|
|
|
ReleasePool(poolID string) error
|
2021-08-26 04:10:19 -04:00
|
|
|
// RequestAddress request an address from the specified pool ID. Input options or required IP can be passed.
|
2015-09-22 16:20:55 -04:00
|
|
|
RequestAddress(string, net.IP, map[string]string) (*net.IPNet, map[string]string, error)
|
2021-08-26 04:10:19 -04:00
|
|
|
// ReleaseAddress releases the address from the specified pool ID.
|
2015-09-22 16:20:55 -04:00
|
|
|
ReleaseAddress(string, net.IP) error
|
2016-12-18 22:56:34 -05:00
|
|
|
|
2021-08-26 04:10:19 -04:00
|
|
|
// IsBuiltIn returns true if it is a built-in driver.
|
2016-12-18 22:56:34 -05:00
|
|
|
IsBuiltIn() bool
|
2015-09-22 16:20:55 -04:00
|
|
|
}
|
2015-12-09 21:09:58 -05:00
|
|
|
|
|
|
|
// Capability represents the requirements and capabilities of the IPAM driver
|
|
|
|
type Capability struct {
|
2016-04-18 18:11:36 -04:00
|
|
|
// Whether on address request, libnetwork must
|
|
|
|
// specify the endpoint MAC address
|
2015-12-09 21:09:58 -05:00
|
|
|
RequiresMACAddress bool
|
2016-04-18 18:11:36 -04:00
|
|
|
// Whether of daemon start, libnetwork must replay the pool
|
|
|
|
// request and the address request for current local networks
|
|
|
|
RequiresRequestReplay bool
|
2015-12-09 21:09:58 -05:00
|
|
|
}
|