From 69a2733dbcc351ba76915964837fa62429ac3572 Mon Sep 17 00:00:00 2001 From: bile0026 Date: Thu, 19 Dec 2024 09:44:01 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20adjust=20tenant=20referen?= =?UTF-8?q?ces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integrations/librenms/diffsync/models/nautobot.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nautobot_ssot/integrations/librenms/diffsync/models/nautobot.py b/nautobot_ssot/integrations/librenms/diffsync/models/nautobot.py index 862cdfdd..4591434f 100644 --- a/nautobot_ssot/integrations/librenms/diffsync/models/nautobot.py +++ b/nautobot_ssot/integrations/librenms/diffsync/models/nautobot.py @@ -13,7 +13,6 @@ from nautobot.dcim.models import SoftwareImageFile as ORMSoftwareImageFile from nautobot.dcim.models import SoftwareVersion as ORMSoftwareVersion from nautobot.extras.models import Role, Status -from nautobot.tenancy.models import Tenant from nautobot_ssot.integrations.librenms.constants import os_manufacturer_map from nautobot_ssot.integrations.librenms.diffsync.models.base import Device, Location, Port @@ -71,8 +70,8 @@ def create(cls, adapter, ids, attrs): status=Status.objects.get(name=attrs["status"]), location_type=LocationType.objects.get(name="Site"), ) - if adapter.job.tenant: - new_location.tenant = adapter.job.tenant.value + if adapter.tenant: + new_location.tenant = adapter.tenant new_location.custom_field_data.update( {"system_of_record": os.getenv("NAUTOBOT_SSOT_LIBRENMS_SYSTEM_OF_RECORD", "LibreNMS")} ) @@ -123,7 +122,6 @@ def create(cls, adapter, ids, attrs): adapter.job.logger.debug(f'Device Location {attrs["location"]}') new_device = ORMDevice( name=ids["name"], - device_id=attrs["device_id"], device_type=_device_type, status=Status.objects.get_or_create(name=attrs["status"])[0], role=ensure_role(role_name=attrs["role"], content_type=ORMDevice), @@ -139,8 +137,9 @@ def create(cls, adapter, ids, attrs): device_type=_device_type, ), ) - if adapter.job.tenant: - new_device.tenant = adapter.job.tenant.value + if adapter.tenant: + new_device.tenant = adapter.tenant + new_device.custom_field_data.update({"librenms_device_id": attrs["device_id"]}) new_device.custom_field_data.update( {"system_of_record": os.getenv("NAUTOBOT_SSOT_LIBRENMS_SYSTEM_OF_RECORD", "LibreNMS")} )