From b6d6306bd55b93e5774a992ea9d7f88d784b28df Mon Sep 17 00:00:00 2001 From: "Zach Biles @bile0026" Date: Thu, 5 Dec 2024 16:38:10 -0600 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20handle=20platforms=20?= =?UTF-8?q?with=20no=20manufacturer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integrations/bootstrap/diffsync/models/base.py | 2 +- .../integrations/bootstrap/fixtures/global_settings.yml | 6 ++++++ .../tests/bootstrap/fixtures/global_settings.json | 8 ++++++++ nautobot_ssot/tests/bootstrap/test_setup.py | 4 +++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/nautobot_ssot/integrations/bootstrap/diffsync/models/base.py b/nautobot_ssot/integrations/bootstrap/diffsync/models/base.py index f702008c..fb841e7c 100755 --- a/nautobot_ssot/integrations/bootstrap/diffsync/models/base.py +++ b/nautobot_ssot/integrations/bootstrap/diffsync/models/base.py @@ -362,7 +362,7 @@ class Platform(DiffSyncModel): _children = {} name: str - manufacturer: str + manufacturer: Optional[str] = None network_driver: Optional[str] = None napalm_driver: Optional[str] = None napalm_arguments: Optional[dict] = None diff --git a/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml b/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml index f938033a..71cb1c8c 100755 --- a/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml +++ b/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml @@ -151,6 +151,12 @@ platform: napalm_driver: "" napalm_arguments: {} description: "Arista Devices" + - name: "linux" + manufacturer: "" + network_driver: "" + napalm_driver: "" + napalm_arguments: {} + description: "Linux Devices" location_type: - name: "Region" parent: "" diff --git a/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json b/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json index 68eb8226..da994522 100644 --- a/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json +++ b/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json @@ -211,6 +211,14 @@ "napalm_driver": "", "napalm_arguments": {}, "description": "Arista Devices" + }, + { + "name": "linux", + "manufacturer": "", + "network_driver": "", + "napalm_driver": "", + "napalm_arguments": {}, + "description": "Linux Devices" } ], "location_type": [ diff --git a/nautobot_ssot/tests/bootstrap/test_setup.py b/nautobot_ssot/tests/bootstrap/test_setup.py index 8a56c11e..11803095 100644 --- a/nautobot_ssot/tests/bootstrap/test_setup.py +++ b/nautobot_ssot/tests/bootstrap/test_setup.py @@ -695,7 +695,9 @@ def _setup_manufacturers(self): def _setup_platforms(self): for _platform in GLOBAL_YAML_SETTINGS["platform"]: - _manufac = Manufacturer.objects.get(name=_platform["manufacturer"]) + _manufac = None + if _platform["manufacturer"]: + _manufac = Manufacturer.objects.get(name=_platform["manufacturer"]) _platf = Platform.objects.create( name=_platform["name"], manufacturer=_manufac, From 0fb9f9f0c475c28f61d97ff2f6c2df04faae75d1 Mon Sep 17 00:00:00 2001 From: "Zach Biles @bile0026" Date: Thu, 5 Dec 2024 16:41:25 -0600 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20=F0=9F=9A=A7=20add=20change=20frag?= =?UTF-8?q?ment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/614.fixed | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/614.fixed diff --git a/changes/614.fixed b/changes/614.fixed new file mode 100644 index 00000000..f9eb3f85 --- /dev/null +++ b/changes/614.fixed @@ -0,0 +1 @@ +Fixed creating platforms with no Manufacturer assigned. \ No newline at end of file From 79a9576becbd9d8d0ae85b353937c27c8e01c6a9 Mon Sep 17 00:00:00 2001 From: "Zach Biles @bile0026" Date: Thu, 5 Dec 2024 16:56:56 -0600 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20platform=20crea?= =?UTF-8?q?tion=20with=20no=20manufacturer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integrations/bootstrap/diffsync/models/nautobot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nautobot_ssot/integrations/bootstrap/diffsync/models/nautobot.py b/nautobot_ssot/integrations/bootstrap/diffsync/models/nautobot.py index b14cf190..76081a68 100755 --- a/nautobot_ssot/integrations/bootstrap/diffsync/models/nautobot.py +++ b/nautobot_ssot/integrations/bootstrap/diffsync/models/nautobot.py @@ -351,7 +351,9 @@ def create(cls, adapter, ids, attrs): """Create Platform in Nautobot from NautobotPlatform object.""" adapter.job.logger.info(f'Creating Nautobot Platform {ids["name"]}') try: - _manufacturer = ORMManufacturer.objects.get(name=ids["manufacturer"]) + _manufacturer = None + if ids["manufacturer"]: + _manufacturer = ORMManufacturer.objects.get(name=ids["manufacturer"]) _new_platform = ORMPlatform( name=ids["name"], manufacturer=_manufacturer, From 769f9e2f89f33b97233f2370e358da2ce13b0c7b Mon Sep 17 00:00:00 2001 From: "Zach Biles @bile0026" Date: Fri, 6 Dec 2024 08:22:58 -0600 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20time=5Fzone=20n?= =?UTF-8?q?ormalization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/614.fixed | 3 ++- .../bootstrap/diffsync/adapters/nautobot.py | 2 +- .../bootstrap/fixtures/global_settings.yml | 17 +++++++++++++++++ .../bootstrap/fixtures/global_settings.json | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/changes/614.fixed b/changes/614.fixed index f9eb3f85..a8f04e78 100644 --- a/changes/614.fixed +++ b/changes/614.fixed @@ -1 +1,2 @@ -Fixed creating platforms with no Manufacturer assigned. \ No newline at end of file +Fixed creating platforms with no Manufacturer assigned. +Fixed time_zone attribute normalization on Location objects. \ No newline at end of file diff --git a/nautobot_ssot/integrations/bootstrap/diffsync/adapters/nautobot.py b/nautobot_ssot/integrations/bootstrap/diffsync/adapters/nautobot.py index 09a77875..5af9cd8d 100755 --- a/nautobot_ssot/integrations/bootstrap/diffsync/adapters/nautobot.py +++ b/nautobot_ssot/integrations/bootstrap/diffsync/adapters/nautobot.py @@ -440,7 +440,7 @@ def load_location(self): except AttributeError: _time_zone = nb_location.time_zone else: - _time_zone = None + _time_zone = "" if nb_location.tenant is not None: _tenant = nb_location.tenant.name else: diff --git a/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml b/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml index 71cb1c8c..fe0177f5 100755 --- a/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml +++ b/nautobot_ssot/integrations/bootstrap/fixtures/global_settings.yml @@ -254,6 +254,23 @@ location: contact_phone: "" contact_email: "" tags: [] + - name: "Southwest" + location_type: "Region" + parent: "" + status: "Active" + facility: "OR1" + asn: + time_zone: "" + description: "" + tenant: "" + physical_address: "" + shipping_address: "" + latitude: + longitude: + contact_name: "" + contact_phone: "" + contact_email: "" + tags: [] team: - name: "Datacenter" phone: "123-456-7890" diff --git a/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json b/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json index da994522..af409885 100644 --- a/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json +++ b/nautobot_ssot/tests/bootstrap/fixtures/global_settings.json @@ -289,6 +289,20 @@ "contact_phone": "", "contact_email": "", "tags": [] + }, + { + "name": "Southwest", + "location_type": "Region", + "status": "Active", + "facility": "OR1", + "time_zone": "", + "description": "", + "physical_address": "", + "shipping_address": "", + "contact_name": "", + "contact_phone": "", + "contact_email": "", + "tags": [] } ], "team": [