Repository: nautobot/nautobot-plugin-ssot-infoblox (language: python)

Issue:
Remove custom business logic for dns_name that doesn't have a valid TLD.
Removing backup dump as well.


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 41b4084..f9c5e09 100644
--- a/README.md
+++ b/README.md
@@ -63,23 +63,23 @@ Below are the data mappings between objects within Infoblox and the correspondin
 | ----------------- | -------------- |
 | Network           | Prefix         |
 | IP Address        | IP Address     |
-| ~~Vlan~~          | ~~VLAN~~       |
-| ~~Vlan view~~     | ~~VLAN Group~~ |
+| VLAN              | VLAN           |
+| VLAN view         | VLAN Group     |
 | Network container | Aggregate      |
 
 > **_NOTE_**: VLAN and VLAN Group will be turned on within the next available releases.
 
 ### DiffSyncModel - Network
 
-![Diffsync Model - Network](./diffsyncmodel-network.png)
+![Diffsync Model - Network](./docs/static/diffsyncmodel-network.png)
 
 ### DiffSyncModel - IPAddress
 
-![Diffsync Model - IPAddress](./diffsyncmodel-ipaddress.png)
+![Diffsync Model - IPAddress](./docs/static/diffsyncmodel-ipaddress.png)
 
 ### DiffSyncModel - Aggregate
 
-![Diffsync Model - Aggregate](./diffsyncmodel-aggregate.png)
+![Diffsync Model - Aggregate](./docs/static/diffsyncmodel-aggregate.png)
 
 ## Contributing
 
