Skip to content

Commit

Permalink
Change name per PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcgill298 committed Dec 22, 2023
1 parent 64fb226 commit 4b0d3ac
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/admin/integrations/ipfabric_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PLUGINS_CONFIG = {
| `ipfabric_safe_delete_location_status` | The status that is set for a Location when the `Safe Delete Mode` flag is set in the Job. | `Decommissioning` |
| `ipfabric_safe_delete_vlan_status` | The status that is set for a VLAN when the `Safe Delete Mode` flag is set in the Job. | `Deprecated` |
| `ipfabric_safe_delete_ipaddress_status` | The status that is set for an IP Address when the `Safe Delete Mode` flag is set in the Job. | `Deprecated` |
| `ipfabric_elongate_interface_name` | Whether to attempt to elongate interface names as found in IP Fabric. | `False` |
| `ipfabric_use_canononical_interface_name` | Whether to attempt to elongate interface names as found in IP Fabric. | `False` |


Below is an example snippet from `nautobot_config.py` that demonstrates how to enable and configure the IPFabric SSoT integration along with the optional settings:
Expand All @@ -81,7 +81,7 @@ PLUGINS_CONFIG = {
"ipfabric_safe_delete_location_status": os.environ.get("NAUTOBOT_SSOT_IPFABRIC_LOCATION_DELETE_STATUS"),
"ipfabric_safe_delete_vlan_status": os.environ.get("NAUTOBOT_SSOT_IPFABRIC_VLAN_DELETE_STATUS"),
"ipfabric_safe_delete_ipaddress_status": os.environ.get("NAUTOBOT_SSOT_IPFABRIC_IPADDRESS_DELETE_STATUS"),
"ipfabric_elongate_interface_name": True,
"ipfabric_use_canononical_interface_name": True,
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion nautobot_ssot/integrations/ipfabric/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SAFE_DELETE_VLAN_STATUS = CONFIG.get("ipfabric_safe_delete_vlan_status", "Deprecated")
SAFE_DELETE_IPADDRESS_STATUS = CONFIG.get("ipfabric_safe_delete_ipaddress_status", "Deprecated")
LAST_SYNCHRONIZED_CF_NAME = "last_synced_from_sor"
IP_FABRIC_ELONGATE_INTERFACE_NAME = CONFIG.get("ipfabric_elongate_interface_name", False)
IP_FABRIC_USE_CANONONICAL_INTERFACE_NAME = CONFIG.get("ipfabric_use_canononical_interface_name", False)
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from nautobot.dcim.models import Device
from nautobot.ipam.models import VLAN
from netutils.mac import mac_to_format
from netutils.interface import canonical_interface_name as netutils_elongate_interface_name
from netutils.interface import canonical_interface_name

from nautobot_ssot.integrations.ipfabric.constants import (
DEFAULT_INTERFACE_TYPE,
DEFAULT_INTERFACE_MTU,
DEFAULT_INTERFACE_MAC,
DEFAULT_DEVICE_ROLE,
DEFAULT_DEVICE_STATUS,
IP_FABRIC_ELONGATE_INTERFACE_NAME,
IP_FABRIC_USE_CANONONICAL_INTERFACE_NAME,
)
from nautobot_ssot.integrations.ipfabric.diffsync import DiffSyncModelAdapters

Expand Down Expand Up @@ -57,8 +57,8 @@ def load_device_interfaces(self, device_model, interfaces, device_primary_ip):
for iface in device_interfaces:
ip_address = iface.get("primaryIp")
iface_name = iface["intName"]
if IP_FABRIC_ELONGATE_INTERFACE_NAME:
iface_name = netutils_elongate_interface_name(iface_name)
if IP_FABRIC_USE_CANONONICAL_INTERFACE_NAME:
iface_name = canonical_interface_name(iface_name)
try:
interface = self.interface(
diffsync=self,
Expand Down
6 changes: 3 additions & 3 deletions nautobot_ssot/management/commands/elongate_interface_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from nautobot.dcim.models import Device

from netutils.interface import canonical_interface_name as netutils_elongate_interface_name
from netutils.interface import canonical_interface_name


class Command(BaseCommand):
Expand Down Expand Up @@ -40,11 +40,11 @@ def handle(self, *args, **options): # noqa: D102
devices = Device.objects.all()
for device in devices:
for interface in device.interfaces.all():
new_name = netutils_elongate_interface_name(interface.name)
new_name = canonical_interface_name(interface.name)
if interface.name != new_name:
self.stdout.write(
self.style.WARNING(f"Updating {device.name}.{interface.name} >> ")
+ self.style.SUCCESS(f"{new_name}")
)
interface.name = netutils_elongate_interface_name(new_name)
interface.name = canonical_interface_name(new_name)
interface.validated_save()
4 changes: 3 additions & 1 deletion nautobot_ssot/tests/ipfabric/test_ipfabric_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def test_data_loading(self):
self.assertTrue(hasattr(interface, "subnet_mask"))
self.assertTrue(hasattr(interface, "type"))

@patch("nautobot_ssot.integrations.ipfabric.diffsync.adapter_ipfabric.IP_FABRIC_ELONGATE_INTERFACE_NAME", True)
@patch(
"nautobot_ssot.integrations.ipfabric.diffsync.adapter_ipfabric.IP_FABRIC_USE_CANONONICAL_INTERFACE_NAME", True
)
def test_data_loading_elongate_interface_names(self):
"""Test the load() function with using long form interface names."""

Expand Down

0 comments on commit 4b0d3ac

Please sign in to comment.