Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/461.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed interface link status mapping in Cisco to only report "admin down" as not Enabled
2 changes: 1 addition & 1 deletion nautobot_device_onboarding/command_mappers/cisco_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ sync_network_data:
- command: "show interfaces"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].link_status"
post_processor: "{{ obj[0] | interface_status_to_bool }}"
post_processor: "{{ obj[0] | cisco_interface_status_to_bool }}"
interfaces__802.1Q_mode:
commands:
- command: "show interfaces switchport"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sync_network_data:
- command: "show interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].link_status"
post_processor: "{{ obj[0] | interface_status_to_bool }}"
post_processor: "{{ obj[0] | cisco_interface_status_to_bool }}"
interfaces__802.1Q_mode:
commands:
- command: "show interface switchport"
Expand Down
12 changes: 12 additions & 0 deletions nautobot_device_onboarding/jinja_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ def interface_status_to_bool(status):
return "up" in status.lower()


@library.filter
def cisco_interface_status_to_bool(status):
"""
Take links or admin status and change to boolean.

administratively down -> False
down -> True
up -> True
"""
return "admin" not in status.lower()


@library.filter
def nxos_switchport_mode_to_nautobot_interface_mode(interface_object):
"""Convert the switchport mode from the "show interface switchport" command output to a Nautobot interface mode."""
Expand Down
13 changes: 13 additions & 0 deletions nautobot_device_onboarding/tests/test_jinja_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from nautobot.apps.choices import InterfaceModeChoices

from nautobot_device_onboarding.jinja_filters import (
cisco_interface_status_to_bool,
extract_prefix,
flatten_dict_from_value,
flatten_list_of_dict_from_value,
Expand Down Expand Up @@ -60,6 +61,18 @@ def test_interface_status_to_bool_up_upper(self):
"""Take links or admin status and change to boolean."""
self.assertTrue(interface_status_to_bool("UP"))

def test_cisco_interface_status_to_bool_linkdown(self):
"""Take links or admin status and change to boolean."""
self.assertTrue(cisco_interface_status_to_bool("down"))

def test_cisco_interface_status_to_bool_admindown(self):
"""Take links or admin status and change to boolean."""
self.assertFalse(cisco_interface_status_to_bool("administratively down"))

def test_cisco_interface_status_to_bool_linkup(self):
"""Take links or admin status and change to boolean."""
self.assertFalse(cisco_interface_status_to_bool("up"))

def test_nxos_switchport_mode_to_nautobot_interface_mode(self):
"""Convert the switchport mode from the "show interface switchport" command output to a Nautobot interface mode."""
subtests = {
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def ruff(context, action=None, target=None, fix=False, output_format="concise"):
if "format" in action:
command = "ruff format "
if not fix:
command += "--check "
command += "--check --diff "
command += " ".join(target)
if not run_command(context, command, warn=True):
exit_code = 1
Expand Down
Loading