devicetypes

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

* * MIT License * * (C) Copyright 2023-2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *

Index

Constants

View Source
const (
	FaceFront = "front"
	FaceRear  = "rear"
	FaceFull  = "full" // marks both faces blocked (full-depth device)
)

Face constants for rack positioning

View Source
const (
	InterfaceRoleManagement = "management"
	InterfaceRoleHSN        = "hsn"
	InterfaceRoleStorage    = "storage"
	InterfaceRoleAccess     = "access"
)

Well-known interface role names.

View Source
const (
	SchemaVersionV1Alpha1 = "v1alpha1"
	SchemaVersionV1Alpha2 = "v1alpha2"
	SchemaVersionV1Alpha3 = "v1alpha3"
)

Schema version constants for the inventory datastore.

View Source
const (
	Rack           = TypeRack
	Cabinet        = TypeCabinet
	Chassis        = TypeChassis
	Blade          = TypeBlade
	Node           = TypeNode
	NodeCard       = TypeNodeCard
	Switch         = TypeSwitch
	MgmtSwitch     = TypeMgmtSwitch
	HSNSwitch      = TypeHsnSwitch
	CabinetPDU     = TypeCabinetPDU
	CDU            = TypeCDU
	Module         = TypeModule
	NIC            = TypeNIC
	GPU            = TypeGPU
	CPU            = TypeCPU
	Memory         = TypeMemory
	PowerSupply    = TypePowerSupply
	Cable          = TypeCable
	Fru            = TypeFru
	CEC            = TypeCEC
	CMM            = TypeCMM
	NodeController = TypeNodeController
	Adapter        = TypeAdapter
	Transceiver    = TypeTransceiver
)

Hardware type aliases for backwards compatibility.

Variables

AllStatuses contains every known Nautobot status, including Active and Staged which are used internally as constructor defaults.

AllUserStatuses lists statuses selectable by users at the CLI. Staged is excluded because it is assigned automatically by constructors.

View Source
var CableHardware = []Type{TypeCable}

CableHardware is a list of cable/transceiver hardware types.

View Source
var Debug bool

Debug controls verbose logging during type loading.

View Source
var ErrNilDevice = errors.New("device is nil")

ErrNilDevice is returned when a nil device pointer is passed.

Functions

func All

func All() (devices map[string]CaniDeviceType)

func AllCables

func AllCables() map[string]CaniCableType

AllCables returns all loaded cable types.

func AllFruTypes

func AllFruTypes() map[string]CaniFruType

AllFruTypes returns all loaded FRU/inventory-item types.

func AllLocationTypes

func AllLocationTypes() map[string]LocationTypeDefinition

AllLocationTypes returns all loaded location type definitions.

func AllModules

func AllModules() map[string]CaniModuleType

AllModules returns all loaded module types

func AllRackTypes

func AllRackTypes() map[string]CaniRackType

AllRackTypes returns all loaded rack types.

func AllTypesString

func AllTypesString() []string

func ApplyDeviceType

func ApplyDeviceType(device *CaniDeviceType, slug string) error

ApplyDeviceType looks up the slug in the library and copies classification fields from the library template onto the device. Only fields that are empty on the device are overwritten. Returns an error if the slug is not found.

func ApplyPlan

func ApplyPlan(inv *Inventory, plan *ResolvePlan) ([]string, error)

ApplyPlan applies every assignment in the plan to the inventory. It sets Parent (for devices) or Location (for racks), then rebuilds relationships. Returns the list of changes applied.

func ByPartNumber

func ByPartNumber() map[string]CaniDeviceType

ByPartNumber returns the map of device types indexed by part number

func ErrSlugNotFound

func ErrSlugNotFound(slug string) error

ErrSlugNotFound returns an error indicating the given slug is not in the library.

func ExpandChildren

func ExpandChildren(parent *CaniDeviceType) map[uuid.UUID]*CaniDeviceType

ExpandChildren recursively creates child devices for each device-bay that has a default slug defined. Each child gets a new UUID, status Staged, and its Parent set to the parent device's ID. The parent's Children slice is updated accordingly.

Returns a flat map of all newly created devices (keyed by UUID), including nested descendants.

func FindParentPrefix added in v0.6.1

func FindParentPrefix(target *CaniPrefix, prefixes map[uuid.UUID]*CaniPrefix) uuid.UUID

FindParentPrefix finds the most-specific prefix that contains the given prefix. Returns uuid.Nil if no parent exists.

func FindParentPrefixForIP added in v0.6.1

func FindParentPrefixForIP(addr *CaniIPAddress, prefixes map[uuid.UUID]*CaniPrefix) uuid.UUID

FindParentPrefixForIP finds the most-specific prefix that contains the given IP address. Returns uuid.Nil if no parent exists.

func GetAllSlugs

func GetAllSlugs() []string

GetAllSlugs returns a sorted list of all registered device-type slugs.

func InferInterfaceRole added in v0.6.1

func InferInterfaceRole(name string, ifaceType InterfacesElemType, mgmtOnly bool) string

InferInterfaceRole returns a role name based on the interface's name, type, and mgmt_only flag. Returns empty string if no role can be inferred. Priority: mgmt_only flag > name patterns > type-based heuristics.

func IsValidStatus

func IsValidStatus(s string) bool

IsValidStatus returns true when s matches any known Nautobot status (including Active and Staged). The comparison is case-insensitive.

func ListCaniDeviceTypes

func ListCaniDeviceTypes(types ...Type) map[string]CaniDeviceType

ListCaniDeviceTypes returns all device types whose Type matches any of the given types.

func LoadAll

func LoadAll(typesDirs, typesRepos []string, typesRepoClone, typesRepoPull bool) error

LoadAll loads hardware types from all configured sources in priority order:

  1. Built-in (embedded) types — always loaded first.
  2. Local directory types — loaded from each entry in typesDirs.
  3. Remote git repo types — cloned/pulled then loaded from each entry in typesRepos.

When typesRepoPull is false each repo is cloned on first use but never pulled. Types registered first win; duplicates by slug are skipped.

func LoadEmbedded

func LoadEmbedded() error

LoadEmbedded is a no-op if embedded types were already loaded at init. It exists so callers can still reference it explicitly without harm.

func LoadFromDir

func LoadFromDir(root, source string) error

LoadFromDir scans a root directory for hardware type subdirectories (device-types, module-types, cable-types, rack-types, inventory-types) and registers any YAML types found. Existing slugs are not overwritten.

func LoadFromGitRepo

func LoadFromGitRepo(repoURL string, clone, pull bool) error

LoadFromGitRepo clones or pulls a git repository into a local cache directory, then loads hardware types from it. The cache lives under ~/.cani/types-cache/<sanitized-repo-name>/. When pull is false the repo is cloned on first use but never updated.

func NormalizeStatus

func NormalizeStatus(s string) string

NormalizeStatus returns the canonical Title-case form of s if it is a known Nautobot status, or s unchanged when unrecognised.

func ParseIPAddress added in v0.6.1

func ParseIPAddress(addr *CaniIPAddress) error

ParseIPAddress parses the Address (CIDR) field and populates derived fields (Host, MaskLength, IPVersion) on the given CaniIPAddress.

func ParsePrefix added in v0.6.1

func ParsePrefix(p *CaniPrefix) error

ParsePrefix parses a CIDR string and populates the derived fields (Network, Broadcast, PrefixLen, IPVersion) on the given CaniPrefix.

func PlaceDeviceInRack

func PlaceDeviceInRack(dev *CaniDeviceType, devID uuid.UUID, rack *CaniRackType, startU int, face string)

PlaceDeviceInRack places a device into a rack at the given position. If startU is 0, it finds the next available slot. Sets the device's RackPosition and Face fields.

func PromptForDeviceType

func PromptForDeviceType(device UnclassifiedDevice, opts ClassifyOptions) (string, error)

PromptForDeviceType displays an interactive menu that lets the user pick a device-type slug for an unclassified device. Returns the selected slug or an empty string if the user chose to skip.

func PromptForParent

func PromptForParent(inv *Inventory, orphan OrphanItem, suggestions []ParentSuggestion, opts ClassifyOptions) (uuid.UUID, error)

PromptForParent displays an interactive menu that lets the user pick a parent for an orphan item. Returns the selected parent UUID or uuid.Nil if the user chose to skip.

The inv parameter is used for search; it may be nil if search is not needed.

func RegisterCableType

func RegisterCableType(ct CaniCableType)

RegisterCableType adds a cable type to the in-memory registry.

func RegisterDeviceType

func RegisterDeviceType(dt CaniDeviceType)

RegisterDeviceType adds a device type to the in-memory registry.

func RegisterFruType

func RegisterFruType(ft CaniFruType)

RegisterFruType adds a FRU type to the in-memory registry.

func RegisterLocationType

func RegisterLocationType(lt LocationTypeDefinition)

RegisterLocationType adds a location type definition to the in-memory registry.

func RegisterModuleType

func RegisterModuleType(mt CaniModuleType)

RegisterModuleType adds a module type to the in-memory registry

func RegisterRackType

func RegisterRackType(rt CaniRackType)

RegisterRackType adds a rack type to the in-memory registry.

func ResolveInterfaceRole added in v0.6.1

func ResolveInterfaceRole(explicit string, name string, ifaceType InterfacesElemType, mgmtOnly bool) string

ResolveInterfaceRole returns the explicit role if set, otherwise infers one.

func ScoreTierLabel

func ScoreTierLabel(score int) string

ScoreTierLabel returns a short human-readable label for a match score.

func UserStatusNames

func UserStatusNames() string

UserStatusNames returns the display names of AllUserStatuses as a comma-separated string, suitable for error messages and help text.

func ValidateCable

func ValidateCable(cable *CaniCableType, inv *Inventory) error

ValidateCable checks if a cable connection is valid by verifying: 1. Both termination interfaces exist in the inventory 2. Interface types are compatible (same type for copper connections) 3. Interfaces are not already connected to different cables

func WritePlan

func WritePlan(path string, plan *ResolvePlan) error

WritePlan serialises a plan to path as indented JSON.

Types

type AnyResult

type AnyResult struct {
	Category Category
	Device   *CaniDeviceType
	Rack     *CaniRackType
	Module   *CaniModuleType
	Cable    *CaniCableType
}

AnyResult is a discriminated union returned by LookupAny. Exactly one of the typed fields is non-nil.

func LookupAny

func LookupAny(key string) (*AnyResult, error)

