Skip to content

Commit

Permalink
do not include tags in enabling/disabling device
Browse files Browse the repository at this point in the history
Signed-off-by: kimpaller <[email protected]>
  • Loading branch information
kimpaller committed Oct 23, 2024
1 parent eb08c5e commit 8af9e71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions nebula/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,15 +562,16 @@ def to_config(self, template): # noqa: C901
def enable(self, reason="nebula: Enable device"):
device_id = self.data["devices"]["id"]
author = self.nbi.get_user_from_token()
self.nbi.add_tag(device_id=device_id, tag="active")
self.nbi.update_status(device_id=device_id, status="active")
self.nbi.log_journal(device_id=device_id, author_id=author.id, comments=reason)

def disable(self, reason="nebula: Disable device"):
def disable(self, reason="nebula: Disable device", failed=False):
device_id = self.data["devices"]["id"]
author = self.nbi.get_user_from_token()
self.nbi.remove_tag(device_id=device_id, tag="active")
self.nbi.update_status(device_id=device_id, status="offline")
if failed:
self.nbi.update_status(device_id=device_id, status="failed")
else:
self.nbi.update_status(device_id=device_id, status="offline")
self.nbi.log_journal(device_id=device_id, author_id=author.id, comments=reason)


Expand Down
8 changes: 5 additions & 3 deletions nebula/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ def check_board_booted(
@task(
help={
"reason": "Reason why board will be disabled",
"failure": "Set to true to set device status to Failure rather than Offline",
"netbox_ip": "IP address of netbox instance",
"netbox_port": "Network port of netbox instance",
"netbox_token": "Netbox access token",
Expand All @@ -1439,6 +1440,7 @@ def check_board_booted(
def disable_board(
c,
reason,
failure=False,
netbox_ip=None,
netbox_port=None,
netbox_token=None,
Expand All @@ -1447,7 +1449,7 @@ def disable_board(
board_name=None,
load_config=True,
):
"""Remove Active Tag, change status to offline and log reason to journal"""
"""Change status to offline and log reason to journal"""
nb = nebula.netbox(
ip=netbox_ip,
port=netbox_port,
Expand All @@ -1458,7 +1460,7 @@ def disable_board(
load_config=load_config,
)
device = nebula.NetboxDevice(nb)
device.disable(reason)
device.disable(reason, failure)


@task(
Expand All @@ -1484,7 +1486,7 @@ def enable_board(
board_name=None,
load_config=True,
):
"""Add Active Tag, change status to active and log reason to journal"""
"""Change status to active and log reason to journal"""
nb = nebula.netbox(
ip=netbox_ip,
port=netbox_port,
Expand Down

0 comments on commit 8af9e71

Please sign in to comment.