This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from extras.reports import Report | |
from dcim.models import Device | |
from virtualization.models import VirtualMachine | |
from ipam.constants import * | |
from ipam.models import IPAddress, Prefix | |
LOOPBACK_ROLES = [ | |
IPADDRESS_ROLE_LOOPBACK, | |
IPADDRESS_ROLE_ANYCAST, | |
IPADDRESS_ROLE_VIP, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ telnet 192.168.2.1 | |
Trying 192.168.2.1... | |
Connected to 192.168.2.1. | |
Escape character is '^]'. | |
Account:admin | |
Password: ******** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install as reports/missing-device-ports.py | |
# Run as: python3 manage.py runreport missing-device-ports | |
from extras.reports import Report | |
from dcim.models import Device | |
class MissingDevicePorts(Report): | |
description = "Find devices which are missing ports that are in the device type template" | |
def test_add_ports(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import django | |
import os | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'netbox.settings') | |
django.setup() | |
from dcim.models import Device, ConsolePort, ConsoleServerPort, PowerPort, PowerOutlet, Interface, RearPort, FrontPort, DeviceBay | |
for device in Device.objects.all(): | |
# Based on Device.save() | |
ConsolePort.objects.bulk_create( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/netbox/venv/bin/python | |
import django | |
import os | |
import sys | |
sys.path.append('/opt/netbox/netbox') | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'netbox.settings') | |
django.setup() | |
from dcim.models import Device, ConsolePort, ConsoleServerPort, PowerPort, PowerOutlet, Interface, RearPort, FrontPort, DeviceBay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install as reports/missing-device-ports.py | |
# Run as: python3 manage.py runreport missing-device-ports | |
from extras.reports import Report | |
from dcim.models import Device | |
class MissingDevicePorts(Report): | |
description = "Find devices which are missing ports that are in the device type template" | |
def test_add_ports(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import unittest | |
def parse_natural(name): | |
res = re.split("(\d+)", name) | |
# first and last element is always a string; alternate values are numbers | |
for i in range(1, len(res), 2): | |
res[i] = int(res[i]) | |
return res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import unittest | |
def parse_natural(name, line_card_first=False): | |
res = re.split("(\d+)", name) | |
if line_card_first and len(res) > 3: | |
res = ["", res[1]] + res | |
# first and last element is always a string; alternate values are numbers | |
for i in range(1, len(res), 2): | |
res[i] = int(res[i]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
host="$1" | |
REALM="LOCAL.EXAMPLE.NET" | |
LCREALM="local.example.net" | |
TESTUSER="nagiostest" | |
BASENAME="cn=users,dc=local,dc=example,dc=net" | |
if [ "$host" = "" ]; then | |
echo "Missing hostname" | |
exit 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from extras.reports import Report | |
from dcim.models import Cable, RearPort | |
from dcim.constants import * | |
from circuits.models import CircuitTermination | |
CABLE_TYPES_OK_BETWEEN_RACKS = { | |
CABLE_TYPE_DAC_PASSIVE, | |
} | |
class CheckCableLocality(Report): |