Skip to content

Commit

Permalink
fix: 🐛 adjust tenant references
Browse files Browse the repository at this point in the history
  • Loading branch information
bile0026 committed Dec 19, 2024
1 parent 7320b04 commit 69a2733
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions nautobot_ssot/integrations/librenms/diffsync/models/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")}
)
Expand Down Expand Up @@ -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),
Expand All @@ -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")}
)
Expand Down

0 comments on commit 69a2733

Please sign in to comment.