From e84a703b96700a78733084b67c7cd2038de36e04 Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:14:13 -0600 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Add=20check=20for=20V?= =?UTF-8?q?alidatedSoftware=20being=20used=20with=20SoftwareVersion=20befo?= =?UTF-8?q?re=20deleting=20it.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../citrix_adm/diffsync/models/nautobot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nautobot_ssot/integrations/citrix_adm/diffsync/models/nautobot.py b/nautobot_ssot/integrations/citrix_adm/diffsync/models/nautobot.py index 9558347a..623a2522 100644 --- a/nautobot_ssot/integrations/citrix_adm/diffsync/models/nautobot.py +++ b/nautobot_ssot/integrations/citrix_adm/diffsync/models/nautobot.py @@ -79,8 +79,14 @@ def create(cls, adapter, ids, attrs): def delete(self): """Delete SoftwareVersion in Nautobot from NautobotOSVersion object.""" ver = SoftwareVersion.objects.get(id=self.uuid) - super().delete() - ver.delete() + if hasattr(ver, "validatedsoftwarelcm_set"): + if ver.validatedsoftwarelcm_set.count() != 0: + self.adapter.job.logger.warning( + f"SoftwareVersion {ver.version} for {ver.platform.name} is used with a ValidatedSoftware so won't be deleted." + ) + else: + super().delete() + ver.delete() return self From 4fe6ec9cb380477f4fab53bdea2e0ce6d0b29fb4 Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:15:09 -0600 Subject: [PATCH 2/3] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Add=20changelog=20fr?= =?UTF-8?q?agment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/648.fixed | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/648.fixed diff --git a/changes/648.fixed b/changes/648.fixed new file mode 100644 index 00000000..33c78027 --- /dev/null +++ b/changes/648.fixed @@ -0,0 +1 @@ +Fixed Citrix ADM deleting SoftwareVersion in use with ValidatedSoftware. \ No newline at end of file From efd1e50dd35d9a32ac7020fa33ffc4ed441e72a0 Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:47:56 -0600 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Replicate=20check=20f?= =?UTF-8?q?or=20ValidatedSoftware=20used=20with=20SoftwareVersion=20delete?= =?UTF-8?q?()=20in=20Meraki=20integration.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changes/648.fixed | 3 ++- .../integrations/meraki/diffsync/models/nautobot.py | 12 +++++++++--- tasks.py | 6 ++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/changes/648.fixed b/changes/648.fixed index 33c78027..839b0fb7 100644 --- a/changes/648.fixed +++ b/changes/648.fixed @@ -1 +1,2 @@ -Fixed Citrix ADM deleting SoftwareVersion in use with ValidatedSoftware. \ No newline at end of file +Fixed Citrix ADM deleting SoftwareVersion in use with ValidatedSoftware. +Fixed Meraki deleting SoftwareVersion in use with ValidatedSoftware. \ No newline at end of file diff --git a/nautobot_ssot/integrations/meraki/diffsync/models/nautobot.py b/nautobot_ssot/integrations/meraki/diffsync/models/nautobot.py index 5d9e1665..4d525063 100644 --- a/nautobot_ssot/integrations/meraki/diffsync/models/nautobot.py +++ b/nautobot_ssot/integrations/meraki/diffsync/models/nautobot.py @@ -114,10 +114,16 @@ def create(cls, adapter, ids, attrs): return super().create(adapter=adapter, ids=ids, attrs=attrs) def delete(self): - """Delete DeviceType in Nautobot from NautobotHardware object.""" - super().delete() + """Delete SoftwareVersion in Nautobot from NautobotOSVersion object.""" osversion = SoftwareVersion.objects.get(id=self.uuid) - osversion.delete() + if hasattr(osversion, "validatedsoftwarelcm_set"): + if osversion.validatedsoftwarelcm_set.count() != 0: + self.adapter.job.logger.warning( + f"SoftwareVersion {osversion.version} for {osversion.platform.name} is used with a ValidatedSoftware so won't be deleted." + ) + else: + super().delete() + osversion.delete() return self diff --git a/tasks.py b/tasks.py index 0ee4210e..113bdd51 100644 --- a/tasks.py +++ b/tasks.py @@ -768,7 +768,8 @@ def pylint(context): else: print("No migrations directory found, skipping migrations checks.") - raise Exit(code=exit_code) + if exit_code == 1: + raise Exit(code=exit_code) @task(aliases=("a",)) @@ -812,7 +813,8 @@ def ruff(context, action=None, target=None, fix=False, output_format="concise"): if not run_command(context, command, warn=True): exit_code = 1 - raise Exit(code=exit_code) + if exit_code == 1: + raise Exit(code=exit_code) @task