Skip to content

Commit

Permalink
feat: ✨ Update SSoT for SSoT 3.0 pattern with Adapter replacing DiffS…
Browse files Browse the repository at this point in the history
…ync.
  • Loading branch information
jdrew82 committed Oct 8, 2024
1 parent 24717b9 commit 7ae2c1e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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."""
Expand Down

0 comments on commit 7ae2c1e

Please sign in to comment.