ipam

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPrefixDoesNotExistForIPBlock is the error returned when ipam does not have the entry for the IPBlock
	ErrPrefixDoesNotExistForIPBlock = errors.New("prefix does not exist for IPBlock in ipam db")
	// ErrNilIPBlock is the error when a nil IPBlock was passed
	ErrNilIPBlock = errors.New("ipblock parameter is nil")
)

Functions

func CreateChildIpamEntryForIPBlock

func CreateChildIpamEntryForIPBlock(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ipamDB cipam.Storage, parentIPBlock *cdbm.IPBlock, childBlockSize int) (*cipam.Prefix, error)

CreateChildIpamEntryForIPBlock will create an child ipam entry in the ipam DB for the given parent IP Block, with a given child block size Note: FullGrant is a special case when the childBlockSize matches the parentIPBlock, and the parentIPBlock has no child prefixes, then, the parentIPBlock is updated as a full grant in db, and its prefix is returned (without any updates to the ipam DB)

func CreateIpamEntryForIPBlock

func CreateIpamEntryForIPBlock(ctx context.Context, ipamDB cipam.Storage, prefix string, blockSize int, routingType string, infrastructureProviderID, siteID string) (*cipam.Prefix, error)

CreateIpamEntryForIPBlock will create an ipam entry in the ipam DB for the IPBlock will error if there is a prefix clash in that same namespace

func DeleteChildIpamEntryFromCidr

func DeleteChildIpamEntryFromCidr(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ipamDB cipam.Storage, parentIPBlock *cdbm.IPBlock, childCidr string) error

DeleteChildIpamEntryFromCidr will delete a child ipam entry in the ipam DB given the parent IPBlock, and child cidr Note: FullGrant is a special case when the parentIPBlock has a full grant, and the child is being deleted, then the parent IPBlock's full grant is cleared in db

func DeleteIpamEntryForIPBlock

func DeleteIpamEntryForIPBlock(ctx context.Context, ipamDB cipam.Storage, prefix string, blockSize int, routingType string, infrastructureProviderID, siteID string) error

DeleteIpamEntryForIPBlock will delete the ipam entry in the ipam DB for the IPBlock will not error if the deleted cidr is not existing (idempotent)

func GetCidrForIPBlock

func GetCidrForIPBlock(ctx context.Context, prefix string, blockSize int) string

GetCidrForIPBlock will return the cidr given the prefix, and block size

func GetFirstIPFromCidr

func GetFirstIPFromCidr(cidr string) (string, error)

GetFirstIPFromCidr will parse a cidr, and returns the first IP address in that cidr this is used as the gateway IP

func GetIpamNamespaceForIPBlock

func GetIpamNamespaceForIPBlock(ctx context.Context, routingType string, infrastructureProviderID, siteID string) string

GetIpamNamespaceForIPBlock will return the namespace string for the IPBlock namespace is currently: routingtype/infrastructureProviderID/siteID

func GetIpamUsageForIPBlock

func GetIpamUsageForIPBlock(ctx context.Context, ipamDB cipam.Storage, ipBlock *cdbm.IPBlock) (*cipam.Usage, error)

GetIpamUsageForIPBlock will get an ipam usage for the IPBlock

func NewIpamStorage

func NewIpamStorage(db *bun.DB, tx *bun.Tx) cipam.Storage

NewIpamStorage will return a bun ipam storage interface

func ParseCidrIntoPrefixAndBlockSize

func ParseCidrIntoPrefixAndBlockSize(cidr string) (string, int, error)

ParseCidrIntoPrefixAndBlockSize will parse a cidr into the masked prefix, and blocksize

Types

This section is empty.

Jump to

Keyboard shortcuts

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