diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d72d08f --- /dev/null +++ b/CHANGELOG.md @@ -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. diff --git a/development/nautobot_config.py b/development/nautobot_config.py index bf36553..ed1a424 100644 --- a/development/nautobot_config.py +++ b/development/nautobot_config.py @@ -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", ""), - } + }, } diff --git a/nautobot_ssot_servicenow/diffsync/adapter_servicenow.py b/nautobot_ssot_servicenow/diffsync/adapter_servicenow.py index d4045d5..f5f3821 100644 --- a/nautobot_ssot_servicenow/diffsync/adapter_servicenow.py +++ b/nautobot_ssot_servicenow/diffsync/adapter_servicenow.py @@ -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 @@ -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( diff --git a/nautobot_ssot_servicenow/jobs.py b/nautobot_ssot_servicenow/jobs.py index 535d1b8..77d9425 100644 --- a/nautobot_ssot_servicenow/jobs.py +++ b/nautobot_ssot_servicenow/jobs.py @@ -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.""" @@ -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." diff --git a/nautobot_ssot_servicenow/tests/test_jobs.py b/nautobot_ssot_servicenow/tests/test_jobs.py index e6532da..7d21f62 100644 --- a/nautobot_ssot_servicenow/tests/test_jobs.py +++ b/nautobot_ssot_servicenow/tests/test_jobs.py @@ -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)