LookupAny searches all registries (rack, device, module, cable) for a matching slug or part number. It returns the first exact match found, checking in the order: rack, device, module, cable. Returns an error if nothing matches across any registry.

type CaniCableType

type CaniCableType struct {
	// Identity
	ID           uuid.UUID `json:"id" yaml:"id,omitempty"`
	Slug         string    `json:"slug" yaml:"slug,omitempty"`
	Label        string    `json:"label,omitempty" yaml:"label,omitempty"`
	PartNumber   string    `json:"partNumber,omitempty" yaml:"part_number,omitempty"`
	Manufacturer string    `json:"manufacturer,omitempty" yaml:"manufacturer,omitempty"`
	Model        string    `json:"model,omitempty" yaml:"model,omitempty"`
	Description  string    `json:"description,omitempty" yaml:"description,omitempty"`
	Type         Type      `json:"type,omitempty" yaml:"type,omitempty"`

	// Cable specifics
	CableCategory string   `json:"cableCategory,omitempty" yaml:"cable_category,omitempty"`
	ConnectorType string   `json:"connectorType,omitempty" yaml:"connector_type,omitempty"`
	CableType     string   `json:"cableType,omitempty" yaml:"cable_type,omitempty"` // Nautobot cable type enum (cat3, cat5e, dac-passive, aoc, smf, etc.)
	Length        *float64 `json:"length,omitempty" yaml:"length,omitempty"`
	LengthUnit    string   `json:"lengthUnit,omitempty" yaml:"length_unit,omitempty"`
	Weight        float64  `json:"weight,omitempty" yaml:"weight,omitempty"`
	WeightUnit    string   `json:"weightUnit,omitempty" yaml:"weight_unit,omitempty"`
	Color         string   `json:"color,omitempty" yaml:"color,omitempty"`

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`

	// Inventory state
	TerminationA     uuid.UUID `json:"terminationA,omitempty" yaml:"termination_a,omitempty"`
	TerminationAType string    `json:"terminationAType,omitempty" yaml:"termination_a_type,omitempty"`
	TerminationB     uuid.UUID `json:"terminationB,omitempty" yaml:"termination_b,omitempty"`
	TerminationBType string    `json:"terminationBType,omitempty" yaml:"termination_b_type,omitempty"`

	// Device-level termination references
	TerminationADevice uuid.UUID `json:"terminationADevice,omitempty" yaml:"termination_a_device,omitempty"`
	TerminationBDevice uuid.UUID `json:"terminationBDevice,omitempty" yaml:"termination_b_device,omitempty"`
	TerminationAPort   string    `json:"terminationAPort,omitempty" yaml:"termination_a_port,omitempty"`
	TerminationBPort   string    `json:"terminationBPort,omitempty" yaml:"termination_b_port,omitempty"`

	// Source tracks where this type was loaded from (e.g. "builtin", "local:/path", "git:url").
	Source string `json:"-" yaml:"-"`
}

CaniCableType represents a physical cable, both as hardware-library template and inventory instance.

func GetCableTypeByPartNumber

func GetCableTypeByPartNumber(partNumber string) (CaniCableType, bool)

GetCableTypeByPartNumber looks up a cable type by its part number.

func GetCableTypeBySlug

func GetCableTypeBySlug(slug string) (CaniCableType, bool)

GetCableTypeBySlug looks up a cable type by its slug.

func NewCable

func NewCable(cableType, label string) *CaniCableType

NewCable creates a new CaniCableType with a generated UUID.

func NewCableFromPartNumber

func NewCableFromPartNumber(partNumber string) (*CaniCableType, error)

NewCableFromPartNumber creates a CaniCableType from a part number.

func NewCableFromSlug

func NewCableFromSlug(slug string) (*CaniCableType, error)

NewCableFromSlug creates a CaniCableType instance from a registry slug.

func (*CaniCableType) GetID

func (c *CaniCableType) GetID() uuid.UUID

GetID returns the unique identifier.

func (*CaniCableType) GetSlug

func (c *CaniCableType) GetSlug() string

GetSlug returns the cable type slug.

func (*CaniCableType) GetStatus

func (c *CaniCableType) GetStatus() string

GetStatus returns the current status.

func (*CaniCableType) GetType

func (c *CaniCableType) GetType() Type

GetType returns the cable hardware type.

func (*CaniCableType) GetVendor

func (c *CaniCableType) GetVendor() string

GetVendor returns the manufacturer name.

func (*CaniCableType) SetDeviceTerminations

func (c *CaniCableType) SetDeviceTerminations(deviceA, deviceB uuid.UUID, portA, portB string)

SetDeviceTerminations sets both device UUIDs and port names for the cable endpoints.

func (*CaniCableType) SetTerminations

func (c *CaniCableType) SetTerminations(interfaceA, interfaceB uuid.UUID)

SetTerminations sets both interface terminations.

func (*CaniCableType) Validate

func (c *CaniCableType) Validate() error

Validate checks the cable connection for internal consistency.

type CaniDeviceType

type CaniDeviceType struct {
	// Identity
	ID           uuid.UUID `json:"id" yaml:"id,omitempty"`
	Name         string    `json:"name" yaml:"name,omitempty"`
	Slug         string    `json:"slug" yaml:"slug,omitempty"`
	PartNumber   string    `json:"partNumber" yaml:"part_number,omitempty"`
	Manufacturer string    `json:"manufacturer" yaml:"manufacturer,omitempty"`
	Vendor       string    `json:"vendor,omitempty" yaml:"vendor,omitempty"`
	Model        string    `json:"model" yaml:"model,omitempty"`
	Description  string    `json:"description,omitempty" yaml:"description,omitempty"`
	Serial       string    `json:"serial,omitempty" yaml:"serial,omitempty"`
	AssetTag     string    `json:"assetTag,omitempty" yaml:"asset_tag,omitempty"`

	// Classification
	Type          Type   `json:"type,omitempty" yaml:"type,omitempty"`
	SubdeviceRole string `json:"subdeviceRole,omitempty" yaml:"subdevice_role,omitempty"` // parent or child (chassis/blade)

	// Physical
	UHeight     int     `json:"uHeight,omitempty" yaml:"u_height,omitempty"`
	IsFullDepth bool    `json:"isFullDepth,omitempty" yaml:"is_full_depth,omitempty"`
	Weight      float64 `json:"weight,omitempty" yaml:"weight,omitempty"`
	WeightUnit  string  `json:"weightUnit,omitempty" yaml:"weight_unit,omitempty"`
	Comments    string  `json:"comments,omitempty" yaml:"comments,omitempty"`

	// Hardware specs (from library YAML)
	Interfaces      []InterfaceSpec   `json:"interfaces,omitempty" yaml:"interfaces,omitempty"`
	ConsolePorts    []ConsolePortSpec `json:"consolePorts,omitempty" yaml:"console-ports,omitempty"`
	PowerPorts      []PowerPortSpec   `json:"powerPorts,omitempty" yaml:"power-ports,omitempty"`
	ModuleBays      []ModuleBaySpec   `json:"moduleBays,omitempty" yaml:"module-bays,omitempty"`
	DeviceBays      []DeviceBaySpec   `json:"deviceBays,omitempty" yaml:"device-bays,omitempty"`
	Identifications []Identification  `json:"identifications,omitempty" yaml:"identifications,omitempty"`

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`

	// Inventory state
	Platform string      `json:"platform,omitempty" yaml:"platform,omitempty"` // OS/firmware platform
	Parent   uuid.UUID   `json:"parent" yaml:"parent,omitempty"`
	Children []uuid.UUID `json:"children,omitempty" yaml:"children,omitempty"`
	Frus     []uuid.UUID `json:"frus,omitempty" yaml:"frus,omitempty"`

	// Explicit FK fields for Nautobot export (derived from Parent at load time)
	Rack         uuid.UUID `json:"rack,omitempty" yaml:"rack,omitempty"`                  // FK to CaniRackType
	Location     uuid.UUID `json:"location,omitempty" yaml:"location,omitempty"`          // FK to CaniLocationType
	ParentDevice uuid.UUID `json:"parentDevice,omitempty" yaml:"parent_device,omitempty"` // FK to parent device (blade→chassis)

	// Rack placement
	RackPosition int    `json:"rackPosition,omitempty" yaml:"rack_position,omitempty"`
	Face         string `json:"face,omitempty" yaml:"face,omitempty"`

	// IPAM: primary IP addresses for this device
	PrimaryIPv4 uuid.UUID `json:"primaryIpv4,omitempty" yaml:"primary_ipv4,omitempty"`
	PrimaryIPv6 uuid.UUID `json:"primaryIpv6,omitempty" yaml:"primary_ipv6,omitempty"`

	// Source tracks where this type was loaded from (e.g. "builtin", "local:/path", "git:url").
	Source string `json:"-" yaml:"-"`
}

CaniDeviceType is the single device representation used for both hardware-library templates (loaded from YAML) and inventory instances.

func GetByManufacturerModel

func GetByManufacturerModel(manufacturer, model string) (CaniDeviceType, bool)

GetByManufacturerModel looks up a device type by manufacturer and model. The comparison is case-insensitive and also checks the Identifications array for alternate manufacturer/model combinations. If model is empty, it will match device types with the same manufacturer and an empty model. Returns the device type and true if found, or an empty CaniDeviceType and false if not found.

func GetByPartNumber

func GetByPartNumber(partNumber string) (CaniDeviceType, bool)

GetByPartNumber looks up a device type by its part number. Returns the device type and true if found, or an empty CaniDeviceType and false if not found.

func GetBySlug

func GetBySlug(slug string) (CaniDeviceType, bool)

GetBySlug looks up a device type by its slug. Returns the device type and true if found, or an empty CaniDeviceType and false if not found.

func Lookup

func Lookup(query string) (CaniDeviceType, error)

Lookup searches the device type library for a match against the given query string. It checks in order: exact part number, exact slug, case-insensitive slug, then scored fuzzy match on slug, model, manufacturer, and name. Returns an error if no match is found or the query is empty.

func LookupScored

func LookupScored(query string) (CaniDeviceType, int)

LookupScored is like Lookup but also returns a confidence score. Score 100 = exact part number or slug, lower = fuzzy. Returns zero-value with score 0 when nothing matches.

func NewDeviceFromPartNumber

func NewDeviceFromPartNumber(partNumber string) (*CaniDeviceType, error)

NewDeviceFromPartNumber creates a CaniDeviceType from a part number.

func NewDeviceFromSlug

func NewDeviceFromSlug(slug string) (*CaniDeviceType, error)

