ipam

package
v0.0.0-...-d248564 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIPOverflow = errors.New(" ip overflow")
)

Functions

func DeleteTenantStore

func DeleteTenantStore(tenantName string) error

func GetTenantIP

func GetTenantIP(tenantList []string) netip.Prefix

func ListSubnets

func ListSubnets(original string, newPrefix int) []string

Types

type Bridge

type Bridge struct {
	Name    string     `json:"name"`
	Gateway netip.Addr `json:"gateway"`
}

type ContainerNetInfo

type ContainerNetInfo struct {
	ID     string `json:"id"`
	IFname string `json:"ifname"`
}

type NodeData

type NodeData struct {
	NodeIP        string                  `json:"nodeIP"`
	NodeCIDR      string                  `json:"nodeCIDR"`
	AvailableList []string                `json:"availableList"`
	TenantList    map[string]netip.Prefix `json:"tenantList"`
}

type NodeIPAM

type NodeIPAM struct {
	NodeName  string
	NodeStore *NodeStore
}

func NewNodeIPAM

func NewNodeIPAM(store *NodeStore, nodeName string) (*NodeIPAM, error)

func (*NodeIPAM) AllocateTenant

func (nim *NodeIPAM) AllocateTenant(tenantName string, tenantVNI int, tenantPrefix int) error

Check if it is possible to create a tenantStore outside and pass it to the function only updating the tenantCIDR

func (*NodeIPAM) RemoveTenant

func (nim *NodeIPAM) RemoveTenant(tenantName string)

type NodeStore

type NodeStore struct {
	*filemutex.FileMutex
	Directory string
	Data      *NodeData
	DataFile  string
}

func NewNodeStore

func NewNodeStore(dataDir string, nodeName string) (*NodeStore, error)

func (*NodeStore) AddAvailableTenantList

func (s *NodeStore) AddAvailableTenantList(availList []string) error

func (*NodeStore) AddNodeCIDR

func (s *NodeStore) AddNodeCIDR(nodeCIDR string) error

func (*NodeStore) AddNodeIP

func (s *NodeStore) AddNodeIP(nodeIP string) error

func (*NodeStore) LoadNodeData

func (s *NodeStore) LoadNodeData() error

Load node data to a node store

func (*NodeStore) StoreNodeData

func (s *NodeStore) StoreNodeData() error

Store node data to a json file

type PodData

type PodData struct {
	Pods map[string]string `json:"pods"`
}

type PodIPAM

type PodIPAM struct {
	PodStore *PodStore
}

func NewPodIPAM

func NewPodIPAM(store *PodStore) (*PodIPAM, error)

type PodStore

type PodStore struct {
	*filemutex.FileMutex
	Directory string
	Data      *PodData
	DataFile  string
}

func NewPodStore

func NewPodStore() (*PodStore, error)

func (*PodStore) LoadPodData

func (s *PodStore) LoadPodData() error

func (*PodStore) StorePodData

func (s *PodStore) StorePodData() error

type TenantData

type TenantData struct {
	TenantName   string  `json:"tenantName"`
	TenantPrefix int     `json:"tenantPrefix"`
	TenantCIDR   string  `json:"tenantCIDR"`
	Bridge       *Bridge `json:"bridge"`
	Vxlan        *Vxlan  `json:"vxlan"`

	IPs  map[string]ContainerNetInfo `json:"ips"`
	Last string                      `json:"last"`
}

type TenantIPAM

type TenantIPAM struct {
	TenantName  string
	TenantStore *TenantStore
}

func NewTenantIPAM

func NewTenantIPAM(store *TenantStore, tenantName string) (*TenantIPAM, error)

func (*TenantIPAM) AllocateIP

func (tim *TenantIPAM) AllocateIP(id string, ifName string) (net.IP, error)

func (*TenantIPAM) CheckIP

func (tim *TenantIPAM) CheckIP(id string) (net.IP, error)

func (*TenantIPAM) IPNet

func (tim *TenantIPAM) IPNet(ip net.IP) *net.IPNet

func (*TenantIPAM) NextIP

func (tim *TenantIPAM) NextIP(ip net.IP) (net.IP, error)

func (*TenantIPAM) ReleaseIP

func (tim *TenantIPAM) ReleaseIP(id string) error

type TenantStore

type TenantStore struct {
	*filemutex.FileMutex
	Directory string
	Data      *TenantData
	DataFile  string
}

func NewTenantStore

func NewTenantStore(dataDir string, tenantName string) (*TenantStore, error)

func (*TenantStore) Add

func (t *TenantStore) Add(ip net.IP, id string, ifname string) error

func (*TenantStore) Contains

func (t *TenantStore) Contains(ip net.IP) bool

func (*TenantStore) Del

func (t *TenantStore) Del(id string) error

func (*TenantStore) GetIPByID

func (t *TenantStore) GetIPByID(id string) (net.IP, bool)

func (*TenantStore) Last

func (t *TenantStore) Last() net.IP

func (*TenantStore) LoadTenantData

func (s *TenantStore) LoadTenantData() error

Load tenant data to a tenant store

func (*TenantStore) StoreTenantData

func (s *TenantStore) StoreTenantData() error

Store tenant data to a json file

type Vxlan

type Vxlan struct {
	VtepName string `json:"vtepName"`
	VtepIP   string `json:"vtepIP"`
	VtepMac  string `json:"vtepMac"`
	VNI      int    `json:"VNI"`
}

Jump to

Keyboard shortcuts

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