ipam

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OutOfRangeError  = errors.New("AddressOutOfRange")
	ConflictError    = errors.New("AddressConflict")
	NoAvailableError = errors.New("NoAvailableAddress")
	InvalidCIDRError = errors.New("CIDRInvalid")
)

Functions

This section is empty.

Types

type IP

type IP string

func (IP) Add

func (a IP) Add(num int64) IP

func (IP) Equal

func (a IP) Equal(b IP) bool

func (IP) GreaterThan

func (a IP) GreaterThan(b IP) bool

func (IP) LessThan

func (a IP) LessThan(b IP) bool

func (IP) Sub added in v1.7.2

func (a IP) Sub(num int64) IP

type IPAM

type IPAM struct {
	Subnets map[string]*Subnet
	// contains filtered or unexported fields
}

func NewIPAM

func NewIPAM() *IPAM

func (*IPAM) AddOrUpdateSubnet

func (ipam *IPAM) AddOrUpdateSubnet(name, cidrStr string, excludeIps []string) error

func (*IPAM) ContainAddress

func (ipam *IPAM) ContainAddress(address string) bool

func (*IPAM) DeleteSubnet

func (ipam *IPAM) DeleteSubnet(subnetName string)

func (*IPAM) GetPodAddress

func (ipam *IPAM) GetPodAddress(podName string) []*SubnetAddress

func (*IPAM) GetRandomAddress

func (ipam *IPAM) GetRandomAddress(podName, subnetName string, skippedAddrs []string) (string, string, string, error)

func (*IPAM) GetStaticAddress

func (ipam *IPAM) GetStaticAddress(podName, ip, mac, subnetName string) (string, string, string, error)

func (*IPAM) IsIPAssignedToPod

func (ipam *IPAM) IsIPAssignedToPod(ip, subnetName string) bool

func (*IPAM) ReleaseAddressByPod

func (ipam *IPAM) ReleaseAddressByPod(podName string)

type IPRange

type IPRange struct {
	Start IP
	End   IP
}

func (IPRange) IPExist

func (ipr IPRange) IPExist(ip IP) bool

type IPRangeList

type IPRangeList []*IPRange

func (IPRangeList) Contains

func (iprl IPRangeList) Contains(ip IP) bool

type Subnet

type Subnet struct {
	Name string

	Protocol         string
	V4CIDR           *net.IPNet
	V4FreeIPList     IPRangeList
	V4ReleasedIPList IPRangeList
	V4ReservedIPList IPRangeList
	V4PodToIP        map[string]IP
	V4IPToPod        map[IP]string
	V6CIDR           *net.IPNet
	V6FreeIPList     IPRangeList
	V6ReleasedIPList IPRangeList
	V6ReservedIPList IPRangeList
	V6PodToIP        map[string]IP
	V6IPToPod        map[IP]string
	PodToMac         map[string]string
	MacToPod         map[string]string
	// contains filtered or unexported fields
}

func NewSubnet

func NewSubnet(name, cidrStr string, excludeIps []string) (*Subnet, error)

func (*Subnet) ContainAddress

func (subnet *Subnet) ContainAddress(address IP) bool

func (*Subnet) GetPodAddress

func (subnet *Subnet) GetPodAddress(podName string) (IP, IP, string, string)

func (*Subnet) GetRandomAddress

func (subnet *Subnet) GetRandomAddress(podName string, skippedAddrs []string) (IP, IP, string, error)

func (*Subnet) GetRandomMac

func (subnet *Subnet) GetRandomMac(podName string) string

func (*Subnet) GetStaticAddress

func (subnet *Subnet) GetStaticAddress(podName string, ip IP, mac string, force bool) (IP, string, error)

func (*Subnet) GetStaticMac

func (subnet *Subnet) GetStaticMac(podName, mac string) error

func (*Subnet) ReleaseAddress

func (subnet *Subnet) ReleaseAddress(podName string)

type SubnetAddress

type SubnetAddress struct {
	Subnet *Subnet
	Ip     string
	Mac    string
}

Jump to

Keyboard shortcuts

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