ipam

package
v1.12.10 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 13 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 net.IP

func NewIP added in v1.12.0

func NewIP(s string) (IP, error)

func (IP) Add

func (a IP) Add(n int64) IP

func (IP) Clone added in v1.12.0

func (a IP) Clone() 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) String added in v1.12.0

func (a IP) String() string

func (IP) Sub added in v1.7.2

func (a IP) Sub(n int64) IP

func (IP) To16 added in v1.12.0

func (a IP) To16() net.IP

func (IP) To4 added in v1.12.0

func (a IP) To4() net.IP

type IPAM

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

func NewIPAM

func NewIPAM() *IPAM

func (*IPAM) AddOrUpdateIPPool added in v1.12.0

func (ipam *IPAM) AddOrUpdateIPPool(subnet, ippool string, ips []string) error

func (*IPAM) AddOrUpdateSubnet

func (ipam *IPAM) AddOrUpdateSubnet(name, cidrStr, gw 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 string, mac *string, subnetName, poolName string, skippedAddrs []string, checkConflict bool) (string, string, string, error)

func (*IPAM) GetStaticAddress

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

func (*IPAM) GetSubnetIPRangeString added in v1.12.0

func (ipam *IPAM) GetSubnetIPRangeString(subnetName string, excludeIps []string) (string, string, string, string)

func (*IPAM) GetSubnetV4Mask added in v1.10.0

func (ipam *IPAM) GetSubnetV4Mask(subnetName string) (string, error)

func (*IPAM) IPPoolStatistics added in v1.12.0

func (ipam *IPAM) IPPoolStatistics(subnet, ippool string) (
	v4Available, v4Using, v6Available, v6Using internal.BigInt,
	v4AvailableRange, v4UsingRange, v6AvailableRange, v6UsingRange string,
)

func (*IPAM) IsIPAssignedToOtherPod added in v1.11.0

func (ipam *IPAM) IsIPAssignedToOtherPod(ip, subnetName, podName string) (string, bool)

func (*IPAM) ReleaseAddressByPod

func (ipam *IPAM) ReleaseAddressByPod(podName, subnetName string)

func (*IPAM) RemoveIPPool added in v1.12.0

func (ipam *IPAM) RemoveIPPool(subnet, ippool string)

type IPPool added in v1.12.0

type IPPool struct {
	V4IPs       *IPRangeList
	V4Free      *IPRangeList
	V4Available *IPRangeList
	V4Reserved  *IPRangeList
	V4Released  *IPRangeList
	V4Using     *IPRangeList
	V6IPs       *IPRangeList
	V6Free      *IPRangeList
	V6Available *IPRangeList
	V6Reserved  *IPRangeList
	V6Released  *IPRangeList
	V6Using     *IPRangeList
}

type IPRange

type IPRange struct {
	// contains filtered or unexported fields
}

IPRange represents an IP range of [start, end]

func NewIPRange added in v1.12.0

func NewIPRange(start, end IP) *IPRange

func NewIPRangeFromCIDR added in v1.12.0

func NewIPRangeFromCIDR(cidr net.IPNet) *IPRange

func (*IPRange) Add added in v1.12.0

func (r *IPRange) Add(ip IP) bool

func (*IPRange) Clone added in v1.12.0

func (r *IPRange) Clone() *IPRange

func (*IPRange) Contains added in v1.12.0

func (r *IPRange) Contains(ip IP) bool

func (*IPRange) Count added in v1.12.0

func (r *IPRange) Count() internal.BigInt

func (*IPRange) End

func (r *IPRange) End() IP

func (*IPRange) Random added in v1.12.0

func (r *IPRange) Random() IP

func (*IPRange) Remove added in v1.12.0

func (r *IPRange) Remove(ip IP) ([]*IPRange, bool)

func (*IPRange) SetEnd added in v1.12.0

func (r *IPRange) SetEnd(ip IP)

func (*IPRange) SetStart added in v1.12.0

func (r *IPRange) SetStart(ip IP)

func (*IPRange) Start

func (r *IPRange) Start() IP

func (*IPRange) String added in v1.12.0

func (r *IPRange) String() string

type IPRangeList

type IPRangeList struct {
	// contains filtered or unexported fields
}

func NewEmptyIPRangeList added in v1.12.0

func NewEmptyIPRangeList() *IPRangeList

func NewIPRangeList added in v1.12.0

