Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Citrix ADM Removing Used SoftwareVersions #649

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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