NewDeviceFromSlug creates a CaniDeviceType inventory instance from a registry slug.

func (*CaniDeviceType) GetID

func (c *CaniDeviceType) GetID() uuid.UUID

GetID returns the unique identifier.

func (*CaniDeviceType) GetInterface

func (c *CaniDeviceType) GetInterface(name string) *InterfaceSpec

GetInterface returns the interface spec with the given name, or nil if not found.

func (*CaniDeviceType) GetIsFullDepth

func (c *CaniDeviceType) GetIsFullDepth() bool

GetIsFullDepth returns whether this device occupies full rack depth.

func (*CaniDeviceType) GetRackID

func (c *CaniDeviceType) GetRackID(inv *Inventory) uuid.UUID

GetRackID returns the rack ID for this device. Prefers the explicit Rack FK; falls back to checking if Parent exists in the inventory's Racks collection. Returns uuid.Nil if not in a rack.

func (*CaniDeviceType) GetSlug

func (c *CaniDeviceType) GetSlug() string

GetSlug returns the device type slug.

func (*CaniDeviceType) GetStatus

func (c *CaniDeviceType) GetStatus() string

GetStatus returns the current status.

func (*CaniDeviceType) GetType

func (c *CaniDeviceType) GetType() Type

GetType returns the hardware type as a Type constant.

func (*CaniDeviceType) GetUHeight

func (c *CaniDeviceType) GetUHeight() int

GetUHeight returns the U-height for this device. Returns 1 as default if not set.

func (*CaniDeviceType) GetVendor

func (c *CaniDeviceType) GetVendor() string

GetVendor returns the vendor name, falling back to Manufacturer.

func (*CaniDeviceType) InstantiateInterfaces

func (c *CaniDeviceType) InstantiateInterfaces() []InterfaceInstance

InstantiateInterfaces creates InterfaceInstance entries from this device's InterfaceSpec definitions. Returns the instantiated interfaces for assignment to an inventory record.

func (*CaniDeviceType) IsCable

func (c *CaniDeviceType) IsCable() bool

IsCable returns true if this device is a cable type.

func (*CaniDeviceType) MergeProperties

func (c *CaniDeviceType) MergeProperties(other *CaniDeviceType) bool

MergeProperties merges non-empty properties from another CaniDeviceType into this one. Returns true if any changes were made.

func (*CaniDeviceType) Validate

func (c *CaniDeviceType) Validate() error

Validate checks the device type for consistency and returns an error if invalid.

type CaniFruType

type CaniFruType struct {
	// Identity
	ID           uuid.UUID `json:"id" yaml:"id,omitempty"`
	Name         string    `json:"name" yaml:"name,omitempty"`
	Slug         string    `json:"slug" yaml:"slug,omitempty"`
	PartNumber   string    `json:"partNumber" yaml:"part_number,omitempty"`
	Manufacturer string    `json:"manufacturer,omitempty" yaml:"manufacturer,omitempty"`
	Model        string    `json:"model,omitempty" yaml:"model,omitempty"`
	Description  string    `json:"description,omitempty" yaml:"description,omitempty"`
	Type         Type      `json:"type,omitempty" yaml:"type,omitempty"`

	// Physical
	Weight     float64 `json:"weight,omitempty" yaml:"weight,omitempty"`
	WeightUnit string  `json:"weightUnit,omitempty" yaml:"weight_unit,omitempty"`

	// Inventory state
	Label    string `json:"label,omitempty" yaml:"label,omitempty"`
	Serial   string `json:"serial,omitempty" yaml:"serial,omitempty"`
	AssetTag string `json:"assetTag,omitempty" yaml:"asset_tag,omitempty"`
	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`

	Device     uuid.UUID `json:"device,omitempty" yaml:"device,omitempty"`
	Parent     uuid.UUID `json:"parent,omitempty" yaml:"parent,omitempty"`
	Discovered bool      `json:"discovered,omitempty" yaml:"discovered,omitempty"`

	// Source tracks where this type was loaded from (e.g. "builtin", "local:/path", "git:url").
	Source string `json:"-" yaml:"-"`
}

CaniFruType represents a Field Replaceable Unit (spare part or replacement component). Serves as both hardware-library template and inventory instance.

func GetFruTypeByPartNumber

func GetFruTypeByPartNumber(partNumber string) (CaniFruType, bool)

GetFruTypeByPartNumber looks up a FRU type by its part number.

func GetFruTypeBySlug

func GetFruTypeBySlug(slug string) (CaniFruType, bool)

GetFruTypeBySlug looks up a FRU type by its slug.

func NewFruFromPartNumber

func NewFruFromPartNumber(partNumber string) (*CaniFruType, error)

NewFruFromPartNumber creates a CaniFruType from a part number.

func NewFruFromSlug

func NewFruFromSlug(slug string) (*CaniFruType, error)

NewFruFromSlug creates a CaniFruType instance from a registry slug.

func (*CaniFruType) GetID

func (f *CaniFruType) GetID() uuid.UUID

GetID returns the unique identifier.

func (*CaniFruType) GetSlug

func (f *CaniFruType) GetSlug() string

GetSlug returns the FRU type slug.

func (*CaniFruType) GetStatus

func (f *CaniFruType) GetStatus() string

GetStatus returns the current status.

func (*CaniFruType) GetType

func (f *CaniFruType) GetType() Type

GetType returns the hardware type as a Type constant.

func (*CaniFruType) GetVendor

func (f *CaniFruType) GetVendor() string

GetVendor returns the manufacturer name.

func (*CaniFruType) Validate

func (f *CaniFruType) Validate() error

Validate checks the FRU for internal consistency.

type CaniIPAddress added in v0.6.1

type CaniIPAddress struct {
	// Identity
	ID         uuid.UUID `json:"id" yaml:"id"`
	Host       string    `json:"host" yaml:"host"`              // IP without mask: "10.0.0.1"
	MaskLength int       `json:"maskLength" yaml:"mask_length"` // Prefix length: 24
	Address    string    `json:"address" yaml:"address"`        // Combined CIDR: "10.0.0.1/24"
	IPVersion  int       `json:"ipVersion" yaml:"ip_version"`   // 4 or 6

	// Classification
	Type        IPAddressType `json:"type,omitempty" yaml:"type,omitempty"`        // host, dhcp, slaac
	IPRole      IPAddressRole `json:"ipRole,omitempty" yaml:"ip_role,omitempty"`   // loopback, vip, etc.
	DNSName     string        `json:"dnsName,omitempty" yaml:"dns_name,omitempty"` // Optional forward DNS name
	Description string        `json:"description,omitempty" yaml:"description,omitempty"`

	// Relationships
	Parent     uuid.UUID   `json:"parent,omitempty" yaml:"parent,omitempty"`         // Parent prefix (auto-computed)
	Interfaces []uuid.UUID `json:"interfaces,omitempty" yaml:"interfaces,omitempty"` // Assigned interface IDs
	NATInside  uuid.UUID   `json:"natInside,omitempty" yaml:"nat_inside,omitempty"`  // NAT inside IP (optional)

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`
}

CaniIPAddress represents a single host address with its subnet mask. IP addresses are organized under their parent prefix and can be assigned to one or more interfaces.

func (*CaniIPAddress) GetID added in v0.6.1

func (ip *CaniIPAddress) GetID() uuid.UUID

GetID returns the unique identifier.

type CaniLocationType

type CaniLocationType struct {
	// Identity
	ID           uuid.UUID   `json:"id" yaml:"id"`
	Name         string      `json:"name" yaml:"name"`
	Slug         string      `json:"slug,omitempty" yaml:"slug,omitempty"`
	LocationType string      `json:"locationType" yaml:"location_type"` // site, building, floor, room, etc.
	Parent       uuid.UUID   `json:"parent,omitempty" yaml:"parent,omitempty"`
	Children     []uuid.UUID `json:"children,omitempty" yaml:"children,omitempty"` // child locations; rebuilt from Parent at load time
	Racks        []uuid.UUID `json:"racks,omitempty" yaml:"racks,omitempty"`       // racks at this location; rebuilt from CaniRackType.Location at load time

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`

	Nestable     bool     `json:"nestable,omitempty" yaml:"nestable,omitempty"`
	ContentTypes []string `json:"contentTypes,omitempty" yaml:"content_types,omitempty"`
	Source       string   `json:"source,omitempty" yaml:"-"`

	// Nautobot-equivalent fields
	Facility        string `json:"facility,omitempty" yaml:"facility,omitempty"`
	Description     string `json:"description,omitempty" yaml:"description,omitempty"`
	PhysicalAddress string `json:"physicalAddress,omitempty" yaml:"physical_address,omitempty"`
	ShippingAddress string `json:"shippingAddress,omitempty" yaml:"shipping_address,omitempty"`
	Latitude        string `json:"latitude,omitempty" yaml:"latitude,omitempty"`
	Longitude       string `json:"longitude,omitempty" yaml:"longitude,omitempty"`
	ContactName     string `json:"contactName,omitempty" yaml:"contact_name,omitempty"`
	ContactPhone    string `json:"contactPhone,omitempty" yaml:"contact_phone,omitempty"`
	ContactEmail    string `json:"contactEmail,omitempty" yaml:"contact_email,omitempty"`
	TimeZone        string `json:"timeZone,omitempty" yaml:"time_zone,omitempty"`
	Asn             *int64 `json:"asn,omitempty" yaml:"asn,omitempty"`
	Comments        string `json:"comments,omitempty" yaml:"comments,omitempty"`
}

CaniLocationType represents a physical location in the inventory hierarchy. Locations can contain child locations (building → floor → room) and racks.

func NewDefaultLocation

func NewDefaultLocation() *CaniLocationType

NewDefaultLocation creates a location with a generated UUID and sensible defaults, suitable for use as the root location.

func NewLocation

func NewLocation() *CaniLocationType

NewLocation creates a new empty CaniLocationType.

func NewLocationFromSlug

func NewLocationFromSlug(slug string) (*CaniLocationType, error)

NewLocationFromSlug creates a CaniLocationType from a registered LocationTypeDefinition.

func (*CaniLocationType) AddChild

func (l *CaniLocationType) AddChild(childID uuid.UUID)

AddChild adds a child location UUID to this location.

func (*CaniLocationType) AddRack

func (l *CaniLocationType) AddRack(rackID uuid.UUID)

AddRack adds a rack UUID to this location's rack list.

func (*CaniLocationType) GetID

func (l *CaniLocationType) GetID() uuid.UUID

GetID returns the unique identifier.

func (*CaniLocationType) GetSlug

func (l *CaniLocationType) GetSlug() string

GetSlug returns the location type string (e.g., "site", "building", "room").

func (*CaniLocationType) GetStatus

func (l *CaniLocationType) GetStatus() string

GetStatus returns the current status.

func (*CaniLocationType) Validate

func (l *CaniLocationType) Validate() error

Validate checks the location for internal consistency.

func (*CaniLocationType) ValidateContentType

func (l *CaniLocationType) ValidateContentType(ct string) error

ValidateContentType checks whether the given content type is allowed. An empty ContentTypes list permits everything (backwards compatibility).

type CaniModuleType

type CaniModuleType struct {
	// Identity
	ID           uuid.UUID `json:"id" yaml:"id,omitempty"`
	Name         string    `json:"name" yaml:"name,omitempty"`
	Slug         string    `json:"slug" yaml:"slug,omitempty"`
	PartNumber   string    `json:"partNumber,omitempty" yaml:"part_number,omitempty"`
	Manufacturer string    `json:"manufacturer,omitempty" yaml:"manufacturer,omitempty"`
	Model        string    `json:"model,omitempty" yaml:"model,omitempty"`
	Description  string    `json:"description,omitempty" yaml:"description,omitempty"`
	Type         Type      `json:"type,omitempty" yaml:"type,omitempty"`

	// Physical
	Weight     float64 `json:"weight,omitempty" yaml:"weight,omitempty"`
	WeightUnit string  `json:"weightUnit,omitempty" yaml:"weight_unit,omitempty"`
	Comments   string  `json:"comments,omitempty" yaml:"comments,omitempty"`

	// Hardware specs (from library YAML)
	Interfaces []InterfaceSpec `json:"interfaces,omitempty" yaml:"interfaces,omitempty"`

	// Inventory state
	ParentDevice  uuid.UUID `json:"parentDevice,omitempty" yaml:"parent_device,omitempty"`
	ModuleBayName string    `json:"moduleBayName,omitempty" yaml:"module_bay_name,omitempty"`
	Serial        string    `json:"serial,omitempty" yaml:"serial,omitempty"`
	AssetTag      string    `json:"assetTag,omitempty" yaml:"asset_tag,omitempty"`
	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`

	Location uuid.UUID   `json:"location,omitempty" yaml:"location,omitempty"` // optional; inherits from parent device if unset
	Frus     []uuid.UUID `json:"frus,omitempty" yaml:"frus,omitempty"`

	// Source tracks where this type was loaded from (e.g. "builtin", "local:/path", "git:url").
	Source string `json:"-" yaml:"-"`
}

