Skip to content

Commit

Permalink
Merge pull request #649 from nautobot/patch-648-citrix-adm-removes-so…
Browse files Browse the repository at this point in the history
…ftwareversion

Fix Citrix ADM Removing Used SoftwareVersions
  • Loading branch information
jdrew82 authored Jan 9, 2025
2 parents 9248568 + efd1e50 commit 869cf7f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions changes/648.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed Citrix ADM deleting SoftwareVersion in use with ValidatedSoftware.
Fixed Meraki deleting SoftwareVersion in use with ValidatedSoftware.
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
12 changes: 9 additions & 3 deletions nautobot_ssot/integrations/meraki/diffsync/models/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 4 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 869cf7f

Please sign in to comment.