Source of truth and network automation platform for network infrastructure management.
npx @tessl/cli install tessl/pypi-nautobot@2.4.0A comprehensive network source of truth and automation platform built as a Django web application. Nautobot serves as a flexible data platform that enables network infrastructure management through customizable data models, REST APIs, GraphQL interfaces, and Git integration. The platform supports an extensible plugin architecture for creating custom network automation applications, provides comprehensive data validation and relationship management, and offers features like webhooks, change logging, and role-based permissions.
pip install nautobotimport nautobotFor Django setup (required before using any models or APIs):
import nautobot
nautobot.setup() # Configure Django with Nautobot settingsFor model imports:
from nautobot.dcim.models import Device, Location, Interface
from nautobot.ipam.models import IPAddress, Prefix, VLAN
from nautobot.extras.models import Tag, Status, RoleFor API usage:
from nautobot.core.api.serializers import NautobotModelSerializer
from nautobot.dcim.api.views import DeviceViewSetimport nautobot
nautobot.setup()
# Working with devices
from nautobot.dcim.models import Device, Location, DeviceType
# Get all devices
devices = Device.objects.all()
# Get devices at a specific location
location = Location.objects.get(name="Datacenter-1")
location_devices = Device.objects.filter(location=location)
# Create a new device
from nautobot.extras.models import Status
active_status = Status.objects.get(name="Active")
device = Device.objects.create(
name="router-01",
device_type=DeviceType.objects.get(model="ASR1001-X"),
location=location,
status=active_status
)
# Working with IP addresses
from nautobot.ipam.models import IPAddress, Namespace
# Create an IP address
namespace = Namespace.objects.get(name="Global")
ip = IPAddress.objects.create(
address="192.168.1.1/24",
namespace=namespace,
status=active_status
)
# Assign IP to device interface
from nautobot.dcim.models import Interface
interface = Interface.objects.get(device=device, name="GigabitEthernet0/0/0")
ip.assigned_object = interface
ip.save()Nautobot follows a modular Django architecture with several key components:
The plugin system enables third-party developers to extend Nautobot with custom models, APIs, views, and automation logic while maintaining compatibility with the core platform.
Core functionality including Django setup, base models, API infrastructure, form handling, job system, and plugin architecture. Provides the foundation for all other modules.
def setup(config_path=None):
"""Configure Django with Nautobot settings."""
class BaseModel:
"""Abstract base model with UUID primary key, natural keys, and validation."""
class NautobotModelSerializer:
"""Main model serializer for API operations."""
class NautobotAppConfig:
"""Base app configuration class for plugins."""Physical and virtual network infrastructure management including devices, locations, racks, cables, power, and device components. Provides comprehensive modeling of network hardware and connectivity.
class Device:
"""Physical network devices."""
class Location:
"""Physical locations/sites."""
class Interface:
"""Network interfaces on devices."""
class Cable:
"""Physical cable connections."""Device and Infrastructure Management
IP address space management including prefixes, IP addresses, VLANs, VRFs, namespaces, and routing. Supports hierarchical IP space organization and VLAN management.
class IPAddress:
"""Individual IP addresses."""
class Prefix:
"""IP prefixes/networks."""
class VLAN:
"""Virtual LANs."""
class VRF:
"""Virtual routing and forwarding instances."""Advanced features including custom fields, relationships, jobs, webhooks, templates, secrets management, and configuration contexts. Enables customization and automation workflows.
class Job:
"""Background job definitions."""
class CustomField:
"""Runtime-configurable custom fields."""
class Relationship:
"""Custom object relationships."""
class Webhook:
"""Webhook integrations."""Service provider circuit management including circuits, providers, and circuit terminations. Manages external network connectivity and carrier services.
class Circuit:
"""Service provider circuits."""
class Provider:
"""Service providers."""
class CircuitTermination:
"""Circuit endpoints."""Multi-tenancy support and user management including tenants, groups, permissions, and authentication. Provides role-based access control and organizational separation.
class Tenant:
"""Tenant objects for multi-tenancy."""
class User:
"""Extended user model."""
class ObjectPermission:
"""Object-level permissions."""Virtual infrastructure management including virtual machines, cloud services, and wireless networks. Extends the DCIM model to virtual and cloud environments.
class VirtualMachine:
"""Virtual machines."""
class VMInterface:
"""Virtual machine interfaces."""# Install Nautobot
pip install nautobot
# Basic setup in your application
import nautobot
nautobot.setup() # Must be called before using models or APIs
# Access the version
print(nautobot.__version__) # "2.4.17"Nautobot requires Django configuration. The setup() function handles this automatically:
import nautobot
# Use default configuration path
nautobot.setup()
# Or specify custom configuration
nautobot.setup(config_path="/path/to/nautobot_config.py")Model Access:
from nautobot.dcim.models import Device
devices = Device.objects.filter(status__name="Active")API Usage:
from nautobot.dcim.api.serializers import DeviceSerializer
from nautobot.dcim.models import Device
device = Device.objects.first()
serializer = DeviceSerializer(device)
data = serializer.dataCustom Fields:
from nautobot.extras.models import CustomField
custom_field = CustomField.objects.create(
type="text",
name="asset_tag",
label="Asset Tag"
)Job Creation:
from nautobot.extras.jobs import Job
class MyCustomJob(Job):
class Meta:
name = "My Custom Job"
description = "Custom automation job"
def run(self):
# Job logic here
pass