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

SSoT ServiceNow fixes and updates for Nautobot 2.0 #560

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions changes/449.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `delete_records` flag to the ServiceNow DataTarget job
1 change: 1 addition & 0 deletions changes/449.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix logic used for loading location records to make ServiceNow SSoT Nautobot 2.x compatible
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def load_locations(self):
ancestor = self.site_filter.parent
while ancestor is not None:
locations.insert(0, ancestor)
ancestor = ancestor.parent
else:
locations = Location.objects.all()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def load(self):
# Load all Nautobot ancestor records as well
# This is so in case the Nautobot ancestors exist in ServiceNow but aren't linked to the record,
# we link them together instead of creating new, redundant ancestor records in ServiceNow.
ancestor = self.site_filter.region
ancestor = self.site_filter.parent
while ancestor is not None:
try:
self.get(self.location, ancestor.name)
Expand Down
6 changes: 5 additions & 1 deletion nautobot_ssot/integrations/servicenow/jobs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""ServiceNow Data Target Job."""

from diffsync.enum import DiffSyncFlags
from django.core.exceptions import ObjectDoesNotExist
from django.templatetags.static import static
from django.urls import reverse
Expand Down Expand Up @@ -79,11 +80,14 @@ def load_target_adapter(self):
self.target_adapter = ServiceNowDiffSync(client=snc, job=self, sync=self.sync, site_filter=self.site_filter)
self.target_adapter.load()

def run(self, dryrun, memory_profiling, site_filter, *args, **kwargs): # pylint:disable=arguments-differ
def run(self, dryrun, memory_profiling, delete_records, site_filter, *args, **kwargs): # pylint:disable=arguments-differ
"""Run sync."""
self.dryrun = dryrun
self.memory_profiling = memory_profiling
self.site_filter = site_filter
self.delete_records = delete_records
if not self.delete_records:
self.diffsync_flags |= DiffSyncFlags.SKIP_UNMATCHED_DST
super().run(dryrun, memory_profiling, *args, **kwargs)

def lookup_object(self, model_name, unique_id):
Expand Down
Loading