Skip to content

Commit

Permalink
fix: 🐛 Replicate check for ValidatedSoftware used with SoftwareVersio…
Browse files Browse the repository at this point in the history
…n delete() in Meraki integration.
  • Loading branch information
jdrew82 committed Jan 9, 2025
1 parent 4fe6ec9 commit efd1e50
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion changes/648.fixed
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Fixed Citrix ADM deleting SoftwareVersion in use with ValidatedSoftware.
Fixed Citrix ADM deleting SoftwareVersion in use with ValidatedSoftware.
Fixed Meraki deleting SoftwareVersion in use with ValidatedSoftware.
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 efd1e50

Please sign in to comment.