CaniModuleType represents a module installed in a device (GPU, NIC, PSU, memory, etc.). Serves as both hardware-library template and inventory instance.

func GetModuleByManufacturerModel

func GetModuleByManufacturerModel(manufacturer, model string) (CaniModuleType, bool)

GetModuleByManufacturerModel looks up a module type by manufacturer and model. The comparison is case-insensitive. Returns the module type and true if found, or an empty CaniModuleType and false if not found.

func GetModuleBySlug

func GetModuleBySlug(slug string) (CaniModuleType, bool)

GetModuleBySlug looks up a module type by its slug. Returns the module type and true if found, or an empty CaniModuleType and false if not found.

func GetModuleTypeByPartNumber

func GetModuleTypeByPartNumber(partNumber string) (CaniModuleType, bool)

GetModuleTypeByPartNumber looks up a module type by its part number. Returns the module type and true if found, or an empty CaniModuleType and false if not found.

func GetModuleTypeBySlug

func GetModuleTypeBySlug(slug string) (CaniModuleType, bool)

GetModuleTypeBySlug is an alias for GetModuleBySlug for consistency with device type naming. Returns the module type and true if found, or an empty CaniModuleType and false if not found.

func LookupModule

func LookupModule(query string) (CaniModuleType, error)

LookupModule searches the module type library for a match against the given query string. Returns an error if no match is found.

func LookupModuleScored

func LookupModuleScored(query string) (CaniModuleType, int)

LookupModuleScored is like LookupModule but also returns a confidence score.

func NewModuleFromPartNumber

func NewModuleFromPartNumber(partNumber string) (*CaniModuleType, error)

NewModuleFromPartNumber creates a CaniModuleType from a part number.

func NewModuleFromSlug

func NewModuleFromSlug(slug string) (*CaniModuleType, error)

NewModuleFromSlug creates a CaniModuleType inventory instance from a registry slug.

func (*CaniModuleType) GetID

func (m *CaniModuleType) GetID() uuid.UUID

GetID returns the unique identifier.

func (*CaniModuleType) GetInterface

func (m *CaniModuleType) GetInterface(name string) *InterfaceSpec

GetInterface returns the interface spec with the given name, or nil if not found.

func (*CaniModuleType) GetInterfaceByName

func (m *CaniModuleType) GetInterfaceByName(name string) *InterfaceSpec

GetInterfaceByName is an alias for GetInterface.

func (*CaniModuleType) GetSlug

func (m *CaniModuleType) GetSlug() string

GetSlug returns the module type slug.

func (*CaniModuleType) GetStatus

func (m *CaniModuleType) GetStatus() string

GetStatus returns the current status.

func (*CaniModuleType) GetType

func (m *CaniModuleType) GetType() Type

GetType returns the hardware type as a Type constant.

func (*CaniModuleType) GetVendor

func (m *CaniModuleType) GetVendor() string

GetVendor returns the manufacturer name.

func (*CaniModuleType) InstantiateInterfaces

func (m *CaniModuleType) InstantiateInterfaces() []InterfaceInstance

InstantiateInterfaces creates InterfaceInstance entries from this module's specs.

func (*CaniModuleType) Validate

func (m *CaniModuleType) Validate() error

Validate checks the module for internal consistency.

type CaniPrefix added in v0.6.1

type CaniPrefix struct {
	// Identity
	ID          uuid.UUID  `json:"id" yaml:"id"`
	Prefix      string     `json:"prefix" yaml:"prefix"`                           // CIDR notation, e.g. "10.0.0.0/24"
	Network     string     `json:"network,omitempty" yaml:"network,omitempty"`     // Network address (derived)
	Broadcast   string     `json:"broadcast,omitempty" yaml:"broadcast,omitempty"` // Broadcast address (derived)
	PrefixLen   int        `json:"prefixLength" yaml:"prefix_length"`              // Mask bits
	IPVersion   int        `json:"ipVersion" yaml:"ip_version"`                    // 4 or 6
	Type        PrefixType `json:"type,omitempty" yaml:"type,omitempty"`           // container, network, pool
	Description string     `json:"description,omitempty" yaml:"description,omitempty"`

	// Relationships
	Location uuid.UUID `json:"location,omitempty" yaml:"location,omitempty"` // Optional location scope
	VLAN     uuid.UUID `json:"vlan,omitempty" yaml:"vlan,omitempty"`         // Optional VLAN association
	VRF      string    `json:"vrf,omitempty" yaml:"vrf,omitempty"`           // Optional VRF name (string, not FK)
	Parent   uuid.UUID `json:"parent,omitempty" yaml:"parent,omitempty"`     // Parent prefix (auto-computed)

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`
}

CaniPrefix represents an IPv4 or IPv6 network prefix in CIDR notation. Prefixes form a hierarchy: a more-specific prefix is a child of a less-specific one that contains it.

func (*CaniPrefix) GetID added in v0.6.1

func (p *CaniPrefix) GetID() uuid.UUID

GetID returns the unique identifier.

type CaniRackType

type CaniRackType struct {
	// Identity
	ID           uuid.UUID `json:"id" yaml:"id,omitempty"`
	Name         string    `json:"name" yaml:"name,omitempty"`
	Slug         string    `json:"slug" yaml:"slug,omitempty"`
	PartNumber   string    `json:"partNumber,omitempty" yaml:"part_number,omitempty"`
	Manufacturer string    `json:"manufacturer,omitempty" yaml:"manufacturer,omitempty"`
	Model        string    `json:"model,omitempty" yaml:"model,omitempty"`
	Description  string    `json:"description,omitempty" yaml:"description,omitempty"`
	Type         Type      `json:"type,omitempty" yaml:"type,omitempty"`

	// Physical
	UHeight          int             `json:"uHeight" yaml:"u_height,omitempty"`
	OuterWidth       int             `json:"outerWidth,omitempty" yaml:"outer_width,omitempty"`
	OuterDepth       int             `json:"outerDepth,omitempty" yaml:"outer_depth,omitempty"`
	OuterUnit        string          `json:"outerUnit,omitempty" yaml:"outer_unit,omitempty"` // mm or in
	Width            string          `json:"width,omitempty" yaml:"width,omitempty"`          // Nautobot WidthEnum (10/19/21/23 inch)
	Weight           float64         `json:"weight,omitempty" yaml:"weight,omitempty"`
	WeightUnit       string          `json:"weightUnit,omitempty" yaml:"weight_unit,omitempty"`
	DeviceBays       []DeviceBaySpec `json:"deviceBays,omitempty" yaml:"device-bays,omitempty"`
	ModuleBays       []ModuleBaySpec `json:"moduleBays,omitempty" yaml:"module-bays,omitempty"`
	TopZoneHeight    int             `json:"topZoneHeight,omitempty" yaml:"top_zone_height,omitempty"`
	BottomZoneHeight int             `json:"bottomZoneHeight,omitempty" yaml:"bottom_zone_height,omitempty"`

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`

	// Inventory state
	Location      uuid.UUID                    `json:"location,omitempty" yaml:"location,omitempty"`
	RackType      string                       `json:"rackType,omitempty" yaml:"rack_type,omitempty"` // Nautobot enum: 2-post-frame, 4-post-cabinet, etc.
	Serial        string                       `json:"serial,omitempty" yaml:"serial,omitempty"`
	AssetTag      string                       `json:"assetTag,omitempty" yaml:"asset_tag,omitempty"`
	FacilityId    string                       `json:"facilityId,omitempty" yaml:"facility_id,omitempty"`
	DescUnits     bool                         `json:"descUnits,omitempty" yaml:"desc_units,omitempty"` // Descending unit numbering
	Comments      string                       `json:"comments,omitempty" yaml:"comments,omitempty"`
	Devices       []uuid.UUID                  `json:"devices,omitempty" yaml:"devices,omitempty"`              // rebuilt from CaniDeviceType.Rack at load time
	OccupiedSlots map[int]map[string]uuid.UUID `json:"occupiedSlots,omitempty" yaml:"occupied_slots,omitempty"` // rebuilt from CaniDeviceType.RackPosition + .Face at load time

	// ProviderDefaults holds provider-specific defaults from the hardware
	// type YAML (e.g. CSM class, starting ordinal, VLAN ranges).
	// Each key is a provider name ("csm"), and the value is a map of
	// provider-specific settings decoded by the provider package.
	ProviderDefaults map[string]any `json:"providerDefaults,omitempty" yaml:"provider_defaults,omitempty"`

	// Source tracks where this type was loaded from (e.g. "builtin", "local:/path", "git:url").
	Source string `json:"-" yaml:"-"`
}

