ipstore

package
v0.0.0-...-2a71758 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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

func NextIP

func NextIP(ip net.IP, subnet net.IPNet) (net.IP, error)

NextIP returns the next ip in the subnet

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

func (manager *IPManager) Assign(ip string, id string) error

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) Exists

func (manager *IPManager) Exists(ip string) (bool, error)

Exists checks whether the ip is used or not

func (*IPManager) Get

func (manager *IPManager) Get(ip string) (string, error)

Get returns the id by which the ip was used and return empty if the key not exists

func (*IPManager) GetAvailableIP

func (manager *IPManager) GetAvailableIP(id string) (string, error)

GetAvailableIP returns the next available ip address

func (*IPManager) Release

func (manager *IPManager) Release(ip string) error

Release marks the ip as available or return an error if the ip is avaialble already

func (*IPManager) ReleaseByID

func (manager *IPManager) ReleaseByID(id string) (string, error)

ReleaseByID release the key-value pair by id

func (*IPManager) SetLastKnownIP

func (manager *IPManager) SetLastKnownIP(ip net.IP)

SetLastKnownIP updates the record of last visited ip address

func (*IPManager) UniqueID

func (manager *IPManager) UniqueID(id string) (bool, error)

UniqueID checks whether the id has already existed in the ipam

func (*IPManager) Update

func (manager *IPManager) Update(key string, value string) error

Update updates the value of existed key in the db

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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