ipam

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOutOfRange  = errors.New("AddressOutOfRange")
	ErrConflict    = errors.New("AddressConflict")
	ErrNoAvailable = errors.New("NoAvailableAddress")
	ErrInvalidCIDR = 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, nicName, subnetName string, skippedAddrs []string) (string, string, string, error)

func (*IPAM) GetStaticAddress

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

func (*IPAM) IsIPAssignedToPod

func (ipam *IPAM) IsIPAssignedToPod(ip, subnetName, podName 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
	V4NicToIP        map[string]IP
	V4IPToPod        map[IP]string
	V6CIDR           *net.IPNet
	V6FreeIPList     IPRangeList
	V6ReleasedIPList IPRangeList
	V6ReservedIPList IPRangeList
	V6NicToIP        map[string]IP
	V6IPToPod        map[IP]string
	NicToMac         map[string]string
	MacToPod         map[string]string
	PodToNicList     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, nicName string) (IP, IP, string, string)

func (*Subnet) GetRandomAddress

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

func (*Subnet) GetRandomMac

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

func (*Subnet) GetStaticAddress

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

func (*Subnet) GetStaticMac

func (subnet *Subnet) GetStaticMac(podName, nicName, mac string, checkConflict bool) 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