Nautobot Network Automation Platform

3.1.0 · active · verified Thu Apr 16

Nautobot is an open source network source of truth and automation platform built on Django. It provides a highly extensible data model for network inventory, IP address management (IPAM), and device configuration, alongside a powerful framework for custom automation jobs and plugins. The current version is 3.1.0, with frequent patch releases across major versions (2.x, 3.x) and a new major version released approximately every 6-12 months.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates defining a basic Nautobot Job, a common way to extend Nautobot's functionality using Python. The `Job` class provides methods for interacting with Nautobot models and logging. This code is designed to be saved within a Nautobot job directory and executed via the Nautobot UI or `nautobot-server runjob` command, making use of the library's internal context.

from nautobot.dcim.models import Device
from nautobot.extras.jobs import Job

# Example: A simple job to list devices
class MyFirstJob(Job):
    name = "My First Nautobot Job"
    description = "A simple job to list devices and log their names."
    task_queue = "default"

    def run(self, data, commit):
        self.log_info(message="Starting MyFirstJob...")
        devices = Device.objects.all()
        self.log_info(f"Found {devices.count()} devices in the database.")
        for device in devices:
            self.log_info(f"- Device: {device.name}, Status: {device.status}")
        self.log_success("Job completed successfully!")
        return "Success"

# To make this job available in Nautobot:
# 1. Save this code as 'my_job.py' (or similar) in a directory configured for Nautobot jobs.
# 2. In the Nautobot UI, navigate to Jobs, find 'My First Nautobot Job', and click 'Run'.
# This quickstart demonstrates how to define a Job that interacts with Nautobot models
# and is executed by the Nautobot platform.

view raw JSON →