Skip to content

Commit

Permalink
migrate from building_loctype to site_loctype
Browse files Browse the repository at this point in the history
  • Loading branch information
lpconsulting321 committed Dec 3, 2024
1 parent 04abf1e commit 9a41851
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def load_locations(self):
"longitude": format_latitude(site.longitude),
"contact_phone": site.phonenumber,
"physical_address": "\n".join(address),
"location_type__name": self.job.building_loctype.name,
"location_type__name": self.job.site_loctype.name,
"status__name": "Active",
"tags": [{"name": "SSoT Synced from Slurpit"}],
"system_of_record": "Slurpit",
Expand Down Expand Up @@ -296,7 +296,7 @@ def load_devices(self):
"role__name": constants.DEFAULT_DEVICE_ROLE,
"status__name": "Active",
"primary_ip4__host": device.ipv4,
"location__location_type__name": self.job.building_loctype.name,
"location__location_type__name": self.job.site_loctype.name,
"tags": [{"name": "SSoT Synced from Slurpit"}],
"system_of_record": "Slurpit",
"last_synced_from_sor": datetime.today().date().isoformat(),
Expand Down
14 changes: 7 additions & 7 deletions nautobot_ssot/integrations/slurpit/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class SlurpitDataSource(DataSource, Job): # pylint: disable=too-many-instance-a
label="Slurpit Instance",
)

building_loctype = ObjectVar(
site_loctype = ObjectVar(
model=LocationType,
queryset=LocationType.objects.all(),
display_field="name",
required=False,
label="Building LocationType",
label="Site LocationType",
description="LocationType to use for imported Sites from Slurpit. If unspecified, will revert to Site LocationType.",
)

Expand Down Expand Up @@ -117,7 +117,7 @@ def run(
dryrun,
memory_profiling,
credentials,
building_loctype,
site_loctype,
namespace,
ignore_prefixes,
sync_slurpit_tagged_only,
Expand All @@ -127,10 +127,10 @@ def run(
"""Run the Slurpit DataSource job."""
self.logger.info("Running Slurpit DataSource job")
self.credentials = credentials
self.building_loctype = building_loctype
if not self.building_loctype:
self.building_loctype = LocationType.objects.get_or_create(name="Site")[0]
self.building_loctype.content_types.add(ContentType.objects.get_for_model(Device))
self.site_loctype = site_loctype
if not self.site_loctype:
self.site_loctype = LocationType.objects.get_or_create(name="Site")[0]
self.site_loctype.content_types.add(ContentType.objects.get_for_model(Device))
self.namespace = namespace
if not self.namespace:
self.namespace = Namespace.objects.get(name="Global")
Expand Down
4 changes: 2 additions & 2 deletions nautobot_ssot/tests/slurpit/test_slurpit_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def setUp(self):

job = SlurpitDataSource()
job.job_result = JobResult.objects.create(name=job.class_path, task_name="fake task", worker="default")
job.building_loctype = LocationType.objects.get_or_create(name="Site")[0]
job.namespace = Namespace.objects.get(name="Global")
job.site_loctype = LocationType.objects.get_or_create(name="Site")[0]
job.namespace = Namespace.objects.get_or_create(name="Global")[0]
self.slurpit = SlurpitAdapter(job=job, api_client=slurpit_client)

def site_effect(value):
Expand Down

0 comments on commit 9a41851

Please sign in to comment.