CaniRackType represents a physical rack, both as hardware-library template and inventory instance. Tracks devices and their U-slot positions.

func GetRackTypeByPartNumber

func GetRackTypeByPartNumber(partNumber string) (CaniRackType, bool)

GetRackTypeByPartNumber looks up a rack type by its part number.

func GetRackTypeBySlug

func GetRackTypeBySlug(slug string) (CaniRackType, bool)

GetRackTypeBySlug looks up a rack type by its slug.

func NewRackFromPartNumber

func NewRackFromPartNumber(partNumber string) (*CaniRackType, error)

NewRackFromPartNumber creates a CaniRackType from a part number.

func NewRackFromSlug

func NewRackFromSlug(slug string) (*CaniRackType, error)

NewRackFromSlug creates a CaniRackType inventory instance from a registry slug.

func (*CaniRackType) CanFitDevice

func (r *CaniRackType) CanFitDevice(startU, height int, face string, isFullDepth bool) bool

CanFitDevice checks if a device can fit at startU with given height and face. startU is 1-based (U1 is the bottom of the rack). isFullDepth devices block both front and rear faces.

func (*CaniRackType) FindNextAvailableSlot

func (r *CaniRackType) FindNextAvailableSlot(height int, face string, isFullDepth bool) int

FindNextAvailableSlot finds the next available starting U-position that can fit a device of the given height and face. It scans from the top of the rack downward so devices populate top-to-bottom. Returns 0 if no space is available.

func (*CaniRackType) GetDeviceFace

func (r *CaniRackType) GetDeviceFace(deviceID uuid.UUID) string

GetDeviceFace returns the face string stored for a device, or "" if not found.

func (*CaniRackType) GetDeviceHeight

func (r *CaniRackType) GetDeviceHeight(deviceID uuid.UUID) int

GetDeviceHeight returns the number of U-slots occupied by a device, or 0 if not found.

func (*CaniRackType) GetDeviceStartU

func (r *CaniRackType) GetDeviceStartU(deviceID uuid.UUID) int

GetDeviceStartU returns the starting U-position for a device, or 0 if not found.

func (*CaniRackType) GetID

func (r *CaniRackType) GetID() uuid.UUID

GetID returns the unique identifier.

func (*CaniRackType) GetSlotOccupant

func (r *CaniRackType) GetSlotOccupant(u int, face string) uuid.UUID

GetSlotOccupant returns the device UUID occupying the given U-position and face, or uuid.Nil if the slot is empty. Also matches full-depth occupants.

func (*CaniRackType) GetSlug

func (r *CaniRackType) GetSlug() string

GetSlug returns the rack type slug.

func (*CaniRackType) GetStatus

func (r *CaniRackType) GetStatus() string

GetStatus returns the current status.

func (*CaniRackType) GetType

func (r *CaniRackType) GetType() Type

GetType returns the hardware type as a Type constant.

func (*CaniRackType) GetVendor

func (r *CaniRackType) GetVendor() string

GetVendor returns the manufacturer name.

func (*CaniRackType) MigrateLegacySlots

func (r *CaniRackType) MigrateLegacySlots(legacy map[int]uuid.UUID)

MigrateLegacySlots converts legacy map[int]uuid.UUID to face-aware format. Call this when loading old inventory data. Defaults all devices to front face.

func (*CaniRackType) PlaceDevice

func (r *CaniRackType) PlaceDevice(deviceID uuid.UUID, startU, height int, face string, isFullDepth bool) bool

PlaceDevice places a device in the rack starting at startU with the given height and face. Returns false if the device cannot fit (slots occupied or out of bounds). isFullDepth devices occupy both front and rear faces.

func (*CaniRackType) RemoveDevice

func (r *CaniRackType) RemoveDevice(deviceID uuid.UUID)

RemoveDevice removes a device from the rack and frees its U-slots.

func (*CaniRackType) SwapDevices

func (r *CaniRackType) SwapDevices(idA, idB uuid.UUID) error

SwapDevices atomically swaps the rack positions of two devices. Each device is placed at the other's former startU, preserving each device's own height and face. Returns an error if either placement would fail.

func (*CaniRackType) Validate

func (r *CaniRackType) Validate() error

Validate checks the rack for internal consistency.

type CaniType

type CaniType interface {
	// Validate checks the instance for internal consistency.
	Validate() error

	// GetID returns the unique identifier.
	GetID() uuid.UUID

	// GetSlug returns the hardware library slug (or type identifier for locations).
	GetSlug() string

	// GetStatus returns the current status string.
	GetStatus() string
}

CaniType is the shared interface implemented by all inventory types. It provides a uniform API for validation, identification, and status across CaniDeviceType, CaniRackType, CaniLocationType, CaniModuleType, CaniCableType, and CaniFruType.

type CaniVLAN added in v0.6.1

