From 227f66715065c91f1ae3cba5a1ae842723bac638 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 2 Apr 2024 13:54:49 -0400 Subject: [PATCH 1/2] Fix IPFabric technology calls to us `all` Previously these were using `fetch`, which does not collect all results. Switching this to use `all` will get all relevant data points. --- changes/413.fixed | 1 + .../integrations/ipfabric/diffsync/adapter_ipfabric.py | 4 ++-- nautobot_ssot/tests/ipfabric/test_ipfabric_adapter.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 changes/413.fixed diff --git a/changes/413.fixed b/changes/413.fixed new file mode 100644 index 000000000..ba2502a7f --- /dev/null +++ b/changes/413.fixed @@ -0,0 +1 @@ +Fixed method of retrieving objects from IPFabric's technology categories. diff --git a/nautobot_ssot/integrations/ipfabric/diffsync/adapter_ipfabric.py b/nautobot_ssot/integrations/ipfabric/diffsync/adapter_ipfabric.py index 192a3f93a..996d93684 100644 --- a/nautobot_ssot/integrations/ipfabric/diffsync/adapter_ipfabric.py +++ b/nautobot_ssot/integrations/ipfabric/diffsync/adapter_ipfabric.py @@ -115,7 +115,7 @@ def load(self): # pylint: disable=too-many-locals,too-many-statements interfaces = self.client.inventory.interfaces.all() vlans = self.client.fetch_all("tables/vlan/site-summary") networks = defaultdict(list) - for network in self.client.technology.managed_networks.networks.fetch( + for network in self.client.technology.managed_networks.networks.all( filters={"net": ["empty", False], "siteName": ["empty", False]}, columns=["net", "siteName"], ): @@ -151,7 +151,7 @@ def load(self): # pylint: disable=too-many-locals,too-many-statements location_devices = [device for device in devices if device["siteName"] == location.name] for device in location_devices: device_name = device["hostname"] - stack_members = self.client.technology.platforms.stacks_members.fetch( + stack_members = self.client.technology.platforms.stacks_members.all( filters={"master": ["eq", device_name], "siteName": ["eq", location.name]}, columns=["master", "member", "memberSn", "pn"], ) diff --git a/nautobot_ssot/tests/ipfabric/test_ipfabric_adapter.py b/nautobot_ssot/tests/ipfabric/test_ipfabric_adapter.py index 7992e2121..28bf30d0d 100644 --- a/nautobot_ssot/tests/ipfabric/test_ipfabric_adapter.py +++ b/nautobot_ssot/tests/ipfabric/test_ipfabric_adapter.py @@ -36,8 +36,8 @@ def setUp(self): side_effect=(lambda x: VLAN_FIXTURE if x == "tables/vlan/site-summary" else "") ) ipfabric_client.inventory.interfaces.all.return_value = INTERFACE_FIXTURE - ipfabric_client.technology.managed_networks.networks.fetch.return_value = NETWORKS_FIXTURE - ipfabric_client.technology.platforms.stacks_members.fetch.side_effect = [[] for site in SITE_FIXTURE[:-1]] + [ + ipfabric_client.technology.managed_networks.networks.all.return_value = NETWORKS_FIXTURE + ipfabric_client.technology.platforms.stacks_members.all.side_effect = [[] for site in SITE_FIXTURE[:-1]] + [ STACKS_FIXTURE ] From 4780efb6e8bb98593d07599f7288f952b179dcc5 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 2 Apr 2024 18:20:15 -0400 Subject: [PATCH 2/2] Fix test case for contrib --- nautobot_ssot/tests/test_contrib_adapter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nautobot_ssot/tests/test_contrib_adapter.py b/nautobot_ssot/tests/test_contrib_adapter.py index 01b96e67d..cf4c7b05a 100644 --- a/nautobot_ssot/tests/test_contrib_adapter.py +++ b/nautobot_ssot/tests/test_contrib_adapter.py @@ -331,6 +331,7 @@ class Adapter(NautobotAdapter): top_level = ["vlan_group"] location_type = dcim_models.LocationType.objects.create(name="Building") + location_type.content_types.add(ContentType.objects.get_for_model(ipam_models.VLAN)) location = dcim_models.Location.objects.create( name="Example Building", location_type=location_type, status=extras_models.Status.objects.get(name="Active") )