Documentation ¶
Index ¶
- Constants
- func NextIP(ip net.IP, subnet net.IPNet) (net.IP, error)
- type Config
- type IPAllocator
- type IPManager
- func (manager *IPManager) Assign(ip string, id string) error
- func (manager *IPManager) Close()
- func (manager *IPManager) Exists(ip string) (bool, error)
- func (manager *IPManager) Get(ip string) (string, error)
- func (manager *IPManager) GetAvailableIP(id string) (string, error)
- func (manager *IPManager) Release(ip string) error
- func (manager *IPManager) ReleaseByID(id string) (string, error)
- func (manager *IPManager) SetLastKnownIP(ip net.IP)
- func (manager *IPManager) UniqueID(id string) (bool, error)
- func (manager *IPManager) Update(key string, value string) error
Constants ¶
const ( // Mask size beyond 30 won't be accepted since the .0 and .255 are reserved MaxMask = 30 // This assumes all the ip start with 1 for now before we address // the issue: https://github.com/aws/amazon-ecs-cni-plugins/issues/37 IPPrefix = "1" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { DB string PersistConnection bool Bucket string ConnectionTimeout time.Duration }
Config represents the configuration for boltdb opermation where the ip address are stored
type IPAllocator ¶
type IPAllocator interface { GetAvailableIP(string) (string, error) Get(string) (string, error) Assign(string, string) error Update(string, string) error Release(string) error ReleaseByID(string) (string, error) Exists(string) (bool, error) SetLastKnownIP(net.IP) Close() }
IPAllocator defines the operation for an ip allocator
func NewIPAllocator ¶
func NewIPAllocator(options *Config, subnet net.IPNet) (IPAllocator, error)
NewIPAllocator creates an ip manager from the IPAM and db configuration
type IPManager ¶
type IPManager struct {
// contains filtered or unexported fields
}
IPManager is responsible for managing the ip addresses using boltdb
func (*IPManager) Assign ¶
Assign marks the ip as used or return an error if the ip has already been used
func (*IPManager) Close ¶
func (manager *IPManager) Close()
Close will close the connection to the db
func (*IPManager) Get ¶
Get returns the id by which the ip was used and return empty if the key not exists
func (*IPManager) GetAvailableIP ¶
GetAvailableIP returns the next available ip address
func (*IPManager) Release ¶
Release marks the ip as available or return an error if the ip is avaialble already
func (*IPManager) ReleaseByID ¶
ReleaseByID release the key-value pair by id
func (*IPManager) SetLastKnownIP ¶
SetLastKnownIP updates the record of last visited ip address