type CaniVLAN struct {
	// Identity
	ID          uuid.UUID `json:"id" yaml:"id"`
	VID         int       `json:"vid" yaml:"vid"` // VLAN ID (1-4094)
	Name        string    `json:"name" yaml:"name"`
	Description string    `json:"description,omitempty" yaml:"description,omitempty"`

	// Relationships
	Location uuid.UUID `json:"location,omitempty" yaml:"location,omitempty"` // Optional location scope

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`
}

CaniVLAN represents a layer-2 VLAN domain.

func (*CaniVLAN) GetID added in v0.6.1

func (v *CaniVLAN) GetID() uuid.UUID

GetID returns the unique identifier.

type Category

type Category string

Category represents a classification category.

const (
	CategoryDevice Category = "device"
	CategoryModule Category = "module"
	CategoryCable  Category = "cable"
	CategoryRack   Category = "rack"
	CategoryFru    Category = "fru"
)

func ClassifyForNautobot

func ClassifyForNautobot(hardwareType string) Category

ClassifyForNautobot returns the category for a hardware type.

type ClassifyOptions

type ClassifyOptions struct {
	NoColor bool
	Writer  io.Writer // defaults to os.Stdout
	Reader  io.Reader // defaults to os.Stdin
}

ClassifyOptions controls the interactive classification prompt.

type ConsolePortSpec

type ConsolePortSpec struct {
	Name string `yaml:"name" json:"name"`
	Type string `yaml:"type" json:"type"`
}

ConsolePortSpec defines a console port in a device type.

type DeviceBaySlugRef

type DeviceBaySlugRef struct {
	Slug  interface{} `yaml:"slug" json:"slug"`
	Types interface{} `yaml:"types,omitempty" json:"types,omitempty"`
}

DeviceBaySlugRef is a slug or list of slugs used in allowed/default device-bay fields.

func (DeviceBaySlugRef) AllowedTypes

func (r DeviceBaySlugRef) AllowedTypes() []string

AllowedTypes returns the allowed hardware-type strings as a slice.

func (DeviceBaySlugRef) Slugs

func (r DeviceBaySlugRef) Slugs() []string

Slugs returns the referenced slugs as a string slice.

type DeviceBaySpec

type DeviceBaySpec struct {
	Name     string            `yaml:"name" json:"name"`
	Position string            `yaml:"position,omitempty" json:"position,omitempty"`
	Allowed  *DeviceBaySlugRef `yaml:"allowed,omitempty" json:"allowed,omitempty"`
	Default  *DeviceBaySlugRef `yaml:"default,omitempty" json:"default,omitempty"`
	Extra    map[string]any    `yaml:",inline" json:"extra,omitempty"`
}

DeviceBaySpec defines a device bay (U-slot) in a rack or device type. Provider-specific YAML keys (e.g. "ordinal") are captured in Extra.

type IPAddressRole added in v0.6.1

type IPAddressRole string

IPAddressRole indicates a special function of an IP address.

const (
	IPAddressRoleLoopback  IPAddressRole = "loopback"
	IPAddressRoleSecondary IPAddressRole = "secondary"
	IPAddressRoleAnycast   IPAddressRole = "anycast"
	IPAddressRoleVIP       IPAddressRole = "vip"
	IPAddressRoleVRRP      IPAddressRole = "vrrp"
	IPAddressRoleHSRP      IPAddressRole = "hsrp"
	IPAddressRoleGLBP      IPAddressRole = "glbp"
)

type IPAddressType added in v0.6.1

type IPAddressType string

IPAddressType classifies how an IP address is used.

const (
	IPAddressTypeHost  IPAddressType = "host"
	IPAddressTypeDHCP  IPAddressType = "dhcp"
	IPAddressTypeSLAAC IPAddressType = "slaac"
)

type Identification

type Identification struct {
	Manufacturer string `yaml:"manufacturer" json:"manufacturer"`
	Model        string `yaml:"model" json:"model"`
}

Identification provides alternate manufacturer/model combinations for lookup.

type InterfaceInstance

type InterfaceInstance struct {
	ID            uuid.UUID          `json:"id" yaml:"id"`
	Name          string             `json:"name" yaml:"name"`
	InterfaceType InterfacesElemType `json:"interfaceType" yaml:"interface_type"`
	DeviceID      uuid.UUID          `json:"deviceId" yaml:"device_id"`

	// Shared metadata (status, role, tags, tenant, custom fields, external IDs, provider metadata)
	ObjectMeta `yaml:",inline"`

	MgmtOnly       bool        `json:"mgmtOnly,omitempty" yaml:"mgmt_only,omitempty"`
	Label          string      `json:"label,omitempty" yaml:"label,omitempty"`
	ConnectedCable *uuid.UUID  `json:"connectedCable,omitempty" yaml:"connected_cable,omitempty"`
	ContentType    string      `json:"contentType,omitempty" yaml:"content_type,omitempty"` // For cable terminations (e.g., "dcim.interface")
	IPAddresses    []uuid.UUID `json:"ipAddresses,omitempty" yaml:"ip_addresses,omitempty"` // Assigned IP address IDs
}

InterfaceInstance represents an instantiated interface on a specific device.

type InterfaceSpec

type InterfaceSpec struct {
	ID             uuid.UUID          `yaml:"id,omitempty" json:"id,omitempty"`
	Name           string             `yaml:"name" json:"name"`
	Type           InterfacesElemType `yaml:"type" json:"type"`
	Label          string             `yaml:"label,omitempty" json:"label,omitempty"`
	Role           string             `yaml:"role,omitempty" json:"role,omitempty"`
	MgmtOnly       *bool              `yaml:"mgmt_only,omitempty" json:"mgmt_only,omitempty"`
	ConnectedCable *uuid.UUID         `yaml:"connected_cable,omitempty" json:"connectedCable,omitempty"`
}

InterfaceSpec defines an interface template in a device/module type. When used in inventory, ID and ConnectedCable are populated.

type InterfacesElemType

type InterfacesElemType string

InterfacesElemType represents the type of network interface.

const (
	InterfacesElemTypeA1000BaseT       InterfacesElemType = "1000base-t"
	InterfacesElemTypeA1000BaseKx      InterfacesElemType = "1000base-kx"
	InterfacesElemTypeA10GbaseT        InterfacesElemType = "10gbase-t"
	InterfacesElemTypeA10GbaseXSfpp    InterfacesElemType = "10gbase-x-sfpp"
	InterfacesElemTypeA25GbaseXSfp28   InterfacesElemType = "25gbase-x-sfp28"
	InterfacesElemTypeA40GbaseXQsfpp   InterfacesElemType = "40gbase-x-qsfpp"
	InterfacesElemTypeA100GbaseXQsfp28 InterfacesElemType = "100gbase-x-qsfp28"
	InterfacesElemTypeA200GbaseXQsfp56 InterfacesElemType = "200gbase-x-qsfp56"
	InterfacesElemTypeA400GbaseXQsfpdd InterfacesElemType = "400gbase-x-qsfpdd"
	InterfacesElemTypeA400GbaseXOsfp   InterfacesElemType = "400gbase-x-osfp"
	InterfacesElemTypeVirtual          InterfacesElemType = "virtual"
	InterfacesElemTypeLag              InterfacesElemType = "lag"
)

type Inventory

type Inventory struct {
	SchemaVersion string `json:"schemaVersion" yaml:"schema_version"`
	Provider      string `json:"provider,omitempty" yaml:"provider,omitempty"`

	Locations  map[uuid.UUID]*CaniLocationType  `json:"locations"  yaml:"locations"`
	Racks      map[uuid.UUID]*CaniRackType      `json:"racks"      yaml:"racks"`
	Devices    map[uuid.UUID]*CaniDeviceType    `json:"devices"    yaml:"devices"`
	Modules    map[uuid.UUID]*CaniModuleType    `json:"modules"    yaml:"modules"`
	Cables     map[uuid.UUID]*CaniCableType     `json:"cables"     yaml:"cables"`
	Frus       map[uuid.UUID]*CaniFruType       `json:"frus"       yaml:"frus"`
	Interfaces map[uuid.UUID]*InterfaceInstance `json:"interfaces" yaml:"interfaces"`

	// IPAM
	Prefixes    map[uuid.UUID]*CaniPrefix    `json:"prefixes,omitempty"    yaml:"prefixes,omitempty"`
	IPAddresses map[uuid.UUID]*CaniIPAddress `json:"ipAddresses,omitempty" yaml:"ip_addresses,omitempty"`
	VLANs       map[uuid.UUID]*CaniVLAN      `json:"vlans,omitempty"       yaml:"vlans,omitempty"`

	// Metadata stores the catalog of metadata definitions (roles,
	// statuses, tags) that individual inventory items reference.
	Metadata *InventoryMetadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
	// contains filtered or unexported fields
}

Inventory represents the entire inventory of devices, racks, locations, etc. This is the structure stored in datastore.

func NewInventory

func NewInventory() *Inventory

NewInventory creates an Inventory with all maps initialized.

func (*Inventory) AddCable

func (inv *Inventory) AddCable(cable *CaniCableType) error

AddCable inserts a single cable into the inventory.

func (*Inventory) AddDevices

func (inv *Inventory) AddDevices(batch map[uuid.UUID]*CaniDeviceType) error

AddDevices inserts new devices into the inventory. Returns an error if any UUID already exists.

func (*Inventory) AddIPAddress added in v0.6.1

func (inv *Inventory) AddIPAddress(addr *CaniIPAddress) error

AddIPAddress inserts a single IP address into the inventory and auto-computes its parent prefix.

func (*Inventory) AddLocation

func (inv *Inventory) AddLocation(loc *CaniLocationType) error

AddLocation inserts a single location into the inventory.

func (*Inventory) AddMetadata

func (inv *Inventory) AddMetadata(kind string, entry MetadataEntry) error

AddMetadata stores a metadata definition (role, status, or tag) in the inventory metadata catalog. kind must be "roles", "statuses", or "tags". Returns an error if an entry with the same name already exists.

func (*Inventory) AddModule

func (inv *Inventory) AddModule(mod *CaniModuleType) error

AddModule inserts a single module into the inventory.

func (*Inventory) AddPrefix added in v0.6.1

func (inv *Inventory) AddPrefix(prefix *CaniPrefix) error

AddPrefix inserts a single prefix into the inventory and auto-computes its parent.

func (*Inventory) AddRack

func (inv *Inventory) AddRack(rack *CaniRackType) error

AddRack inserts a single rack into the inventory.

func (*Inventory) AddVLAN added in v0.6.1

func (inv *Inventory) AddVLAN(vlan *CaniVLAN) error

AddVLAN inserts a single VLAN into the inventory.

func (*Inventory) AllRacks

func (inv *Inventory) AllRacks() []*CaniRackType

AllRacks returns every rack in the inventory, sorted alphabetically by name for deterministic ordering.

func (*Inventory) AssignRacksToLocation

func (inv *Inventory) AssignRacksToLocation(locationID uuid.UUID)

AssignRacksToLocation sets the location of every rack that has no parent to the given locationID and records them in the location's Racks list.

func (*Inventory) AvailableModuleBays

func (inv *Inventory) AvailableModuleBays(deviceID uuid.UUID, bayFilter string) []ModuleBaySpec

AvailableModuleBays returns the device's module-bay specs that are not yet occupied by a module. If bayFilter is non-empty, only bays whose name contains the filter string (case-insensitive) are returned.

func (*Inventory) DevicesBySlug

func (inv *Inventory) DevicesBySlug(slug string) []*CaniDeviceType

DevicesBySlug returns all inventory devices matching the given slug, sorted by name for deterministic ordering.

func (*Inventory) DevicesByType

func (inv *Inventory) DevicesByType(deviceType string) []CaniDeviceType

DevicesByType returns all devices of a specific type from the inventory.

func (*Inventory) EnsureLocation

func (inv *Inventory) EnsureLocation() uuid.UUID

EnsureLocation guarantees at least one location exists in the inventory and returns its UUID. If no location exists a default one is created.

func (*Inventory) Exists

func (inv *Inventory) Exists(name string) bool

Exists checks if a device with the given name exists in the inventory.

func (*Inventory) FindCableByLabel

func (inv *Inventory) FindCableByLabel(label string) *CaniCableType

FindCableByLabel returns the first cable matching the given label, or nil.

func (*Inventory) FindConnectableByNameOrID added in v0.6.1

func (inv *Inventory) FindConnectableByNameOrID(ref string) uuid.UUID

FindConnectableByNameOrID searches devices first, then modules, returning the UUID of the matching entity. This allows cables to terminate on either a device or a module. Returns uuid.Nil if nothing matches.

func (*Inventory) FindDeviceByNameOrID

func (inv *Inventory) FindDeviceByNameOrID(ref string) *CaniDeviceType

FindDeviceByNameOrID tries to parse ref as a UUID; if that fails it falls back to a name lookup. Returns nil if nothing matches.

func (*Inventory) FindDeviceByProviderKey

func (inv *Inventory) FindDeviceByProviderKey(provider, key string, value any) *CaniDeviceType

FindDeviceByProviderKey looks up a device whose ProviderMetadata[provider][key] matches value. Uses the O(1) provider-key index when available, falling back to a linear scan otherwise.

func (*Inventory) FindDeviceByProviderKeys

func (inv *Inventory) FindDeviceByProviderKeys(provider string, checks []ProviderKeyCheck) *CaniDeviceType

FindDeviceByProviderKeys scans inventory devices for one whose ProviderMetadata[provider] matches any of the given key/value pairs. Checks are tried in order; returns on first match.

func (*Inventory) FindFruByName

func (inv *Inventory) FindFruByName(name string) *CaniFruType

FindFruByName returns the first FRU matching the given name, or nil.

func (*Inventory) FindLocationByName

func (inv *Inventory) FindLocationByName(name string) *CaniLocationType

FindLocationByName returns the first location matching the given name, or nil.

func (*Inventory) FindLocationByNameOrID

func (inv *Inventory) FindLocationByNameOrID(ref string) *CaniLocationType

FindLocationByNameOrID tries to parse ref as a UUID; if that fails it falls back to a name lookup. Returns nil if nothing matches.

func (*Inventory) FindModuleByName

func (inv *Inventory) FindModuleByName(name string) *CaniModuleType

FindModuleByName returns the first module matching the given name, or nil.

func (*Inventory) FindName

func (inv *Inventory) FindName(name string) (*CaniDeviceType, bool)

FindName finds a device by its name in the inventory.

func (*Inventory) FindRackByName

func (inv *Inventory) FindRackByName(name string) *CaniRackType

FindRackByName returns the first rack matching the given name, or nil.

func (*Inventory) FruExists

func (inv *Inventory) FruExists(name string) bool

FruExists returns true if a FRU with the given name exists.

func (*Inventory) GetCablesForDevice

func (inv *Inventory) GetCablesForDevice(deviceID uuid.UUID) []*CaniCableType

GetCablesForDevice returns all cables where either termination references the device.

func (*Inventory) GetDevicesInRack

func (inv *Inventory) GetDevicesInRack(rackID uuid.UUID) []*CaniDeviceType

GetDevicesInRack returns all devices whose Parent matches the given rack UUID.

func (*Inventory) GetInterfaceByID

func (inv *Inventory) GetInterfaceByID(ifaceID uuid.UUID) (*InterfaceSpec, *CaniDeviceType)

GetInterfaceByID finds an interface by UUID using the Interfaces index. Returns the interface spec and the owning device (nil for module-owned interfaces).

func (*Inventory) GetInterfacesByDevice

func (inv *Inventory) GetInterfacesByDevice(deviceID uuid.UUID) []*InterfaceInstance

GetInterfacesByDevice returns all InterfaceInstance entries belonging to the given device (including interfaces on the device's modules).

func (*Inventory) GetModulesForDevice

func (inv *Inventory) GetModulesForDevice(deviceID uuid.UUID) []*CaniModuleType

GetModulesForDevice returns all modules whose ParentDevice matches the device UUID.

func (*Inventory) ListMetadata

func (inv *Inventory) ListMetadata(kind string) []MetadataEntry

ListMetadata returns all metadata entries for a given kind.

func (*Inventory) LocationExists

func (inv *Inventory) LocationExists(name string) bool

LocationExists returns true if a location with the given name exists.

func (*Inventory) MergeCables

func (inv *Inventory) MergeCables(incoming map[uuid.UUID]*CaniCableType)

MergeCables merges incoming cables by UUID match, then label match, then insert.

func (*Inventory) MergeDevices

func (inv *Inventory) MergeDevices(incoming map[uuid.UUID]*CaniDeviceType)

MergeDevices merges new devices into the inventory by UUID match, then name match, then insert. After changes it verifies parent-child relationships.

func (*Inventory) MergeDevicesStrict

func (inv *Inventory) MergeDevicesStrict(incoming map[uuid.UUID]*CaniDeviceType, strict bool) []UnclassifiedDevice

MergeDevicesStrict behaves like MergeDevices but when strict is true it skips any device whose Slug and Model are both empty (unclassified). Skipped devices are collected and returned so callers can report or interactively resolve them.

func (*Inventory) MergeFrus

func (inv *Inventory) MergeFrus(incoming map[uuid.UUID]*CaniFruType)

MergeFrus merges incoming FRUs by UUID match, then name match, then insert.

func (*Inventory) MergeLocations

func (inv *Inventory) MergeLocations(incoming map[uuid.UUID]*CaniLocationType) map[uuid.UUID]uuid.UUID

MergeLocations merges incoming locations by UUID match, then name match, then insert. Returns a remap map from incoming UUID to existing UUID for name-matched locations.

func (*Inventory) MergeModules

func (inv *Inventory) MergeModules(incoming map[uuid.UUID]*CaniModuleType)

MergeModules merges incoming modules by UUID match, then name match, then insert.

func (*Inventory) MergeRacks

func (inv *Inventory) MergeRacks(incoming map[uuid.UUID]*CaniRackType) map[uuid.UUID]uuid.UUID

MergeRacks merges incoming racks by UUID match, then name match, then insert. Returns a remap map from incoming UUID to existing UUID for name-matched racks.

func (*Inventory) ModuleExists

func (inv *Inventory) ModuleExists(name string) bool

ModuleExists returns true if a module with the given name exists.

func (*Inventory) OccupiedModuleBays

func (inv *Inventory) OccupiedModuleBays(deviceID uuid.UUID) map[string]uuid.UUID

OccupiedModuleBays returns a map of bay-name → module-ID for all modules installed in the given device. This mirrors how Nautobot tracks module bay occupancy: each Module references a ModuleBay (by name) on a parent Device, and occupancy is implicit from the Module records.

func (*Inventory) OrphanDevices

func (inv *Inventory) OrphanDevices() []OrphanItem

OrphanDevices returns all devices whose Parent field is uuid.Nil. Results are sorted by name for deterministic output.

func (*Inventory) OrphanRacks

func (inv *Inventory) OrphanRacks() []OrphanItem

OrphanRacks returns all racks whose Location field is uuid.Nil. Results are sorted by name for deterministic output.

func (*Inventory) RackExists

func (inv *Inventory) RackExists(name string) bool

RackExists returns true if a rack with the given name exists.

func (*Inventory) RacksByLocation

func (inv *Inventory) RacksByLocation(locationID uuid.UUID) []*CaniRackType

RacksByLocation returns all racks at the given location, sorted alphabetically by name for deterministic ordering.

func (*Inventory) RebuildProviderKeyIndex

func (inv *Inventory) RebuildProviderKeyIndex()

RebuildProviderKeyIndex rebuilds the transient provider-key lookup index from all devices' ProviderMetadata. Call this once after loading the inventory from the datastore.

func (*Inventory) RemoveCable

func (inv *Inventory) RemoveCable(id uuid.UUID) error

RemoveCable deletes a cable from the inventory.

func (*Inventory) RemoveDevice

func (inv *Inventory) RemoveDevice(id uuid.UUID) error

RemoveDevice deletes a device and cleans up all references:

  • removes from parent's Children list
  • removes rack slot occupancy
  • deletes cables referencing the device
  • deletes child modules belonging to the device

func (*Inventory) RemoveLocation

func (inv *Inventory) RemoveLocation(id uuid.UUID) error

RemoveLocation deletes a location and unlinks it from parent/children.

func (*Inventory) RemoveModule

func (inv *Inventory) RemoveModule(id uuid.UUID) error

RemoveModule deletes a module from the inventory.

func (*Inventory) RemoveRack

func (inv *Inventory) RemoveRack(id uuid.UUID) error

RemoveRack deletes a rack and moves any contained devices to orphaned state.

func (*Inventory) Validate

func (inv *Inventory) Validate() error

Validate checks referential integrity across the entire inventory. It returns an error describing all broken references, or nil if valid.

func (*Inventory) VerifyParentChildRelationships

func (inv *Inventory) VerifyParentChildRelationships() *RelationshipResult

VerifyParentChildRelationships rebuilds all bidirectional parent-child references across the full inventory hierarchy:

Location → Child Locations  (Location.Parent ↔ Location.Children)
Location → Racks            (Rack.Location   ↔ Location.Racks)
Rack     → Devices          (Device.Parent   ↔ Rack.Devices)
Device   → Child Devices    (Device.Parent   ↔ Device.Children)

It also validates (without mutating) module, FRU, and cable references and detects circular parent chains.

The function clears and rebuilds all reverse lists from scratch so that only setting a Parent field is required; all other references are derived.

type InventoryMetadata

type InventoryMetadata struct {
	Roles    []MetadataEntry `json:"roles,omitempty"    yaml:"roles,omitempty"`
	Statuses []MetadataEntry `json:"statuses,omitempty" yaml:"statuses,omitempty"`
	Tags     []MetadataEntry `json:"tags,omitempty"     yaml:"tags,omitempty"`
}

InventoryMetadata holds the catalog of metadata definitions (roles, statuses, tags) that can be referenced by individual inventory items. It lives at the top level of the Inventory struct.

type LocationTypeDefinition

type LocationTypeDefinition struct {
	Name         string   `json:"name" yaml:"name"`
	Slug         string   `json:"slug" yaml:"slug"`
	Description  string   `json:"description,omitempty" yaml:"description,omitempty"`
	Nestable     bool     `json:"nestable,omitempty" yaml:"nestable,omitempty"`
	ContentTypes []string `json:"content_types,omitempty" yaml:"content_types,omitempty"`
	Parent       string   `json:"parent,omitempty" yaml:"parent,omitempty"` // parent type slug
	Source       string   `json:"source,omitempty" yaml:"-"`
}

LocationTypeDefinition is the YAML-loadable template for a Nautobot LocationType. Each YAML file in location-types/ maps 1:1 to a Nautobot LocationType.

func GetLocationTypeBySlug

func GetLocationTypeBySlug(slug string) (LocationTypeDefinition, bool)

GetLocationTypeBySlug looks up a location type definition by its slug.

func (*LocationTypeDefinition) Validate

func (d *LocationTypeDefinition) Validate() error

Validate checks the definition for required fields.

type MatchResult

type MatchResult struct {
	Slug  string
	Score int
}

MatchResult pairs a lookup result with a confidence score.

func FuzzyMatchAll

func FuzzyMatchAll(query string, max int) []MatchResult

FuzzyMatchAll returns all device types that score at or above minAcceptScore for the given query, sorted by descending score. This is used by SuggestTypes to gather multiple candidates instead of just the single best.

func SuggestTypes

func SuggestTypes(device UnclassifiedDevice, maxResults int) []MatchResult

SuggestTypes queries the device-type library with every non-empty field of the device and returns the top unique candidates ordered by descending score. At most maxResults entries are returned. When text-based matching yields fewer than maxResults candidates, a hardware-type fallback fills in additional suggestions from device types whose HardwareType matches.

type MetadataEntry

type MetadataEntry struct {
	Name         string   `json:"name" yaml:"name"`
	Color        string   `json:"color,omitempty" yaml:"color,omitempty"`
	Description  string   `json:"description,omitempty" yaml:"description,omitempty"`
	ContentTypes []string `json:"contentTypes,omitempty" yaml:"content_types,omitempty"`
	Weight       int      `json:"weight,omitempty" yaml:"weight,omitempty"`
}

MetadataEntry represents a role, status, or tag definition stored in the inventory metadata catalog.

type ModuleBaySpec

type ModuleBaySpec struct {
	Name     string `yaml:"name" json:"name"`
	Position string `yaml:"position,omitempty" json:"position,omitempty"`
}

ModuleBaySpec defines a module bay/slot in a device type.

type NautobotStatus

type NautobotStatus string

NautobotStatus represents a valid Nautobot status value.

const (
	StatusActive          NautobotStatus = "Active"
	StatusAvailable       NautobotStatus = "Available"
	StatusConnected       NautobotStatus = "Connected"
	StatusDecommissioned  NautobotStatus = "Decommissioned"
	StatusDecommissioning NautobotStatus = "Decommissioning"
	StatusDeprecated      NautobotStatus = "Deprecated"
	StatusDeprovisioning  NautobotStatus = "Deprovisioning"
	StatusDown            NautobotStatus = "Down"
	StatusEndOfLife       NautobotStatus = "End-of-Life"
	StatusExtendedSupport NautobotStatus = "Extended Support"
	StatusFailed          NautobotStatus = "Failed"
	StatusInventory       NautobotStatus = "Inventory"
	StatusMaintenance     NautobotStatus = "Maintenance"
	StatusOffline         NautobotStatus = "Offline"
	StatusPlanned         NautobotStatus = "Planned"
	StatusPrimary         NautobotStatus = "Primary"
	StatusProvisioning    NautobotStatus = "Provisioning"
	StatusReserved        NautobotStatus = "Reserved"
	StatusRetired         NautobotStatus = "Retired"
	StatusSecondary       NautobotStatus = "Secondary"
	StatusStaged          NautobotStatus = "Staged"
	StatusStaging         NautobotStatus = "Staging"
)

func ValidateUserStatus

func ValidateUserStatus(s string) (NautobotStatus, error)

ValidateUserStatus checks that s matches one of AllUserStatuses (case-insensitive) and returns the canonical Title-case form.

type ObjectMeta

type ObjectMeta struct {
	Status           string               `json:"status"                      yaml:"status,omitempty"`
	Role             string               `json:"role,omitempty"              yaml:"role,omitempty"`
	Tags             []string             `json:"tags,omitempty"              yaml:"tags,omitempty"`
	Tenant           string               `json:"tenant,omitempty"            yaml:"tenant,omitempty"`
	CustomFields     map[string]any       `json:"customFields,omitempty"      yaml:"custom_fields,omitempty"`
	ExternalIDs      map[string]uuid.UUID `json:"externalIDs,omitempty"       yaml:"external_ids,omitempty"`
	ProviderMetadata map[string]any       `json:"providerMetadata,omitempty"  yaml:"provider_metadata,omitempty"`
}

ObjectMeta contains metadata fields shared across all inventory types. Embed this struct in any inventory type to gain consistent support for status, role, tags, tenant, custom fields, external IDs, and provider metadata. Go promotes the embedded fields so callers can access them directly (e.g. device.Status, rack.Tags).

func (*ObjectMeta) FlattenProviderMetadata

func (m *ObjectMeta) FlattenProviderMetadata() map[string]any

FlattenProviderMetadata returns a flat map of all provider metadata, combining all provider sub-maps and top-level keys. Provider sub-map keys are NOT prefixed. If multiple providers define the same key, the last one wins (map iteration order).

func (*ObjectMeta) GetImportSource

func (m *ObjectMeta) GetImportSource(provider string) string

GetImportSource returns the "import_source" value from the named provider sub-map. Returns an empty string if not set.

func (*ObjectMeta) GetProviderMeta

func (m *ObjectMeta) GetProviderMeta(key string) (any, bool)

GetProviderMeta searches all provider sub-maps in ProviderMetadata for the given key and returns the first match. Top-level keys are checked first, then each provider sub-map is scanned.

func (*ObjectMeta) GetProviderSubMap

func (m *ObjectMeta) GetProviderSubMap(provider string) (map[string]any, bool)

GetProviderSubMap returns the provider-specific sub-map for the given provider name (e.g. "redfish", "csm", "hpcm").

func (ObjectMeta) GetRole added in v0.6.1

func (m ObjectMeta) GetRole() string

GetRole returns the effective role: the explicit Role field if set, otherwise the first "role" value found in ProviderMetadata.

func (*ObjectMeta) SetImportSource

func (m *ObjectMeta) SetImportSource(provider, source string)

SetImportSource sets the "import_source" key inside the named provider sub-map, creating the sub-map if it does not exist.

func (*ObjectMeta) SetProviderMeta

func (m *ObjectMeta) SetProviderMeta(provider, key string, value any)

SetProviderMeta sets a key inside the named provider sub-map, creating the sub-map if it does not exist.

type OrphanItem

type OrphanItem struct {
	ID               uuid.UUID
	Name             string
	Kind             string // "device" or "rack"
	DeviceType       string
	Model            string
	Manufacturer     string
	ProviderMetadata map[string]any
}

OrphanItem describes an inventory item that has no parent assigned.

type ParentSuggestion

type ParentSuggestion struct {
	ID     uuid.UUID
	Name   string
	Kind   string // "rack", "device", "location"
	Score  int    // 0–100
	Reason string // human-readable explanation
	Detail string // extra context: location, model, device count, etc.
}

ParentSuggestion is a scored candidate parent for an orphan.

func SearchParentCandidates

func SearchParentCandidates(inv *Inventory, query string, orphanKind string, maxResults int) []ParentSuggestion

SearchParentCandidates searches the next level up in the hierarchy by name substring. Devices → racks, racks → locations.

func SuggestParents

func SuggestParents(inv *Inventory, orphan OrphanItem, maxResults int) []ParentSuggestion

SuggestParents returns ranked candidate parents for an orphan. The hierarchy is strictly: location → rack → device → module → FRU. Orphan devices suggest racks only; orphan racks suggest locations only.

type PlanAssignment

type PlanAssignment struct {
	OrphanID     uuid.UUID `json:"orphan_id"`
	OrphanName   string    `json:"orphan_name"`
	OrphanKind   string    `json:"orphan_kind"` // "device" or "rack"
	ParentID     uuid.UUID `json:"parent_id"`
	ParentName   string    `json:"parent_name"`
	ParentKind   string    `json:"parent_kind"`             // "rack" or "location"
	RackPosition int       `json:"rack_position,omitempty"` // U-slot for device→rack placement
	Face         string    `json:"face,omitempty"`          // front, rear, or full
}

PlanAssignment records a single parent assignment for an orphan.

type PowerPortSpec

type PowerPortSpec struct {
	Name          string `yaml:"name" json:"name"`
	Type          string `yaml:"type" json:"type"`
	MaximumDraw   int    `yaml:"maximum_draw,omitempty" json:"maximum_draw,omitempty"`
	AllocatedDraw int    `yaml:"allocated_draw,omitempty" json:"allocated_draw,omitempty"`
}

PowerPortSpec defines a power port in a device type.

type PrefixType added in v0.6.1

type PrefixType string

PrefixType classifies a prefix's function within the IP hierarchy.

const (
	PrefixTypeContainer PrefixType = "container"
	PrefixTypeNetwork   PrefixType = "network"
	PrefixTypePool      PrefixType = "pool"
)

type ProviderKeyCheck

type ProviderKeyCheck struct {
	Key   string
	Value any
}

ProviderKeyCheck pairs a metadata key with a value for lookup.

type RelationshipResult

type RelationshipResult struct {
	Fixed    []string
	Warnings []string
	Errors   []error
	Orphans  []OrphanItem
}

RelationshipResult holds the outcome of a relationship verification pass. Fixed lists auto-corrections applied, Warnings lists non-fatal issues, and Errors lists broken references that could not be resolved. Orphans collects items with no parent assigned.

func (*RelationshipResult) HasErrors

func (r *RelationshipResult) HasErrors() bool

HasErrors returns true when unresolvable relationship errors exist.

func (*RelationshipResult) HasOrphans

func (r *RelationshipResult) HasOrphans() bool

HasOrphans returns true when orphaned items were detected.

type ResolvePlan

type ResolvePlan struct {
	Assignments []PlanAssignment `json:"assignments"`
}

ResolvePlan is a list of parent assignments produced by a dry-run. It can be saved to a file, edited, and applied later.

func ReadPlan

func ReadPlan(path string) (*ResolvePlan, error)

ReadPlan loads a plan from a JSON file.

type SlotOccupancy

type SlotOccupancy struct {
	DeviceID uuid.UUID `json:"deviceId" yaml:"DeviceID"`
	Face     string    `json:"face" yaml:"Face"` // "front", "rear", or "full"
}

SlotOccupancy tracks which device occupies a slot at a given face.

type TransformResult

type TransformResult struct {
	Locations   map[uuid.UUID]*CaniLocationType
	Racks       map[uuid.UUID]*CaniRackType
	Devices     map[uuid.UUID]*CaniDeviceType
	Modules     map[uuid.UUID]*CaniModuleType
	Cables      map[uuid.UUID]*CaniCableType
	Frus        map[uuid.UUID]*CaniFruType
	Metadata    *InventoryMetadata
	Prefixes    map[uuid.UUID]*CaniPrefix
	IPAddresses map[uuid.UUID]*CaniIPAddress
	VLANs       map[uuid.UUID]*CaniVLAN
}

TransformResult holds the combined output of the Transform step. Nil maps indicate the provider does not produce that type.

func (*TransformResult) EnsureUniqueDeviceNames

func (tr *TransformResult) EnsureUniqueDeviceNames()

EnsureUniqueDeviceNames detects duplicate names within the transform result and appends an incrementing number to make each name unique. This runs before the result is merged into the inventory so that the provider never introduces collisions.

type Type

type Type string

Type represents a hardware classification type.

const (
	TypeRack           Type = "rack"
	TypeCabinet        Type = "cabinet"
	TypeChassis        Type = "chassis"
	TypeBlade          Type = "blade"
	TypeNode           Type = "node"
	TypeNodeCard       Type = "nodecard"
	TypeSwitch         Type = "switch"
	TypeMgmtSwitch     Type = "mgmt-switch"
	TypeHsnSwitch      Type = "hsn-switch"
	TypeCabinetPDU     Type = "cabinet-pdu"
	TypeCDU            Type = "cdu"
	TypeModule         Type = "module"
	TypeNIC            Type = "nic"
	TypeGPU            Type = "gpu"
	TypeCPU            Type = "cpu"
	TypeMemory         Type = "memory"
	TypePowerSupply    Type = "power-supply"
	TypeCable          Type = "cable"
	TypeFru            Type = "fru"
	TypeCEC            Type = "cec"
	TypeCMM            Type = "cmm"
	TypeNodeController Type = "nodecontroller"
	TypeAdapter        Type = "adapter"
	TypeTransceiver    Type = "transceiver"
)

func AllTypes

func AllTypes() []Type

type TypeEntry

type TypeEntry struct {
	Name       string
	Slug       string
	PartNumber string
	Category   string
	Source     string
}

TypeEntry is a flat representation of any hardware type for listing purposes.

func ListAllAvailableTypes

func ListAllAvailableTypes() []TypeEntry

ListAllAvailableTypes returns a flat list of every registered type across all registries (devices, modules, cables, racks, FRUs).

type UnclassifiedDevice

type UnclassifiedDevice struct {
	ID               uuid.UUID
	Name             string
	DeviceType       string // e.g. node, blade, chassis, nodecard
	Model            string
	Manufacturer     string
	Status           string
	Role             string
	ChildrenCount    int
	ProviderMetadata map[string]any // e.g. csm xname, class, aliases
}

UnclassifiedDevice holds the summary fields of a device that lacks a resolved CaniType.

func FindUnclassifiedDevices

func FindUnclassifiedDevices(inv *Inventory) []UnclassifiedDevice

FindUnclassifiedDevices scans the inventory for devices that have no Slug and no Model (i.e. they cannot be matched to a CaniType). Returns a list of summaries suitable for interactive classification.

Directories

Path Synopsis
* * MIT License * * (C) Copyright 2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software.
* * MIT License * * (C) Copyright 2026 Hewlett Packard Enterprise Development LP * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software.

Jump to

Keyboard shortcuts

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