func NewIPRangeList(ips ...IP) (*IPRangeList, error)

func NewIPRangeListFrom added in v1.12.0

func NewIPRangeListFrom(x ...string) (*IPRangeList, error)

func (*IPRangeList) Add added in v1.12.0

func (r *IPRangeList) Add(ip IP) bool

func (*IPRangeList) Allocate added in v1.12.0

func (r *IPRangeList) Allocate(skipped []IP) IP

func (*IPRangeList) At added in v1.12.0

func (r *IPRangeList) At(i int) *IPRange

func (*IPRangeList) Clone added in v1.12.0

func (r *IPRangeList) Clone() *IPRangeList

func (*IPRangeList) Contains

func (r *IPRangeList) Contains(ip IP) bool

func (*IPRangeList) Count added in v1.12.0

func (r *IPRangeList) Count() internal.BigInt

func (*IPRangeList) Equal added in v1.12.0

func (r *IPRangeList) Equal(x *IPRangeList) bool

func (*IPRangeList) Find added in v1.12.0

func (r *IPRangeList) Find(ip IP) (int, bool)

func (*IPRangeList) Intersect added in v1.12.0

func (r *IPRangeList) Intersect(x *IPRangeList) *IPRangeList

Intersect returns a new list which contains items which are in both `r` and `x`

func (*IPRangeList) Len added in v1.12.0

func (r *IPRangeList) Len() int

func (*IPRangeList) Merge added in v1.12.0

func (r *IPRangeList) Merge(x *IPRangeList) *IPRangeList

func (*IPRangeList) MergeRange added in v1.12.0

func (r *IPRangeList) MergeRange(x *IPRange) *IPRangeList

func (*IPRangeList) Remove added in v1.12.0

func (r *IPRangeList) Remove(ip IP) bool

func (*IPRangeList) Separate added in v1.12.0

func (r *IPRangeList) Separate(x *IPRangeList) *IPRangeList

Separate returns a new list which contains items which are in `r` but not in `x`

func (*IPRangeList) String added in v1.12.0

func (r *IPRangeList) String() string

type Subnet

type Subnet struct {
	Name string

	CIDR         string
	Protocol     string
	V4CIDR       *net.IPNet
	V4Free       *IPRangeList
	V4Reserved   *IPRangeList
	V4Available  *IPRangeList
	V4Using      *IPRangeList
	V4NicToIP    map[string]IP
	V4IPToPod    map[string]string
	V6CIDR       *net.IPNet
	V6Free       *IPRangeList
	V6Reserved   *IPRangeList
	V6Available  *IPRangeList
	V6Using      *IPRangeList
	V6NicToIP    map[string]IP
	V6IPToPod    map[string]string
	NicToMac     map[string]string
	MacToPod     map[string]string
	PodToNicList map[string][]string
	V4Gw         string
	V6Gw         string

	IPPools map[string]*IPPool
	// contains filtered or unexported fields
}

func NewSubnet

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

func (*Subnet) AddOrUpdateIPPool added in v1.12.0

func (s *Subnet) AddOrUpdateIPPool(name string, ips []string) error

func (*Subnet) ContainAddress

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

func (*Subnet) GetPodAddress

func (s *Subnet) GetPodAddress(_, nicName string) (IP, IP, string, string)

This func is only called in ipam.GetPodAddress, move mutex to caller

func (*Subnet) GetRandomAddress

func (s *Subnet) GetRandomAddress(poolName, podName, nicName string, mac *string, skippedAddrs []string, checkConflict bool) (IP, IP, string, error)

func (*Subnet) GetRandomMac

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

func (*Subnet) GetStaticAddress

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

func (*Subnet) GetStaticMac

func (s *Subnet) GetStaticMac(podName, nicName, mac string, checkConflict bool) error

func (*Subnet) IPPoolStatistics added in v1.12.0

func (s *Subnet) IPPoolStatistics(ippool string) (
	v4Available, v4Using, v6Available, v6Using internal.BigInt,
	v4AvailableRange, v4UsingRange, v6AvailableRange, v6UsingRange string,
)

func (*Subnet) ReleaseAddress

func (s *Subnet) ReleaseAddress(podName string)

func (*Subnet) ReleaseAddressWithNicName added in v1.12.0

func (s *Subnet) ReleaseAddressWithNicName(podName, nicName string)

func (*Subnet) RemoveIPPool added in v1.12.0

func (s *Subnet) RemoveIPPool(name 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