Documentation
¶
Index ¶
- func AddPool(db *gorm.DB, nsID uint, raw string) (*models.IpamNamespacePrefix, error)
- func Allocate(db *gorm.DB, nsID, vrfID uint, raw, description string, dhcp PrefixDHCP) (*models.IpamPrefix, error)
- func ContainingPrefix(prefixes []models.IpamPrefix, vrfs map[uint]models.IpamVRF, host netip.Prefix, ...) *models.IpamPrefix
- func CreateVRF(db *gorm.DB, nsID uint, w VRFWrite) (*models.IpamVRF, error)
- func DefaultGateway(prefix netip.Prefix) netip.Addr
- func DeleteNamespace(db *gorm.DB, id uint) error
- func DeletePool(db *gorm.DB, nsID, poolID uint) error
- func DeletePrefix(db *gorm.DB, nsID, prefixID uint) error
- func DeleteVRF(db *gorm.DB, nsID, vrfID uint) error
- func DhcpEnabled(db *gorm.DB) bool
- func Enabled(db *gorm.DB) bool
- func EnsureEmptyNamespace(db *gorm.DB) (*models.IpamNamespace, error)
- func ListDhcpPrefixes(db *gorm.DB) ([]models.IpamPrefix, error)
- func ListPools(db *gorm.DB, nsID uint) ([]models.IpamNamespacePrefix, error)
- func ListPrefixes(db *gorm.DB, nsID uint) ([]models.IpamPrefix, error)
- func ListVRFs(db *gorm.DB, nsID uint) ([]models.IpamVRF, error)
- func ParseNodeKey(s string) (string, uint, error)
- func ParsePrefix(s string) (netip.Prefix, error)
- func ResolveAddressPrefix(db *gorm.DB, addr *models.Address, host netip.Prefix, vrfName string, ...) error
- func SplitLines(s string) []string
- func UpdatePrefix(db *gorm.DB, nsID, prefixID uint, description string, dhcp PrefixDHCP) (*models.IpamPrefix, error)
- func UpdateVRF(db *gorm.DB, nsID, vrfID uint, w VRFWrite) (*models.IpamVRF, error)
- type HostCell
- type HostPage
- type NamespaceView
- type PrefixDHCP
- type StatusError
- type TreeNode
- type TreeNodeData
- type VRFListItem
- type VRFWrite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Allocate ¶
func Allocate(db *gorm.DB, nsID, vrfID uint, raw, description string, dhcp PrefixDHCP) (*models.IpamPrefix, error)
func ContainingPrefix ¶ added in v1.1.0
func ContainingPrefix(prefixes []models.IpamPrefix, vrfs map[uint]models.IpamVRF, host netip.Prefix, vrfName string) *models.IpamPrefix
ContainingPrefix picks the most-specific allocated prefix that contains host. When vrfName is non-empty, only prefixes in a VRF of that name (case-insensitive) are considered.
func DefaultGateway ¶ added in v1.0.6
DefaultGateway is the first usable address: network + 1 for prefixes with a network/broadcast pair, otherwise the prefix address itself.
func DhcpEnabled ¶ added in v1.0.6
DhcpEnabled reports Settings.DhcpEnabled (nil/false = off). Disabling the flag only hides per-prefix DHCP UI and the DNS MAC column — it does not touch rows.
func Enabled ¶
Enabled reports Settings.IpamEnabled (nil/false = off). Disabling the flag only hides the UI and 404s /api/ipam/* — it does not touch rows.
func EnsureEmptyNamespace ¶ added in v1.1.1
func EnsureEmptyNamespace(db *gorm.DB) (*models.IpamNamespace, error)
EnsureEmptyNamespace returns the unnamed namespace, creating it (and its default VRF) if needed. Prefixes and extra VRFs stored here are shown at the forest root.
func ListDhcpPrefixes ¶ added in v1.0.6
func ListDhcpPrefixes(db *gorm.DB) ([]models.IpamPrefix, error)
ListDhcpPrefixes returns every allocated prefix with DHCP enabled, across namespaces. Used by factum2-dns to build the dnsmgr2 prefix include.
func ListPrefixes ¶
func ParseNodeKey ¶
ParseNodeKey splits "ns:3" into ("ns", 3).
func ParsePrefix ¶
ParsePrefix accepts a CIDR or a bare address that means "the whole family": 0.0.0.0 and 0.0.0.0/0 are IPv4-any; :: and ::/0 are IPv6-any. The result is always masked (10.1.2.3/24 → 10.1.2.0/24).
func ResolveAddressPrefix ¶ added in v1.1.0
func ResolveAddressPrefix(db *gorm.DB, addr *models.Address, host netip.Prefix, vrfName string, preferredID *uint) error
ResolveAddressPrefix sets addr.PrefixID to the covering allocated prefix. preferredID, when non-nil, must contain the address. vrfName disambiguates overlapping namespaces. Returns a 400 StatusError when no covering prefix exists (or the preferred id is invalid).
func SplitLines ¶ added in v1.0.6
SplitLines trims a newline-separated list, dropping empty lines.
func UpdatePrefix ¶
func UpdatePrefix(db *gorm.DB, nsID, prefixID uint, description string, dhcp PrefixDHCP) (*models.IpamPrefix, error)
Types ¶
type HostCell ¶ added in v1.1.0
type HostCell struct {
Address string `json:"address"`
CIDR string `json:"cidr"`
Allocated bool `json:"allocated"`
}
HostCell is one address in a prefix occupancy page.
type HostPage ¶ added in v1.1.0
type HostPage struct {
PrefixID uint `json:"prefix_id"`
Prefix string `json:"prefix"`
VRFID uint `json:"vrf_id"`
VRFName string `json:"vrf_name"`
Family int `json:"family"`
Bits int `json:"bits"`
Page int `json:"page"`
PageCount int `json:"page_count"`
PagePrefix string `json:"page_prefix"`
PageSize int `json:"page_size"`
Hosts []HostCell `json:"hosts"`
}
HostPage is one page of hosts inside an allocated prefix. IPv4 prefixes longer than /24 (more than 256 addresses) are paged as successive /24s. IPv6 prefixes with more than 256 hosts are paged in 256-address chunks.
type NamespaceView ¶
type NamespaceView struct {
models.IpamNamespace
Pools []models.IpamNamespacePrefix `json:"pools"`
VRFs []models.IpamVRF `json:"vrfs"`
PrefixCount int64 `json:"prefix_count"`
PoolCount int `json:"pool_count"`
VRFCount int `json:"vrf_count"`
}
NamespaceView is a namespace plus the bits the list/detail pages need without extra round-trips.
func CreateNamespace ¶
func CreateNamespace(db *gorm.DB, name, description string) (*NamespaceView, error)
func GetNamespace ¶
func GetNamespace(db *gorm.DB, id uint) (*NamespaceView, error)
func ListNamespaces ¶
func ListNamespaces(db *gorm.DB) ([]NamespaceView, error)
func UpdateNamespace ¶
type PrefixDHCP ¶ added in v1.0.6
type PrefixDHCP struct {
Enabled bool
RangeStart string
RangeEnd string
Gateway string
DnsServers string
}
PrefixDHCP is the DHCP server config stored on an allocated prefix.
type StatusError ¶
StatusError is an application-level failure with an HTTP-ish status so handlers don't have to string-match error text.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type TreeNode ¶
type TreeNode struct {
Key string `json:"key"`
Title string `json:"title"`
Lazy bool `json:"lazy"`
Expanded bool `json:"expanded,omitempty"`
Type string `json:"type"`
Data TreeNodeData `json:"data"`
Children []TreeNode `json:"children,omitempty"`
}
TreeNode is one row of the prefix tree, shaped for Wunderbaum (key, title, lazy, data). Parent/children are computed from CIDR containment.
type TreeNodeData ¶
type TreeNodeData struct {
Kind string `json:"kind"` // namespace | pool | vrf | allocated
ID uint `json:"id"`
NamespaceID uint `json:"namespace_id,omitempty"`
PoolID uint `json:"pool_id,omitempty"`
PrefixID uint `json:"prefix_id,omitempty"`
VRFID uint `json:"vrf_id,omitempty"`
VRFName string `json:"vrf_name,omitempty"`
IsDefault bool `json:"is_default,omitempty"`
Family int `json:"family"`
Description string `json:"description,omitempty"`
Used string `json:"used"`
UsedFrac float64 `json:"used_frac"`
ChildCount int `json:"child_count"`
DhcpEnabled bool `json:"dhcp_enabled,omitempty"`
DhcpRangeStart string `json:"dhcp_range_start,omitempty"`
DhcpRangeEnd string `json:"dhcp_range_end,omitempty"`
DhcpGateway string `json:"dhcp_gateway,omitempty"`
DhcpDnsServers string `json:"dhcp_dns_servers,omitempty"`
RD string `json:"rd,omitempty"`
ImportRT string `json:"import_rt,omitempty"`
ExportRT string `json:"export_rt,omitempty"`
Source string `json:"source,omitempty"`
NetboxID uint `json:"netbox_id,omitempty"`
}
type VRFListItem ¶ added in v1.1.0
type VRFListItem struct {
ID uint `json:"id"`
NamespaceID uint `json:"namespace_id"`
NamespaceName string `json:"namespace_name"`
Name string `json:"name"`
Description string `json:"description"`
IsDefault bool `json:"is_default"`
RD string `json:"rd"`
ImportRT string `json:"import_rt"`
ExportRT string `json:"export_rt"`
Source string `json:"source"`
PrefixCount int64 `json:"prefix_count"`
}
VRFListItem is a VRF plus its namespace name for the address picker.
func ListAllVRFs ¶ added in v1.1.0
func ListAllVRFs(db *gorm.DB) ([]VRFListItem, error)