Documentation
¶
Index ¶
- func CustomFieldValue(fields map[string]any, names ...string) any
- func DeletePathForService(tx *gorm.DB, serviceID uint) error
- func FreqFromITU(channel int, gridGHz float64) uint64
- func HzFromNm(nm float64) uint64
- func HzFromTHz(thz float64) uint64
- func LoadKindMaps(db *gorm.DB) (map[string]string, error)
- func MarkStaleByConnection(db *gorm.DB, connectionID uint) error
- func MarkStaleByDevice(db *gorm.DB, deviceID uint) error
- func MarkStaleByInterface(db *gorm.DB, interfaceID uint) error
- func Nm(hz uint64) float64
- func NormalizeOpticalKindCF(raw any) string
- func NormalizeOpticalPortRole(raw any) string
- func OpticalEnabled(db *gorm.DB) bool
- func RebuildPath(db *gorm.DB, g *Graph, serviceID uint) error
- func RebuildStale(db *gorm.DB) error
- func ReresolveAllKinds(db *gorm.DB) error
- func ResolveOpticalKind(cf, role string, maps map[string]string) string
- func THz(hz uint64) float64
- func ValidateXConnect(db *gorm.DB, xc *models.OpticalXConnect) error
- type ApplyResult
- type DeviceImpact
- type Graph
- type Hop
- type ImpactRow
- type Inventory
- type InventoryPort
- type InventoryXConnect
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CustomFieldValue ¶
CustomFieldValue picks the first non-empty NetBox custom-field value among names (optical_role before optical_kind). Selection extras may be a bare string or {"value": "..."}.
func DeletePathForService ¶
DeletePathForService removes path + hops for a service (used on service delete).
func FreqFromITU ¶
FreqFromITU maps a G.694.1 channel number on a grid (GHz) onto Hz. Anchor: channel 0 ≈ 193.1 THz on the 50 GHz grid is conventional for "type a channel" — we use 193.1 THz as channel 0 of the 50 GHz grid (ITU C-band often numbers from 190+). Default UI grid is 50 GHz.
Here channel N on a 50 GHz grid is 193.1 THz + N*50 GHz. Negative channels are allowed (below 193.1 THz).
func LoadKindMaps ¶
LoadKindMaps returns netbox_role_name → optical_kind (names already lower).
func MarkStaleByConnection ¶
MarkStaleByConnection marks paths whose hops reference the connection.
func MarkStaleByDevice ¶ added in v1.0.4
MarkStaleByDevice marks paths that hop through the chassis or its ports.
func MarkStaleByInterface ¶
MarkStaleByInterface marks paths whose hops reference the interface.
func NormalizeOpticalKindCF ¶
NormalizeOpticalKindCF accepts a NetBox custom-field value: a bare string, or a map/struct with a "value" key (selection extras). Invalid or empty returns "". Aliases (transponder/muxponder) become wdm_shelf.
func NormalizeOpticalPortRole ¶
NormalizeOpticalPortRole accepts the same CF shapes as NormalizeOpticalKindCF for an interface optical_role. Invalid/empty → "".
func OpticalEnabled ¶
OpticalEnabled reports Settings.OpticalEnabled (nil/false = off).
func RebuildPath ¶
RebuildPath traces and replaces hops for one service.
func RebuildStale ¶
RebuildStale loads the graph once and rebuilds every stale/incomplete path.
func ReresolveAllKinds ¶
ReresolveAllKinds rewrites Device.OpticalKind from persisted CF then map.
func ResolveOpticalKind ¶
ResolveOpticalKind is CF-then-map. maps keyed by lowercased role name.
func ValidateXConnect ¶
func ValidateXConnect(db *gorm.DB, xc *models.OpticalXConnect) error
ValidateXConnect checks one xconnect against the design rules.
Types ¶
type ApplyResult ¶ added in v1.0.4
type ApplyResult struct {
Kind string `json:"kind"`
PortsUpserted int `json:"ports_upserted"`
PortsSkipped []string `json:"ports_skipped,omitempty"`
XConnectsUpserted int `json:"xconnects_upserted"`
XConnectsDeleted int `json:"xconnects_deleted"`
XConnectsSkipped []string `json:"xconnects_skipped,omitempty"`
}
ApplyResult is what ApplyInventory changed (and skipped).
func ApplyInventory ¶ added in v1.0.4
ApplyInventory upserts Device.OpticalKind, OpticalPort rows, and driver-sourced OpticalXConnects for one chassis. Operator-created xconnects (Source empty) are left alone. Passthrough xconnects from inventory are skipped: ILA/passive walk uses OpticalKind, and ROADM internal-links are not λ adjacencies.
type DeviceImpact ¶
type DeviceImpact struct {
DeviceID uint `json:"device_id"`
Status string `json:"status"`
ServiceCount int `json:"service_count"`
CustomerCount int `json:"customer_count"`
Services []ImpactRow `json:"services"`
}
DeviceImpact is the payload for GET /api/device/:id/impact.
func DeviceDownImpact ¶
func DeviceDownImpact(db *gorm.DB, deviceID uint) (DeviceImpact, error)
DeviceDownImpact unions ELINE endpoints and optical device hops.
type Graph ¶
type Graph struct {
Ifaces map[uint]models.Interface
Devices map[uint]models.Device
Ports map[uint]models.OpticalPort // by interface
ConnsByIface map[uint][]models.Connection
XCsByIface map[uint][]models.OpticalXConnect
Conns map[uint]models.Connection
XCs map[uint]models.OpticalXConnect
}
Graph is an in-memory adjacency list for one walk or a RebuildStale batch.
type Hop ¶
type Hop struct {
Kind string
InterfaceID *uint
ConnectionID *uint
XConnectID *uint
DeviceID *uint
FreqHz uint64
Label string
}
Hop is one walk step (same shape as ServiceHop, without IDs).
type ImpactRow ¶
type ImpactRow struct {
ServiceID uint `json:"id"`
ServiceRef string `json:"service_id"`
Category string `json:"category"`
CustomerID uint `json:"customer_id"`
Customer string `json:"customer"`
Source string `json:"source"`
}
ImpactRow is one affected service.
func ResourceImpact ¶
ResourceImpact lists VL/VI/LF/LI services whose hops touch the resource, or the service itself when the resource is a wavelength/fiber service.
func ResourcesImpact ¶ added in v1.0.5
ResourcesImpact unions ResourceImpact across every attached resource, de-duplicated by services.id.
type Inventory ¶ added in v1.0.4
type Inventory struct {
Kind string `json:"optical_kind"`
Source string `json:"source"`
Ports []InventoryPort `json:"ports"`
XConnects []InventoryXConnect `json:"xconnects"`
}
Inventory is one device's optical ports and intra-device xconnects, as produced by a read-only driver (Open ROADM GetOpticalInventory) and applied onto Factum tables.