From 7ae2c1eaab9c7edb82c51c90f6ed72557a759bb3 Mon Sep 17 00:00:00 2001 From: Justin Drew <2396364+jdrew82@users.noreply.github.com> Date: Tue, 8 Oct 2024 08:51:50 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Update=20SSoT=20for=20SSoT?= =?UTF-8?q?=203.0=20pattern=20with=20Adapter=20replacing=20DiffSync.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../diffsync/adapters/nautobot.py | 5 +++-- .../{{ cookiecutter.system_of_record_slug }}.py | 5 +++-- .../diffsync/models/base.py | 12 ++++++------ .../diffsync/models/nautobot.py | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/nautobot.py b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/nautobot.py index bcb1961b..73cb33e9 100644 --- a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/nautobot.py +++ b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/nautobot.py @@ -1,10 +1,11 @@ """Nautobot Adapter for {{ cookiecutter.system_of_record }} SSoT app.""" -from diffsync import DiffSync +from diffsync import Adapter + from {{ cookiecutter.app_name }}.diffsync.models.nautobot import NautobotDevice -class NautobotAdapter(DiffSync): +class NautobotAdapter(Adapter): """DiffSync adapter for Nautobot.""" device = NautobotDevice diff --git a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/{{ cookiecutter.system_of_record_slug }}.py b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/{{ cookiecutter.system_of_record_slug }}.py index a4b24299..9a98851a 100644 --- a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/{{ cookiecutter.system_of_record_slug }}.py +++ b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/{{ cookiecutter.system_of_record_slug }}.py @@ -1,10 +1,11 @@ """{{ cookiecutter.verbose_name }} Adapter for {{ cookiecutter.system_of_record }} SSoT app.""" -from diffsync import DiffSync +from diffsync import Adapter + from {{ cookiecutter.app_name }}.diffsync.models.{{ cookiecutter.system_of_record_slug }} import {{ cookiecutter.system_of_record_camel }}Device -class {{ cookiecutter.system_of_record_camel }}Adapter(DiffSync): +class {{ cookiecutter.system_of_record_camel }}Adapter(Adapter): """DiffSync adapter for {{ cookiecutter.system_of_record }}.""" device = {{ cookiecutter.system_of_record_camel }}Device diff --git a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/base.py b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/base.py index 473bdea7..5436c8c4 100644 --- a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/base.py +++ b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/base.py @@ -20,10 +20,10 @@ class Device(DiffSyncModel): _children = {} name: str - status: Optional[str] - role: Optional[str] - model: Optional[str] - location: Optional[str] - ip_address: Optional[str] + status: Optional[str] = None + role: Optional[str] = None + model: Optional[str] = None + location: Optional[str] = None + ip_address: Optional[str] = None - uuid: Optional[UUID] + uuid: Optional[UUID] = None diff --git a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/nautobot.py b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/nautobot.py index 94e8af30..c53eca86 100644 --- a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/nautobot.py +++ b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/nautobot.py @@ -28,7 +28,7 @@ class NautobotDevice(Device): """Nautobot implementation of {{ cookiecutter.system_of_record }} Device model.""" @classmethod - def create(cls, diffsync, ids, attrs): + def create(cls, adapter, ids, attrs): """Create Device in Nautobot from NautobotDevice object.""" new_device = NewDevice( name=ids["name"], @@ -38,7 +38,7 @@ def create(cls, diffsync, ids, attrs): location=ensure_location(attrs["location"]), ) new_device.validated_save() - return super().create(diffsync=diffsync, ids=ids, attrs=attrs) + return super().create(adapter=adapter, ids=ids, attrs=attrs) def update(self, attrs): """Update Device in Nautobot from NautobotDevice object."""