Source of truth and network automation platform for network infrastructure management.
—
Physical and virtual network infrastructure management including devices, locations, racks, cables, power, and device components. Provides comprehensive modeling of network hardware and connectivity.
Hierarchical organization of physical locations and sites.
class Location:
"""
Physical locations/sites in a hierarchical structure.
Attributes:
name (str): Location name
location_type (LocationType): Type of location
parent (Location): Parent location in hierarchy
description (str): Location description
physical_address (str): Physical address
shipping_address (str): Shipping address
latitude (float): GPS latitude
longitude (float): GPS longitude
contact_name (str): Primary contact name
contact_phone (str): Contact phone number
contact_email (str): Contact email address
"""
class LocationType:
"""
Location type definitions (site, building, floor, room, etc.).
Attributes:
name (str): Type name
description (str): Type description
nestable (bool): Whether locations of this type can be nested
parent (LocationType): Parent type in hierarchy
"""Physical rack organization and space management.
class Rack:
"""
Equipment racks for mounting devices.
Attributes:
name (str): Rack name
location (Location): Rack location
rack_group (RackGroup): Rack group assignment
tenant (Tenant): Tenant assignment
status (Status): Operational status
serial (str): Serial number
asset_tag (str): Asset tag
type (str): Rack type
width (int): Rack width in units
u_height (int): Rack height in units
desc_units (bool): Whether units are numbered descending
outer_width (int): Outer width in millimeters
outer_depth (int): Outer depth in millimeters
outer_unit (str): Unit of measurement
mounting_depth (int): Mounting depth in millimeters
"""
class RackGroup:
"""
Rack grouping for organization.
Attributes:
name (str): Group name
location (Location): Location
parent (RackGroup): Parent group
description (str): Group description
"""
class RackReservation:
"""
Rack space reservations.
Attributes:
rack (Rack): Associated rack
units (list): Reserved rack units
created (datetime): Creation date
user (User): User who created reservation
tenant (Tenant): Tenant assignment
description (str): Reservation description
"""Network device definitions and management.
class Manufacturer:
"""
Hardware manufacturers.
Attributes:
name (str): Manufacturer name
description (str): Manufacturer description
"""
class Platform:
"""
Device platforms/operating systems.
Attributes:
name (str): Platform name
manufacturer (Manufacturer): Associated manufacturer
napalm_driver (str): NAPALM driver name
napalm_args (dict): NAPALM driver arguments
description (str): Platform description
"""
class DeviceFamily:
"""
Device family grouping.
Attributes:
name (str): Family name
description (str): Family description
"""
class DeviceType:
"""
Device type definitions/templates.
Attributes:
model (str): Device model name
manufacturer (Manufacturer): Device manufacturer
device_family (DeviceFamily): Device family
part_number (str): Part number
u_height (int): Height in rack units
is_full_depth (bool): Whether device is full depth
subdevice_role (str): Subdevice role
front_image (ImageField): Front panel image
rear_image (ImageField): Rear panel image
comments (str): Comments
"""
class Device:
"""
Physical network devices.
Attributes:
name (str): Device name
device_type (DeviceType): Device type
device_role (Role): Device role
tenant (Tenant): Tenant assignment
platform (Platform): Device platform
serial (str): Serial number
asset_tag (str): Asset tag
location (Location): Device location
rack (Rack): Rack assignment
position (int): Rack position
face (str): Rack face (front/rear)
status (Status): Operational status
primary_ip4 (IPAddress): Primary IPv4 address
primary_ip6 (IPAddress): Primary IPv6 address
cluster (Cluster): Cluster membership
virtual_chassis (VirtualChassis): Virtual chassis membership
vc_position (int): Virtual chassis position
vc_priority (int): Virtual chassis priority
comments (str): Comments
local_context_data (dict): Local configuration context
"""
class DeviceRedundancyGroup:
"""
Device redundancy groups for high availability.
Attributes:
name (str): Group name
status (Status): Group status
description (str): Group description
comments (str): Comments
"""Controller management for network devices.
class Controller:
"""
Device controllers (wireless controllers, SDN controllers, etc.).
Attributes:
name (str): Controller name
controller_device (Device): Physical controller device
controller_device_redundancy_group (DeviceRedundancyGroup): Redundancy group
role (Role): Controller role
tenant (Tenant): Tenant assignment
platform (Platform): Controller platform
status (Status): Operational status
description (str): Controller description
location (Location): Controller location
"""
class ControllerManagedDeviceGroup:
"""
Groups of devices managed by controllers.
Attributes:
name (str): Group name
controller (Controller): Managing controller
status (Status): Group status
description (str): Group description
weight (int): Group weight/priority
"""Network interfaces and other device components.
class Interface:
"""
Network interfaces on devices.
Attributes:
device (Device): Parent device
name (str): Interface name
label (str): Interface label
type (str): Interface type
enabled (bool): Whether interface is enabled
lag (Interface): Link aggregation group parent
mtu (int): Maximum transmission unit
mac_address (str): MAC address
speed (int): Interface speed in Kbps
duplex (str): Duplex setting
wwn (str): World Wide Name
mgmt_only (bool): Management only interface
description (str): Interface description
mode (str): Interface mode (access/tagged/trunk)
untagged_vlan (VLAN): Untagged VLAN
tagged_vlans (list): Tagged VLANs
vrf (VRF): VRF assignment
ip_addresses (list): Assigned IP addresses
"""
class BaseInterface:
"""Base interface functionality for common interface operations."""
class ConsolePort:
"""
Console ports on devices.
Attributes:
device (Device): Parent device
name (str): Port name
label (str): Port label
type (str): Port type
speed (int): Port speed
description (str): Port description
"""
class ConsoleServerPort:
"""
Console server ports.
Attributes:
device (Device): Parent device
name (str): Port name
label (str): Port label
type (str): Port type
speed (int): Port speed
description (str): Port description
"""
class PowerPort:
"""
Device power ports.
Attributes:
device (Device): Parent device
name (str): Port name
label (str): Port label
type (str): Port type
maximum_draw (int): Maximum power draw in watts
allocated_draw (int): Allocated power draw in watts
description (str): Port description
"""
class PowerOutlet:
"""
Power outlets on devices.
Attributes:
device (Device): Parent device
name (str): Outlet name
label (str): Outlet label
type (str): Outlet type
power_port (PowerPort): Associated power port
feed_leg (str): Power feed leg
description (str): Outlet description
"""
class DeviceBay:
"""
Modular device bays.
Attributes:
device (Device): Parent device
name (str): Bay name
label (str): Bay label
description (str): Bay description
installed_device (Device): Installed child device
"""
class ModuleBay:
"""
Module bays for modular components.
Attributes:
device (Device): Parent device
name (str): Bay name
label (str): Bay label
description (str): Bay description
"""
class FrontPort:
"""
Front panel ports for structured cabling.
Attributes:
device (Device): Parent device
name (str): Port name
label (str): Port label
type (str): Port type
rear_port (RearPort): Associated rear port
rear_port_position (int): Rear port position
description (str): Port description
"""
class RearPort:
"""
Rear panel ports for structured cabling.
Attributes:
device (Device): Parent device
name (str): Port name
label (str): Port label
type (str): Port type
positions (int): Number of positions
description (str): Port description
"""
class InventoryItem:
"""
Inventory item tracking.
Attributes:
device (Device): Parent device
parent (InventoryItem): Parent inventory item
name (str): Item name
label (str): Item label
manufacturer (Manufacturer): Item manufacturer
part_id (str): Part identifier
serial (str): Serial number
asset_tag (str): Asset tag
discovered (bool): Whether item was auto-discovered
description (str): Item description
"""Physical cable management and connection tracking.
class Cable:
"""
Physical cable connections between devices.
Attributes:
termination_a (object): A-side termination
termination_b (object): B-side termination
type (str): Cable type
status (Status): Cable status
tenant (Tenant): Tenant assignment
label (str): Cable label
color (str): Cable color
length (float): Cable length
length_unit (str): Length unit
description (str): Cable description
"""
class CablePath:
"""
Cable path tracking for end-to-end connectivity.
Attributes:
origin (object): Path origin
destination (object): Path destination
path (list): List of cable segments in path
is_active (bool): Whether path is active
is_split (bool): Whether path is split
"""
class CableTermination:
"""
Cable termination points.
Attributes:
cable (Cable): Associated cable
cable_end (str): Cable end (A or B)
termination (object): Termination object
"""
class PathEndpoint:
"""
Path endpoint management for complex topologies.
Attributes:
path (CablePath): Associated cable path
endpoint (object): Endpoint object
"""Virtual chassis and device contexts.
class VirtualChassis:
"""
Virtual chassis stacking.
Attributes:
name (str): Virtual chassis name
domain (str): Chassis domain
master (Device): Master device
description (str): Chassis description
"""
class VirtualDeviceContext:
"""
Multi-context devices (virtual firewalls, routers, etc.).
Attributes:
name (str): Context name
device (Device): Parent device
identifier (int): Context identifier
primary_ip4 (IPAddress): Primary IPv4 address
primary_ip6 (IPAddress): Primary IPv6 address
tenant (Tenant): Tenant assignment
status (Status): Context status
description (str): Context description
comments (str): Comments
"""Software version tracking and management.
class SoftwareVersion:
"""
Software version tracking.
Attributes:
version (str): Software version string
platform (Platform): Associated platform
alias (str): Version alias
release_date (date): Release date
end_of_support_date (date): End of support date
documentation_url (str): Documentation URL
long_term_support (bool): LTS version flag
pre_release (bool): Pre-release version flag
tags (list): Associated tags
"""
class SoftwareImageFile:
"""
Software image files.
Attributes:
software_version (SoftwareVersion): Associated software version
image_file_name (str): Image file name
image_file_checksum (str): File checksum
hashing_algorithm (str): Checksum algorithm
image_file_size (int): File size in bytes
download_url (str): Download URL
default_image (bool): Default image flag
tags (list): Associated tags
"""Power distribution and management.
class PowerPanel:
"""
Electrical panels for power distribution.
Attributes:
name (str): Panel name
location (Location): Panel location
rack_group (RackGroup): Associated rack group
description (str): Panel description
"""
class PowerFeed:
"""
Power feed circuits from panels to racks.
Attributes:
power_panel (PowerPanel): Source power panel
rack (Rack): Destination rack
name (str): Feed name
status (Status): Feed status
type (str): Feed type (primary/redundant)
supply (str): Power supply type
phase (str): Electrical phase
voltage (int): Feed voltage
amperage (int): Feed amperage
max_utilization (int): Maximum utilization percentage
available_power (int): Available power in watts
comments (str): Comments
"""Template definitions for device components.
class ConsolePortTemplate:
"""Console port templates for device types."""
class InterfaceTemplate:
"""Interface templates for device types."""
class PowerPortTemplate:
"""Power port templates for device types."""
class ConsoleServerPortTemplate:
"""Console server port templates for device types."""
class PowerOutletTemplate:
"""Power outlet templates for device types."""
class DeviceBayTemplate:
"""Device bay templates for device types."""
class ModuleBayTemplate:
"""Module bay templates for device types."""
class FrontPortTemplate:
"""Front port templates for device types."""
class RearPortTemplate:
"""Rear port templates for device types."""from nautobot.dcim.models import Device, Location, DeviceType, Manufacturer
from nautobot.extras.models import Status
# Get all active devices
active_status = Status.objects.get(name="Active")
devices = Device.objects.filter(status=active_status)
# Create a new device
location = Location.objects.get(name="DataCenter-1")
device_type = DeviceType.objects.get(model="ASR1001-X")
device = Device.objects.create(
name="router-01",
device_type=device_type,
location=location,
status=active_status
)
# Get devices by location
location_devices = Device.objects.filter(location=location)from nautobot.dcim.models import Interface
# Get all interfaces for a device
interfaces = Interface.objects.filter(device=device)
# Create a new interface
interface = Interface.objects.create(
device=device,
name="GigabitEthernet0/0/0",
type="1000base-t",
enabled=True,
description="WAN Interface"
)
# Get interfaces by type
gigabit_interfaces = Interface.objects.filter(type="1000base-t")from nautobot.dcim.models import Cable, Interface
# Create a cable connection
interface_a = Interface.objects.get(device__name="router-01", name="Gi0/0/0")
interface_b = Interface.objects.get(device__name="switch-01", name="Gi1/0/1")
cable = Cable.objects.create(
termination_a=interface_a,
termination_b=interface_b,
type="cat6",
status=active_status,
label="CAB-001",
length=5.0,
length_unit="m"
)
# Find connected devices
connected_interface = cable.termination_b
connected_device = connected_interface.devicefrom nautobot.dcim.models import Location, LocationType
# Create location hierarchy
region_type = LocationType.objects.get(name="Region")
site_type = LocationType.objects.get(name="Site")
# Create parent location
region = Location.objects.create(
name="North America",
location_type=region_type
)
# Create child location
site = Location.objects.create(
name="New York DC",
location_type=site_type,
parent=region,
physical_address="123 Main St, New York, NY"
)
# Get all child locations
child_locations = Location.objects.filter(parent=region)Install with Tessl CLI
npx tessl i tessl/pypi-nautobot