From f7b620c6a2872dd30f69c38b8fd78af73e6b7d33 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 24 Feb 2020 14:09:36 -0500 Subject: [PATCH] Closes #3145: Add 'decommissioning' status for cables --- docs/release-notes/version-2.7.md | 1 + netbox/dcim/choices.py | 2 ++ netbox/dcim/models/__init__.py | 9 +++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/version-2.7.md b/docs/release-notes/version-2.7.md index 7781e4136..45990bd29 100644 --- a/docs/release-notes/version-2.7.md +++ b/docs/release-notes/version-2.7.md @@ -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 diff --git a/netbox/dcim/choices.py b/netbox/dcim/choices.py index e5b77dbaf..c1d7b4053 100644 --- a/netbox/dcim/choices.py +++ b/netbox/dcim/choices.py @@ -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 = { diff --git a/netbox/dcim/models/__init__.py b/netbox/dcim/models/__init__.py index 5848a6201..d73e5a5b1 100644 --- a/netbox/dcim/models/__init__.py +++ b/netbox/dcim/models/__init__.py @@ -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]