Verified Commit 6a6747fb authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files

device: Add report for device uplink connections

Signed-off-by: Adrian Schollmeyer's avatarAdrian 'nex' Schollmeyer <>
parent d2a355c1
......@@ -7,3 +7,5 @@ The format is based on [Keep a Changelog](
### Added
* `` report
* ArubaApNetworkIntegration (ensure valid network configuration and uplink connection)
* `` report
* DeviceUplinkConnection (ensure valid uplink connection for regular devices)
from circuits.models import *
from dcim.choices import DeviceStatusChoices
from dcim.models import *
from ipam.models import *
from extras.reports import Report
class DeviceUplinkConnection(Report):
description = "Validate that every device has a valid uplink connection"
def test_uplink_has_cable(self):
for device in Device.objects.all():
device_role =
if device_role == "Access Switch" or \
device_role == "Core Switch" or \
device_role == "External":
has_uplink_cable = False
interfaces = Interface.objects.filter(device = device)
if len(interfaces) == 0:
for interface in interfaces:
if interface.connected_endpoint is None:
if isinstance(interface.connected_endpoint,
self.log_info(device, "Uplink is a circuit!")
has_uplink_cable = True
endpoint_role = \
if endpoint_role == "Access Switch" or \
endpoint_role == "Core Switch":
has_uplink_cable = True
if has_uplink_cable:
elif device.status == DeviceStatusChoices.STATUS_ACTIVE:
self.log_failure(device, "Missing uplink cable")
elif device.status == DeviceStatusChoices.STATUS_PLANNED:
self.log_info(device, "Missing uplink, but device is planned")
"Missing uplink cable, but device is not active")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment