mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Fix: incorrect DeviceConnectionsReport in reports.md (#4606)
Since the CONNECTION_STATUS_PLANNED constant is gone from dcim.constants, the DeviceConnectionsReport script is no longer correct. The suggested fix is based on the fact that console_port.connection_status and power_port.connection_status currently have the following set of values: * None = A cable is not connected to a Console Server Port or it's connected to a Rear/Front Port; * False = A cable is connected to a Console Server Port and marked as Planned; * True = A cable is connected to a Console Server Port and marked as Installed.
This commit is contained in:
parent
d5b9722533
commit
cea01e037a
@ -33,7 +33,6 @@ Within each report class, we'll create a number of test methods to execute our r
|
|||||||
|
|
||||||
```
|
```
|
||||||
from dcim.choices import DeviceStatusChoices
|
from dcim.choices import DeviceStatusChoices
|
||||||
from dcim.constants import CONNECTION_STATUS_PLANNED
|
|
||||||
from dcim.models import ConsolePort, Device, PowerPort
|
from dcim.models import ConsolePort, Device, PowerPort
|
||||||
from extras.reports import Report
|
from extras.reports import Report
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ class DeviceConnectionsReport(Report):
|
|||||||
console_port.device,
|
console_port.device,
|
||||||
"No console connection defined for {}".format(console_port.name)
|
"No console connection defined for {}".format(console_port.name)
|
||||||
)
|
)
|
||||||
elif console_port.connection_status == CONNECTION_STATUS_PLANNED:
|
elif not console_port.connection_status:
|
||||||
self.log_warning(
|
self.log_warning(
|
||||||
console_port.device,
|
console_port.device,
|
||||||
"Console connection for {} marked as planned".format(console_port.name)
|
"Console connection for {} marked as planned".format(console_port.name)
|
||||||
@ -67,7 +66,7 @@ class DeviceConnectionsReport(Report):
|
|||||||
for power_port in PowerPort.objects.filter(device=device):
|
for power_port in PowerPort.objects.filter(device=device):
|
||||||
if power_port.connected_endpoint is not None:
|
if power_port.connected_endpoint is not None:
|
||||||
connected_ports += 1
|
connected_ports += 1
|
||||||
if power_port.connection_status == CONNECTION_STATUS_PLANNED:
|
if not power_port.connection_status:
|
||||||
self.log_warning(
|
self.log_warning(
|
||||||
device,
|
device,
|
||||||
"Power connection for {} marked as planned".format(power_port.name)
|
"Power connection for {} marked as planned".format(power_port.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user