Documentation
¶
Index ¶
- Constants
- func AssertInterfacesFree(db *gorm.DB, ifaceAID, ifaceBID, exceptID uint) error
- func BothNetboxInterfaces(a, b models.Interface) bool
- func CableSource(netboxID uint) string
- func CreateCable(db *gorm.DB, ifaceAID, ifaceBID uint, label string) (*models.Connection, error)
- func CreateFloorPlan(db *gorm.DB, siteID uint, name string, width, height, grid int) (*models.FloorPlan, error)
- func CreateRack(db *gorm.DB, w RackWrite) (*models.Rack, error)
- func DeleteCable(db *gorm.DB, id uint) error
- func DeleteRack(db *gorm.DB, id uint) error
- func DeviceAtLocalSite(db *gorm.DB, device models.Device, siteID uint) (bool, error)
- func DeviceIDsAtLocalSite(db *gorm.DB, siteID uint) ([]uint, error)
- func DisplayUnit(rackHeightU, startUnit, offsetU int, numbering string) int
- func GetCable(db *gorm.DB, id uint) (*models.Connection, error)
- func GetRack(db *gorm.DB, id uint) (*models.Rack, error)
- func GraphScopeKey(q GraphQuery) string
- func IntervalsOverlap(aStart, aEnd, bStart, bEnd int) bool
- func Is(err error, reason string) bool
- func ListFloorPlans(db *gorm.DB, siteID uint) ([]models.FloorPlan, error)
- func LoadCableEnds(db *gorm.DB, ifaceAID, ifaceBID uint) (models.Interface, models.Interface, error)
- func LocalSiteIDsForDevice(db *gorm.DB, device models.Device) ([]uint, error)
- func OccupancyPercent(occupied []Occupied, rackTicks int) int
- func OccupiesFace(face string, fullDepth bool, queryFace string) bool
- func OffsetFromNetboxPosition(rackHeightU int, numbering string, startUnit int, positionU, heightU float64) int
- func OutOfRack(offsetTicks, heightTicks, rackTicks int) bool
- func Place(db *gorm.DB, req PlaceRequest) (*models.DevicePlacement, error)
- func PlacementInterval(offsetTicks, heightTicks int) (start, end int)
- func ReasonOf(err error) string
- func RenameFloorPlan(db *gorm.DB, id uint, name string) (*models.FloorPlan, error)
- func SetCableNetboxID(db *gorm.DB, id, netboxID uint) error
- func SnapMM(v, grid int) int
- func StatusOf(err error) int
- func TicksToU(ticks int) float64
- func UToTicks(u float64) int
- func Unmount(db *gorm.DB, deviceID uint, version int) error
- func UpdateCable(db *gorm.DB, id, ifaceAID, ifaceBID uint, label string) (*models.Connection, error)
- func UpdateRack(db *gorm.DB, id uint, w RackWrite) (*models.Rack, error)
- func UtilizedTicks(occupied []Occupied, rackTicks int) int
- func ValidateDeviceTypeResize(db *gorm.DB, typeID uint, newHeight *int, newFull *bool) error
- func ValidateRackHeight(db *gorm.DB, rack models.Rack, newHeightU int) error
- func WholeUBoundary(offsetTicks, heightTicks int) bool
- type DeviceBrief
- type ElevationDTO
- type Error
- type FloorLayoutWrite
- type FloorPlanAnnotationDTO
- type FloorPlanDTO
- type FloorPlanRackDTO
- type Footprint
- type GraphDTO
- type GraphEdge
- type GraphNode
- type GraphPort
- type GraphQuery
- type LayoutDTO
- type Occupied
- type PairCable
- type PairDTO
- type PairDevice
- type PairLink
- type PairPort
- type PlaceRequest
- type PlacementDTO
- type RackSummary
- type RackWrite
- type UnitLabel
- type XY
Constants ¶
const ( ReasonOverlap = "overlap" ReasonOutOfBounds = "out_of_bounds" ReasonImportedReadOnly = "imported_read_only" ReasonStaleVersion = "stale_version" ReasonUnknownDimensions = "unknown_dimensions" ReasonNotFound = "not_found" ReasonInvalid = "invalid" ReasonConflict = "conflict" ReasonForbidden = "forbidden" )
Variables ¶
This section is empty.
Functions ¶
func AssertInterfacesFree ¶
func BothNetboxInterfaces ¶
func CableSource ¶
func CreateCable ¶
func CreateFloorPlan ¶
func DeviceAtLocalSite ¶
func DeviceIDsAtLocalSite ¶
DeviceIDsAtLocalSite returns devices associated with a local site: local SiteID match, imported NetBox site mapping, or a placement in a rack at that site.
func DisplayUnit ¶
DisplayUnit returns the labelled U number for a 1U slot whose bottom is offsetU whole units from the rack bottom.
func GraphScopeKey ¶
func GraphScopeKey(q GraphQuery) string
func IntervalsOverlap ¶
func LoadCableEnds ¶
func LocalSiteIDsForDevice ¶
LocalSiteIDsForDevice returns local sites.id values that this device belongs to. Device.SiteID is a local sites.id for Factum-created devices and a NetBox site id for imported devices — the two sequences are not interchangeable.
func OccupancyPercent ¶
func OffsetFromNetboxPosition ¶
func OffsetFromNetboxPosition(rackHeightU int, numbering string, startUnit int, positionU, heightU float64) int
OffsetFromNetboxPosition converts a NetBox position (lowest-numbered U) into ticks from the bottom of the rack.
func Place ¶
func Place(db *gorm.DB, req PlaceRequest) (*models.DevicePlacement, error)
Place mounts or moves a local device. Imported placements cannot be changed.
func PlacementInterval ¶
func RenameFloorPlan ¶
func UpdateCable ¶
func UtilizedTicks ¶
UtilizedTicks is the union of occupied ticks on either face. A full-depth device is counted once.
func ValidateDeviceTypeResize ¶
ValidateDeviceTypeResize rejects a size change that would overlap or overflow any placement of that type.
func ValidateRackHeight ¶
ValidateRackHeight rejects shrinking a rack over existing placements.
func WholeUBoundary ¶
Types ¶
type DeviceBrief ¶
type DeviceBrief struct {
ID uint `json:"id"`
Name string `json:"name"`
DeviceTypeID uint `json:"device_type_id,omitempty"`
ModelName string `json:"model_name,omitempty"`
VM bool `json:"vm"`
Source string `json:"source,omitempty"`
NetboxID uint `json:"netbox_id,omitempty"`
HeightTicks *int `json:"height_ticks"`
FullDepth *bool `json:"full_depth"`
}
type ElevationDTO ¶
type ElevationDTO struct {
Rack RackSummary `json:"rack"`
Placements []PlacementDTO `json:"placements"`
Unplaced []DeviceBrief `json:"unplaced"`
Accessories []DeviceBrief `json:"accessories"`
Issues []string `json:"issues"`
UnitLabels []UnitLabel `json:"unit_labels"`
}
type FloorLayoutWrite ¶
type FloorLayoutWrite struct {
Revision int `json:"revision"`
WidthMM int `json:"width_mm"`
HeightMM int `json:"height_mm"`
GridMM int `json:"grid_mm"`
Racks []FloorPlanRackDTO `json:"racks"`
Annotations []FloorPlanAnnotationDTO `json:"annotations"`
}
type FloorPlanAnnotationDTO ¶
type FloorPlanDTO ¶
type FloorPlanDTO struct {
ID uint `json:"id"`
SiteID uint `json:"site_id"`
SiteName string `json:"site_name,omitempty"`
Name string `json:"name"`
WidthMM int `json:"width_mm"`
HeightMM int `json:"height_mm"`
GridMM int `json:"grid_mm"`
Revision int `json:"revision"`
Racks []FloorPlanRackDTO `json:"racks"`
Annotations []FloorPlanAnnotationDTO `json:"annotations"`
Available []RackSummary `json:"available_racks,omitempty"`
}
func GetFloorPlan ¶
func GetFloorPlan(db *gorm.DB, id uint) (*FloorPlanDTO, error)
func SaveFloorLayout ¶
func SaveFloorLayout(db *gorm.DB, id uint, w FloorLayoutWrite) (*FloorPlanDTO, error)
type FloorPlanRackDTO ¶
type GraphDTO ¶
type GraphDTO struct {
Scope string `json:"scope"`
Truncated bool `json:"truncated"`
Nodes []GraphNode `json:"nodes"`
Edges []GraphEdge `json:"edges"`
}
func ConnectionGraph ¶
func ConnectionGraph(db *gorm.DB, q GraphQuery) (*GraphDTO, error)
type LayoutDTO ¶
type Occupied ¶
Occupied is one device's occupied interval on a rack face, in ticks from the bottom of the rack. End is exclusive.
func ConflictsWith ¶
func OccupancyFromPlacements ¶
func OccupancyFromPlacements(placements []models.DevicePlacement, heightFor func(deviceID uint) int, fullDepthFor func(deviceID uint) bool) []Occupied
OccupancyFromPlacements builds occupied intervals. heightFor returns the device height in ticks (0 unknown/zero-U). fullDepthFor reports whether the device blocks both faces.
type PairCable ¶
type PairCable struct {
ID uint `json:"id"`
Label string `json:"label,omitempty"`
NetboxID uint `json:"netbox_id,omitempty"`
Source string `json:"source"`
DeviceAID uint `json:"device_a_id"`
InterfaceAID uint `json:"interface_a_id"`
DeviceBID uint `json:"device_b_id"`
InterfaceBID uint `json:"interface_b_id"`
}
type PairDTO ¶
type PairDTO struct {
DeviceA PairDevice `json:"device_a"`
DeviceB PairDevice `json:"device_b"`
Cables []PairCable `json:"cables"`
}
PairDTO is two devices with every interface and the cables between them.
type PairDevice ¶
type PairLink ¶
type PairLink struct {
ID uint `json:"id"`
Label string `json:"label,omitempty"`
NetboxID uint `json:"netbox_id,omitempty"`
Source string `json:"source"`
PeerDeviceID uint `json:"peer_device_id"`
PeerDeviceName string `json:"peer_device_name"`
PeerInterfaceID uint `json:"peer_interface_id"`
PeerInterfaceName string `json:"peer_interface_name"`
}
PairLink is the cable occupying one interface, if any.
type PlaceRequest ¶
type PlacementDTO ¶
type PlacementDTO struct {
ID uint `json:"id"`
DeviceID uint `json:"device_id"`
DeviceName string `json:"device_name"`
DeviceTypeID uint `json:"device_type_id,omitempty"`
ModelName string `json:"model_name,omitempty"`
OffsetTicks int `json:"offset_ticks"`
HeightTicks int `json:"height_ticks"`
HeightU float64 `json:"height_u"`
Face string `json:"face"`
FullDepth bool `json:"full_depth"`
Source string `json:"source"`
Version int `json:"version"`
Conflict string `json:"conflict,omitempty"`
ReadOnly bool `json:"read_only"`
UnknownHeight bool `json:"unknown_height"`
ZeroU bool `json:"zero_u"`
}
type RackSummary ¶
type RackSummary struct {
ID uint `json:"id"`
SiteID uint `json:"site_id"`
SiteName string `json:"site_name,omitempty"`
Name string `json:"name"`
Source string `json:"source"`
NetboxID uint `json:"netbox_id,omitempty"`
HeightU int `json:"height_u"`
WidthMM int `json:"width_mm"`
DepthMM int `json:"depth_mm"`
StartUnit int `json:"start_unit"`
Numbering string `json:"numbering"`
Version int `json:"version"`
DeviceCount int `json:"device_count"`
OccupancyPercent int `json:"occupancy_percent"`
UnknownDimensions int `json:"unknown_dimensions"`
HasConflict bool `json:"has_conflict"`
ReadOnly bool `json:"read_only"`
}