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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmatthews committed Jan 21, 2022
2 parents 751a5ac + fc3da2f commit 895b8d7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nautobot-ssot-servicenow"
version = "0.9.0"
version = "0.9.1"
description = "Nautobot SSoT ServiceNow"
authors = ["Network to Code, LLC <opensource@networktocode.com>"]

Expand Down

0 comments on commit 895b8d7

Please sign in to comment.