1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #3145: Add 'decommissioning' status for cables

This commit is contained in:
Jeremy Stretch
2020-02-24 14:09:36 -05:00
parent 76138f3080
commit f7b620c6a2
3 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@
## Enhancements
* [#3145](https://github.com/netbox-community/netbox/issues/3145) - Add a "decommissioning" cable status
* [#4173](https://github.com/netbox-community/netbox/issues/4173) - Return graceful error message when webhook queuing fails
## Bug Fixes

View File

@ -973,10 +973,12 @@ class CableStatusChoices(ChoiceSet):
STATUS_CONNECTED = 'connected'
STATUS_PLANNED = 'planned'
STATUS_DECOMMISSIONING = 'decommissioning'
CHOICES = (
(STATUS_CONNECTED, 'Connected'),
(STATUS_PLANNED, 'Planned'),
(STATUS_DECOMMISSIONING, 'Decommissioning'),
)
LEGACY_MAP = {

View File

@ -1956,6 +1956,7 @@ class Cable(ChangeLoggedModel):
STATUS_CLASS_MAP = {
CableStatusChoices.STATUS_CONNECTED: 'success',
CableStatusChoices.STATUS_PLANNED: 'info',
CableStatusChoices.STATUS_DECOMMISSIONING: 'warning',
}
class Meta:
@ -2116,14 +2117,14 @@ class Cable(ChangeLoggedModel):
b_path = self.termination_a.trace()
# Determine overall path status (connected or planned)
if self.status == CableStatusChoices.STATUS_PLANNED:
path_status = CONNECTION_STATUS_PLANNED
else:
if self.status == CableStatusChoices.STATUS_CONNECTED:
path_status = CONNECTION_STATUS_CONNECTED
for segment in a_path[1:] + b_path[1:]:
if segment[1] is None or segment[1].status == CableStatusChoices.STATUS_PLANNED:
if segment[1] is None or segment[1].status != CableStatusChoices.STATUS_CONNECTED:
path_status = CONNECTION_STATUS_PLANNED
break
else:
path_status = CONNECTION_STATUS_PLANNED
a_endpoint = a_path[-1][2]
b_endpoint = b_path[-1][2]