@@ -102,12 +102,12 @@ Below is a quick start guide if you're already familiar with the development env
 
 The [PyInvoke](http://www.pyinvoke.org/) library is used to provide some helper commands based on the environment.  There are a few configuration parameters which can be passed to PyInvoke to override the default configuration:
 
-* `nautobot_ver`: the version of Nautobot to use as a base for any built docker containers (default: 1.1.4)
-* `project_name`: the default docker compose project name (default: nautobot_ssot_infoblox)
-* `python_ver`: the version of Python to use as a base for any built docker containers (default: 3.6)
-* `local`: a boolean flag indicating if invoke tasks should be run on the host or inside the docker containers (default: False, commands will be run in docker containers)
-* `compose_dir`: the full path to a directory containing the project compose files
-* `compose_files`: a list of compose files applied in order (see [Multiple Compose files](https://docs.docker.com/compose/extends/#multiple-compose-files) for more information)
+- `nautobot_ver`: the version of Nautobot to use as a base for any built docker containers (default: 1.1.4)
+- `project_name`: the default docker compose project name (default: nautobot_ssot_infoblox)
+- `python_ver`: the version of Python to use as a base for any built docker containers (default: 3.6)
+- `local`: a boolean flag indicating if invoke tasks should be run on the host or inside the docker containers (default: False, commands will be run in docker containers)
+- `compose_dir`: the full path to a directory containing the project compose files
+- `compose_files`: a list of compose files applied in order (see [Multiple Compose files](https://docs.docker.com/compose/extends/#multiple-compose-files) for more information)
 
 Using **PyInvoke** these configuration options can be overridden using [several methods](http://docs.pyinvoke.org/en/stable/concepts/configuration.html).  Perhaps the simplest is simply setting an environment variable `INVOKE_NAUTOBOT_SSOT_INFOBLOX_VARIABLE_NAME` where `VARIABLE_NAME` is the variable you are trying to override.  The only exception is `compose_files`, because it is a list it must be overridden in a yaml file.  There is an example `invoke.yml` (`invoke.example.yml`) in this directory which can be used as a starting point.
 
@@ -220,6 +220,6 @@ Sign up [here](http://slack.networktocode.com/)
 
 ## Screenshots
 
-![Infoblox SSoT Status](./ssot-status.png)
+![Infoblox SSoT Status](./docs/static/ssot-status.png)
 
-![Infoblox SSoT Logs](./ssot-logs.png)
+![Infoblox SSoT Logs](./docs/static/ssot-logs.png)
diff --git a/diffsyncmodel-aggregate.png b/docs/static/diffsyncmodel-aggregate.png
similarity index 100%
rename from diffsyncmodel-aggregate.png
rename to docs/static/diffsyncmodel-aggregate.png
diff --git a/diffsyncmodel-ipaddress.png b/docs/static/diffsyncmodel-ipaddress.png
similarity index 100%
rename from diffsyncmodel-ipaddress.png
rename to docs/static/diffsyncmodel-ipaddress.png
diff --git a/diffsyncmodel-network.png b/docs/static/diffsyncmodel-network.png
similarity index 100%
rename from diffsyncmodel-network.png
rename to docs/static/diffsyncmodel-network.png
diff --git a/ssot-logs.png b/docs/static/ssot-logs.png
similarity index 100%
rename from ssot-logs.png
rename to docs/static/ssot-logs.png
diff --git a/ssot-status.png b/docs/static/ssot-status.png
similarity index 100%
rename from ssot-status.png
rename to docs/static/ssot-status.png
diff --git a/nautobot_ssot_infoblox/diffsync/adapters/infoblox.py b/nautobot_ssot_infoblox/diffsync/adapters/infoblox.py
index 749d167..bf0e248 100644
--- a/nautobot_ssot_infoblox/diffsync/adapters/infoblox.py
+++ b/nautobot_ssot_infoblox/diffsync/adapters/infoblox.py
@@ -5,7 +5,7 @@
 from diffsync import DiffSync
 from diffsync.enum import DiffSyncFlags
 from nautobot.extras.plugins.exceptions import PluginImproperlyConfigured
-from nautobot_ssot_infoblox.diffsync.client import InfobloxApi
+from nautobot_ssot_infoblox.utils.client import InfobloxApi
 from nautobot_ssot_infoblox.diffsync.models.infoblox import (
     InfobloxAggregate,
     InfobloxIPAddress,
diff --git a/nautobot_ssot_infoblox/diffsync/adapters/nautobot.py b/nautobot_ssot_infoblox/diffsync/adapters/nautobot.py
index 10864b8..cb51f9e 100644
--- a/nautobot_ssot_infoblox/diffsync/adapters/nautobot.py
+++ b/nautobot_ssot_infoblox/diffsync/adapters/nautobot.py
@@ -15,7 +15,7 @@
     NautobotVlan,
 )
 from nautobot_ssot_infoblox.constant import TAG_COLOR
-from nautobot_ssot_infoblox.utils import nautobot_vlan_status
+from nautobot_ssot_infoblox.utils.diffsync import nautobot_vlan_status
 
 
 class NautobotMixin:
diff --git a/nautobot_ssot_infoblox/diffsync/models/nautobot.py b/nautobot_ssot_infoblox/diffsync/models/nautobot.py
index 847dd36..a639bbd 100644
--- a/nautobot_ssot_infoblox/diffsync/models/nautobot.py
+++ b/nautobot_ssot_infoblox/diffsync/models/nautobot.py
@@ -8,7 +8,7 @@
 from nautobot.ipam.models import VLAN as OrmVlan
 from nautobot.ipam.models import VLANGroup as OrmVlanGroup
 from nautobot_ssot_infoblox.diffsync.models.base import Aggregate, Network, IPAddress, Vlan, VlanView
-from nautobot_ssot_infoblox.diffsync.utilities import create_tag_sync_from_infoblox
+from nautobot_ssot_infoblox.utils.diffsync import create_tag_sync_from_infoblox
 
 
 class NautobotNetwork(Network):
diff --git a/nautobot_ssot_infoblox/diffsync/utilities.py b/nautobot_ssot_infoblox/diffsync/utilities.py
deleted file mode 100644
index 0f582e2..0000000
--- a/nautobot_ssot_infoblox/diffsync/utilities.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""Utilities for diffsync related stuff."""
-
-from nautobot.extras.models import Tag
-from nautobot_ssot_infoblox.constant import TAG_COLOR
-
-
-def create_tag_sync_from_infoblox():
-    """Create tag for tagging objects that have been created by Infoblox."""
-    tag, _ = Tag.objects.get_or_create(
-        slug="ssot-synced-from-infoblox",
-        defaults={
-            "name": "SSoT Synced from Infoblox",
-            "description": "Object synced at some point from Infoblox",
-            "color": TAG_COLOR,
-        },
-    )
-    return tag
diff --git a/nautobot_ssot_infoblox/jobs.py b/nautobot_ssot_infoblox/jobs.py
index 29e911e..24f4818 100644
--- a/nautobot_ssot_infoblox/jobs.py
+++ b/nautobot_ssot_infoblox/jobs.py
@@ -7,7 +7,7 @@
 
 from diffsync import DiffSyncFlags
 from nautobot_ssot_infoblox.diffsync.adapters import infoblox, nautobot
-from nautobot_ssot_infoblox.diffsync.client import InfobloxApi
+from nautobot_ssot_infoblox.utils.client import InfobloxApi
 from nautobot_ssot_infoblox.constant import PLUGIN_CFG
 
 
diff --git a/nautobot_ssot_infoblox/utils/__init__.py b/nautobot_ssot_infoblox/utils/__init__.py
new file mode 100644
index 0000000..efafc00
--- /dev/null
+++ b/nautobot_ssot_infoblox/utils/__init__.py
@@ -0,0 +1,1 @@
+"""Utility functions for working with Infoblox and Nautobot."""
diff --git a/nautobot_ssot_infoblox/diffsync/client.py b/nautobot_ssot_infoblox/utils/client.py
similarity index 97%
rename from nautobot_ssot_infoblox/diffsync/client.py
rename to nautobot_ssot_infoblox/utils/client.py
index e0052b8..afdd993 100644
--- a/nautobot_ssot_infoblox/diffsync/client.py
+++ b/nautobot_ssot_infoblox/utils/client.py
@@ -152,7 +152,7 @@ def _get_network_ref(self, prefix):  # pylint: disable=inconsistent-return-state
         Returns Response:
             "network/ZG5zLm5ldHdvcmskMTkyLjAuMi4wLzI0LzA:192.0.2.0/24/default"
         """
-        for item in self.get_all_networks(prefix):
+        for item in self.get_all_subnets(prefix):
             if item["network"] == prefix:
                 return item["_ref"]
 
@@ -252,39 +252,6 @@ def get_all_ipv4address_networks(self, prefixes):
         logger.info(response.json()[0])
         return response.json()[0]
 
-    def get_all_networks(self, prefix=None):
-        """Get all IPv4 networks.
-
-        Args:
-            prefix (str): Network prefix - '10.220.0.0/22'
-
-        Returns:
-            (list): IPv4 dict objects
-
-        Return Response:
-        [
-            {
-                "_ref": "network/ZG5zLm5ldHdvcmskMTAuMjIzLjAuMC8yMS8w:10.223.0.0/21/default",
-                "network": "10.223.0.0/21",
-                "network_view": "default"
-            },
-            {
-                "_ref": "network/ZG5zLm5ldHdvcmskMTAuMjIwLjY0LjAvMjEvMA:10.220.64.0/21/default",
-                "network": "10.220.64.0/21",
-                "network_view": "default"
-            }
-        ]
-        """
-        params = {"_return_as_object": 1}
-
-        if prefix:
-            params.update({"network": prefix})
-
-        api_path = "network"
-        response = self._request("GET", api_path, params=params)
-        logger.info(response.json)
-        return response.json().get("result")
-
     def create_network(self, prefix, comment=None):
         """Create a network.
 
@@ -683,9 +650,12 @@ def get_dhcp_lease_from_hostname(self, hostname):
         logger.info(response.json)
         return response.json()
 
-    def get_all_subnets(self):
+    def get_all_subnets(self, prefix: str = None):
         """Get all Subnets.
 
+        Args:
+            prefix (str): Network prefix - '10.220.0.0/22'
+
         Returns:
             (list) of record dicts
 
@@ -705,6 +675,9 @@ def get_all_subnets(self):
         """
         url_path = "network"
         params = {"_return_as_object": 1, "_return_fields": "network,network_view,comment", "_max_results": 10000}
+
+        if prefix:
+            params.update({"network": prefix})
         try:
             response = self._request("GET", url_path, params=params)
         except HTTPError as err:
diff --git a/nautobot_ssot_infoblox/utils.py b/nautobot_ssot_infoblox/utils/diffsync.py
similarity index 50%
rename from nautobot_ssot_infoblox/utils.py
rename to nautobot_ssot_infoblox/utils/diffsync.py
index 31220fe..672c839 100644
--- a/nautobot_ssot_infoblox/utils.py
+++ b/nautobot_ssot_infoblox/utils/diffsync.py
@@ -1,4 +1,20 @@
-"""Utilities."""
+"""Utilities for DiffSync related stuff."""
+
+from nautobot.extras.models import Tag
+from nautobot_ssot_infoblox.constant import TAG_COLOR
+
+
+def create_tag_sync_from_infoblox():
+    """Create tag for tagging objects that have been created by Infoblox."""
+    tag, _ = Tag.objects.get_or_create(
+        slug="ssot-synced-from-infoblox",
+        defaults={
+            "name": "SSoT Synced from Infoblox",
+            "description": "Object synced at some point from Infoblox",
+            "color": TAG_COLOR,
+        },
+    )
+    return tag
 
 
 def get_vlan_view_name(reference):
diff --git a/pyproject.toml b/pyproject.toml
index ae0b2aa..2d8bc5b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "nautobot-ssot-infoblox"
-version = "0.5.1"
+version = "0.5.2"
 description = "Nautobot SSoT Infoblox"
 authors = ["Network to Code, LLC <info@networktocode.com>"]
 license = "Apache-2.0"
diff --git a/ssot-under-the-hood.gif b/ssot-under-the-hood.gif
deleted file mode 100644
index 9b18df2..0000000
Binary files a/ssot-under-the-hood.gif and /dev/null differ


Test patch:
diff --git a/nautobot_ssot_infoblox/tests/fixtures_infoblox.py b/nautobot_ssot_infoblox/tests/fixtures_infoblox.py
index 9e03f7a..25a38ff 100644
--- a/nautobot_ssot_infoblox/tests/fixtures_infoblox.py
+++ b/nautobot_ssot_infoblox/tests/fixtures_infoblox.py
@@ -5,7 +5,7 @@
 import os
 
 
-from nautobot_ssot_infoblox.diffsync import client
+from nautobot_ssot_infoblox.utils import client
 
 FIXTURES = os.environ.get("FIXTURE_DIR", "nautobot_ssot_infoblox/tests/fixtures")
 
diff --git a/nautobot_ssot_infoblox/tests/test_client.py b/nautobot_ssot_infoblox/tests/test_client.py
index d27370e..f61d5b8 100644
--- a/nautobot_ssot_infoblox/tests/test_client.py
+++ b/nautobot_ssot_infoblox/tests/test_client.py
@@ -11,7 +11,7 @@
 import requests_mock
 
 # from requests_mock.mocker import mock
-from nautobot_ssot_infoblox.diffsync.client import InvalidUrlScheme
+from nautobot_ssot_infoblox.utils.client import InvalidUrlScheme
 from nautobot_ssot_infoblox.tests.fixtures_infoblox import (
     get_ptr_record_by_name,
     localhost_client_infoblox,
@@ -423,7 +423,7 @@ def test_create_host_record_failure(self):
 
         self.assertEqual(response, [])
 
-    @patch("nautobot_ssot_infoblox.diffsync.client.InfobloxApi._find_network_reference")
+    @patch("nautobot_ssot_infoblox.utils.client.InfobloxApi._find_network_reference")
     def test_find_next_available_ip_success(self, mock_find_network_reference):
         test_network = "10.220.0.0/22"
         mock_find_network_reference.return_value = find_network_reference().get("result")
@@ -437,7 +437,7 @@ def test_find_next_available_ip_success(self, mock_find_network_reference):
         print(next_ip)
         self.assertEqual(next_ip, "10.220.0.1")
 
-    @patch("nautobot_ssot_infoblox.diffsync.client.InfobloxApi._find_network_reference")
+    @patch("nautobot_ssot_infoblox.utils.client.InfobloxApi._find_network_reference")
     def test_find_next_available_ip_no_network_reference(self, mock_find_network_reference):
         test_network = "10.220.0.0/22"
         mock_find_network_reference.side_effect = Exception
@@ -451,7 +451,7 @@ def test_find_next_available_ip_no_network_reference(self, mock_find_network_ref
 
         self.assertEqual(next_ip, "")
 
-    @patch("nautobot_ssot_infoblox.diffsync.client.InfobloxApi.find_next_available_ip")
+    @patch("nautobot_ssot_infoblox.utils.client.InfobloxApi.find_next_available_ip")
     def test_reserve_fixed_address_success(self, mock_find_next_available_ip):
         test_network = "10.220.0.0/22"
         test_mac = "11:22:33:AA:BB:CC"
@@ -466,7 +466,7 @@ def test_reserve_fixed_address_success(self, mock_find_next_available_ip):
 
         self.assertEqual(reserved_ip, "10.220.0.1")
 
-    @patch("nautobot_ssot_infoblox.diffsync.client.InfobloxApi.find_next_available_ip")
+    @patch("nautobot_ssot_infoblox.utils.client.InfobloxApi.find_next_available_ip")
     def test_reserve_fixed_address_no_ip(self, mock_find_next_available_ip):
         test_network = "10.220.0.0/22"
         test_mac = "11:22:33:AA:BB:CC"
diff --git a/nautobot_ssot_infoblox/tests/test_utils.py b/nautobot_ssot_infoblox/tests/test_utils.py
index 94396d4..009263f 100644
--- a/nautobot_ssot_infoblox/tests/test_utils.py
+++ b/nautobot_ssot_infoblox/tests/test_utils.py
@@ -1,7 +1,7 @@
 """Util tests that do not require Django."""
 import unittest
 
-from nautobot_ssot_infoblox.utils import get_vlan_view_name, nautobot_vlan_status
+from nautobot_ssot_infoblox.utils.diffsync import get_vlan_view_name, nautobot_vlan_status
 
 
 class TestUtils(unittest.TestCase):