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

Commit

Permalink
Get local dev environment running
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmatthews committed Jun 24, 2021
1 parent 392ddf2 commit a0d9c55
Show file tree
Hide file tree
Showing 7 changed files with 1,189 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
# Each version of Nautobot listed here must have a corresponding directory/configuration file
# under development/nautobot_<NAUTOBOT_VER>/configuration.py
matrix:
- "INVOKE_NAUTOBOT_SSOT_SERVICENOW_NAUTOBOT_VER=1.0.0"
- "INVOKE_NAUTOBOT_SSOT_SERVICENOW_NAUTOBOT_VER=1.0.3"
# Add your encrypted secret below, you can encrypt secret using "travis encrypt"
# https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml
# global:
Expand Down
1 change: 1 addition & 0 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ WORKDIR /source

# Copy in only pyproject.toml/poetry.lock to help with caching this layer if no updates to dependencies
COPY poetry.lock pyproject.toml /source/
COPY packages/*.whl /source/packages/
# --no-root declares not to install the project package since we're wanting to take advantage of caching dependency installation
# and the project is copied in and installed after this step
RUN poetry install --no-interaction --no-ansi --no-root
Expand Down
15 changes: 8 additions & 7 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,17 @@ def is_truthy(arg):
PAGINATE_COUNT = int(os.environ.get("PAGINATE_COUNT", 50))

# Enable installed plugins. Add the name of each plugin to the list.
PLUGINS = ["nautobot_ssot_servicenow"]
PLUGINS = ["nautobot_ssot", "nautobot_ssot_servicenow"]

# 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 = {
# 'my_plugin': {
# 'foo': 'bar',
# 'buzz': 'bazz'
# }
# }
PLUGINS_CONFIG = {
"nautobot_ssot_servicenow": {
"instance": "dev12345",
"username": os.getenv("SERVICENOW_USERNAME", ""),
"password": os.getenv("SERVICENOW_PASSWORD", ""),
}
}

# When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to
# prefer IPv4 instead.
Expand Down
14 changes: 7 additions & 7 deletions nautobot_ssot_servicenow/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ def config_information(cls):
def sync_data(self):
"""Sync a slew of Nautobot data into ServiceNow."""
configs = settings.PLUGINS_CONFIG.get("nautobot_ssot_servicenow", {})
self.snc = ServiceNowClient(
snc = ServiceNowClient(
instance=configs.get("instance"),
username=configs.get("username"),
password=configs.get("password"),
worker=self,
)
self.log_info(message="Loading current data from ServiceNow...")
self.servicenow_diffsync = ServiceNowDiffSync(client=self.snc, job=self, sync=self.sync)
self.servicenow_diffsync.load()
servicenow_diffsync = ServiceNowDiffSync(client=snc, job=self, sync=self.sync)
servicenow_diffsync.load()

self.log_info(message="Loading current data from Nautobot...")
self.nautobot_diffsync = NautobotDiffSync(job=self, sync=self.sync)
self.nautobot_diffsync.load()
nautobot_diffsync = NautobotDiffSync(job=self, sync=self.sync)
nautobot_diffsync.load()

diffsync_flags = DiffSyncFlags.CONTINUE_ON_FAILURE
if self.kwargs["log_unchanged"]:
Expand All @@ -79,13 +79,13 @@ def sync_data(self):
diffsync_flags |= DiffSyncFlags.SKIP_UNMATCHED_DST

self.log_info(message="Calculating diffs...")
diff = self.servicenow_diffsync.diff_from(self.nautobot_diffsync, flags=diffsync_flags)
diff = servicenow_diffsync.diff_from(nautobot_diffsync, flags=diffsync_flags)
self.sync.diff = diff.dict()
self.sync.save()

if not self.kwargs["dry_run"]:
self.log_info(message="Syncing from Nautobot to ServiceNow...")
self.servicenow_diffsync.sync_from(self.nautobot_diffsync, flags=diffsync_flags)
servicenow_diffsync.sync_from(nautobot_diffsync, flags=diffsync_flags)
self.log_info(message="Sync complete")

def lookup_object(self, model_name, unique_id):
Expand Down
Binary file added packages/nautobot_ssot-0.1.0-py3-none-any.whl
Binary file not shown.
Loading

0 comments on commit a0d9c55

Please sign in to comment.