Skip to content

Commit 1ecf485

Browse files
author
ibeljakov
committed
Fixed devices.py.example report
1 parent 5cb8e97 commit 1ecf485

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

reports/devices.py.example

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dcim.constants import CONNECTION_STATUS_PLANNED, DEVICE_STATUS_ACTIVE
1+
from dcim.choices import DeviceStatusChoices
22
from dcim.models import ConsolePort, Device, PowerPort
33
from extras.reports import Report
44

@@ -9,13 +9,14 @@ class DeviceConnectionsReport(Report):
99
def test_console_connection(self):
1010

1111
# Check that every console port for every active device has a connection defined.
12-
for console_port in ConsolePort.objects.select_related('device').filter(device__status=DEVICE_STATUS_ACTIVE):
12+
active = DeviceStatusChoices.STATUS_ACTIVE
13+
for console_port in ConsolePort.objects.prefetch_related('device').filter(device__status=active):
1314
if console_port.connected_endpoint is None:
1415
self.log_failure(
1516
console_port.device,
1617
"No console connection defined for {}".format(console_port.name)
1718
)
18-
elif console_port.connection_status == CONNECTION_STATUS_PLANNED:
19+
elif not console_port.connection_status:
1920
self.log_warning(
2021
console_port.device,
2122
"Console connection for {} marked as planned".format(console_port.name)
@@ -26,12 +27,12 @@ class DeviceConnectionsReport(Report):
2627
def test_power_connections(self):
2728

2829
# Check that every active device has at least two connected power supplies.
29-
for device in Device.objects.filter(status=DEVICE_STATUS_ACTIVE):
30+
for device in Device.objects.filter(status=DeviceStatusChoices.STATUS_ACTIVE):
3031
connected_ports = 0
3132
for power_port in PowerPort.objects.filter(device=device):
3233
if power_port.connected_endpoint is not None:
3334
connected_ports += 1
34-
if power_port.connection_status == CONNECTION_STATUS_PLANNED:
35+
if not power_port.connection_status:
3536
self.log_warning(
3637
device,
3738
"Power connection for {} marked as planned".format(power_port.name)
@@ -43,4 +44,3 @@ class DeviceConnectionsReport(Report):
4344
)
4445
else:
4546
self.log_success(device)
46-

0 commit comments

Comments
 (0)