ipam

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2015 License: Apache-2.0, BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package ipam that specifies the contract the IPAM plugin need to satisfy, decoupling IPAM interface and implementation.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidIpamService       = errors.New("Invalid IPAM Service")
	ErrInvalidIpamConfigService = errors.New("Invalid IPAM Config Service")
	ErrIpamNotAvailable         = errors.New("IPAM Service not available")
	ErrIpamInternalError        = errors.New("IPAM Internal Error")
	ErrInvalidAddressSpace      = errors.New("Invalid Address Space")
	ErrInvalidSubnet            = errors.New("Invalid Subnet")
	ErrInvalidRequest           = errors.New("Invalid Request")
	ErrSubnetNotFound           = errors.New("Subnet not found")
	ErrOverlapSubnet            = errors.New("Subnet overlaps with existing subnet on this address space")
	ErrNoAvailableSubnet        = errors.New("No available subnet")
	ErrNoAvailableIPs           = errors.New("No available addresses on subnet")
	ErrIPAlreadyAllocated       = errors.New("Address already in use")
	ErrIPOutOfRange             = errors.New("Requested address is out of range")
	ErrSubnetAlreadyRegistered  = errors.New("Subnet already registered on this address space")
	ErrBadSubnet                = errors.New("Address space does not contain specified subnet")
)

ErrIpamNotAvailable is returned when the plugin prviding the IPAM service is not available

Functions

This section is empty.

Types

type AddressRequest

type AddressRequest struct {
	Subnet     net.IPNet // Preferred subnet pool (Optional)
	Address    net.IP    // Preferred address (Optional)
	Endpoint   string    // For static IP mapping (Optional)
	OpaqueData []byte    // Vendor specific request data
}

AddressRequest encloses the information a client needs to pass to IPAM when requesting an address

func (*AddressRequest) Validate

func (req *AddressRequest) Validate() error

Validate runs syntactic validation on this AddressRequest object

type AddressResponse

type AddressResponse struct {
	Address net.IP
	Subnet  SubnetInfo
}

AddressResponse represents the IPAM service's response to an address request

type AddressSpace

type AddressSpace string

AddressSpace identifies a unique pool of network addresses

type Allocator

type Allocator struct {
	App string
	ID  string

	sync.Mutex
	// contains filtered or unexported fields
}

Allocator provides per address space ipv4/ipv6 book keeping

func NewAllocator

func NewAllocator(ds datastore.DataStore) (*Allocator, error)

NewAllocator returns an instance of libnetwork ipam

func (*Allocator) AddSubnet

func (a *Allocator) AddSubnet(addrSpace AddressSpace, subnetInfo *SubnetInfo) error

AddSubnet adds a subnet for the specified address space

func (*Allocator) AddVendorInfo

func (a *Allocator) AddVendorInfo([]byte) error

AddVendorInfo adds vendor specific data

func (*Allocator) DumpDatabase

func (a *Allocator) DumpDatabase()

DumpDatabase dumps the internal info

func (*Allocator) Exists

func (a *Allocator) Exists() bool

Exists method is true if this object has been stored in the DB.

func (*Allocator) Index

func (a *Allocator) Index() uint64

Index returns the latest DB Index as seen by this object

func (*Allocator) Key

func (a *Allocator) Key() []string

Key provides the Key to be used in KV Store

func (*Allocator) KeyPrefix

func (a *Allocator) KeyPrefix() []string

KeyPrefix returns the immediate parent key that can be used for tree walk

func (*Allocator) Release

func (a *Allocator) Release(addrSpace AddressSpace, address net.IP)

Release allows releasing the address from the specified address space

func (*Allocator) RemoveSubnet

func (a *Allocator) RemoveSubnet(addrSpace AddressSpace, subnet *net.IPNet) error

RemoveSubnet removes the subnet from the specified address space

func (*Allocator) Request

func (a *Allocator) Request(addrSpace AddressSpace, req *AddressRequest) (*AddressResponse, error)

Request allows requesting an IPv4 address from the specified address space

func (*Allocator) RequestV6

func (a *Allocator) RequestV6(addrSpace AddressSpace, req *AddressRequest) (*AddressResponse, error)

RequestV6 requesting an IPv6 address from the specified address space

func (*Allocator) SetIndex

func (a *Allocator) SetIndex(index uint64)

SetIndex method allows the datastore to store the latest DB Index into this object

func (*Allocator) SetValue

func (a *Allocator) SetValue(value []byte) error

SetValue unmarshalls the data from the KV store.

func (*Allocator) Value

func (a *Allocator) Value() []byte

Value marshals the data to be stored in the KV store

type Config

type Config interface {
	// AddSubnet adds a subnet to the specified address space
	AddSubnet(AddressSpace, *SubnetInfo) error
	// RemoveSubnet removes a subnet from the specified address space
	RemoveSubnet(AddressSpace, *net.IPNet) error
	// AddVendorInfo adds Vendor specific data
	AddVendorInfo([]byte) error
}

Config represents the interface the IPAM service plugins must implement in order to allow injection/modification of IPAM database. Common key is a addressspace

type IPAM

type IPAM interface {
	// Request address from the specified address space
	Request(AddressSpace, *AddressRequest) (*AddressResponse, error)
	// Separate API for IPv6
	RequestV6(AddressSpace, *AddressRequest) (*AddressResponse, error)
	// Release the address from the specified address space
	Release(AddressSpace, net.IP)
}

IPAM defines the interface that needs to be implemented by IPAM service plugin Common key is a unique address space identifier

type SubnetInfo

type SubnetInfo struct {
	Subnet     *net.IPNet
	Gateway    net.IP
	OpaqueData []byte // Vendor specific
}

SubnetInfo contains the information subnet hosts need in order to communicate

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL