Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Update module and job names, fix a bug in servicenow adapter, add changelog #9

Merged
merged 2 commits into from
Jan 21, 2022
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

## v0.9.1 - 2022-01-21

### Changed

- #9 - Updated job names and job module `name`.

### Fixed

- #9 - Fixed an error when loading the ServiceNow adapter with certain data sets.

## v0.9.0 - 2022-01-14

First public release. Not yet feature-complete (see #4, #6) but suitable for demonstration purposes.
5 changes: 4 additions & 1 deletion development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@
# Plugins configuration settings. These settings are used by various plugins that the user may have installed.
# Each key in the dictionary is the name of an installed plugin and its value is a dictionary of settings.
PLUGINS_CONFIG = {
"nautobot_ssot": {
"hide_example_jobs": True,
},
"nautobot_ssot_servicenow": {
"instance": os.getenv("SERVICENOW_INSTANCE", ""),
"username": os.getenv("SERVICENOW_USERNAME", ""),
"password": os.getenv("SERVICENOW_PASSWORD", ""),
}
},
}
8 changes: 5 additions & 3 deletions nautobot_ssot_servicenow/diffsync/adapter_servicenow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from diffsync import DiffSync
from diffsync.enum import DiffSyncFlags
from diffsync.exceptions import ObjectAlreadyExists
from diffsync.exceptions import ObjectAlreadyExists, ObjectNotFound
from jinja2 import Environment, FileSystemLoader
import yaml

Expand Down Expand Up @@ -76,14 +76,16 @@ def load(self):
# we link them together instead of creating new, redundant ancestor records in ServiceNow.
ancestor = self.site_filter.region
while ancestor is not None:
if not self.get(self.location, ancestor.name):
try:
self.get(self.location, ancestor.name)
except ObjectNotFound:
record = (
self.client.resource(api_path=f"/table/{entry['table']}")
.get(query={"name": ancestor.name})
.one_or_none()
)
if record:
location = self.load_record(entry["table"], record, self.location, entry["mappings"])
self.load_record(entry["table"], record, self.location, entry["mappings"])
ancestor = ancestor.parent

self.job.log_info(
Expand Down
5 changes: 4 additions & 1 deletion nautobot_ssot_servicenow/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from .utils import get_servicenow_parameters


name = "SSoT - ServiceNow" # pylint: disable=invalid-name


class ServiceNowDataTarget(DataTarget, Job):
"""Job syncing data from Nautobot to ServiceNow."""

Expand All @@ -42,7 +45,7 @@ class ServiceNowDataTarget(DataTarget, Job):
class Meta:
"""Metadata about this Job."""

name = "ServiceNow"
name = "Nautobot ⟹ ServiceNow"
data_target = "ServiceNow"
data_target_icon = static("nautobot_ssot_servicenow/ServiceNow_logo.svg")
description = "Synchronize data from Nautobot into ServiceNow."
Expand Down
4 changes: 2 additions & 2 deletions nautobot_ssot_servicenow/tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class ServiceNowDataTargetJobTestCase(TestCase):

def test_metadata(self):
"""Verify correctness of the Job Meta attributes."""
self.assertEqual("ServiceNow", ServiceNowDataTarget.name)
self.assertEqual("ServiceNow", ServiceNowDataTarget.Meta.name)
self.assertEqual("Nautobot ⟹ ServiceNow", ServiceNowDataTarget.name)
self.assertEqual("Nautobot ⟹ ServiceNow", ServiceNowDataTarget.Meta.name)
self.assertEqual("ServiceNow", ServiceNowDataTarget.Meta.data_target)
self.assertEqual("Synchronize data from Nautobot into ServiceNow.", ServiceNowDataTarget.description)
self.assertEqual("Synchronize data from Nautobot into ServiceNow.", ServiceNowDataTarget.Meta.description)
Expand Down