-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from nautobot/ssot-cookie-revamp
revamps SSoT cookie for contrib pattern
- Loading branch information
Showing
11 changed files
with
72 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Diffsync components for {{ cookiecutter.app_name }}.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/__init__.py
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/adapters/nautobot.py
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
...t-app-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""Diffsync models for {{ cookiecutter.app_name }}.""" | ||
from typing import Optional, Annotated | ||
|
||
{% if cookiecutter.direction_of_sync == "From Nautobot" %} | ||
from diffsync import DiffSyncModel | ||
{% endif %} | ||
from nautobot.dcim.models import Device | ||
{% if cookiecutter.direction_of_sync == "To Nautobot" %} | ||
from nautobot_ssot.contrib import CustomFieldAnnotation, NautobotModel | ||
{% endif %} | ||
|
||
class DeviceSSoTModel({{ "NautobotModel" if cookiecutter.direction_of_sync == "To Nautobot" else "DiffSyncModel" }}): | ||
"""SSoT model for {{ cookiecutter.system_of_record }} devices.""" | ||
|
||
{% if cookiecutter.direction_of_sync == "To Nautobot" %}_model = Device{% endif %} | ||
_modelname = "device" | ||
_identifiers = ("name",) | ||
_attributes = ( | ||
"status__name", | ||
"role__name", | ||
"device_type__name", | ||
"location__name", | ||
"example_custom_field" | ||
) | ||
|
||
name: str | ||
status__name: Optional[str] = None | ||
role__name: Optional[str] = None | ||
device_type__name: Optional[str] = None | ||
location__name: Optional[str] = None | ||
ip_address: Optional[str] = None | ||
example_custom_field: Annotated[str, CustomFieldAnnotation(key="my_example_custom_field")] | ||
{% if cookiecutter.direction_of_sync == "From Nautobot" %} | ||
@classmethod | ||
def create(cls, adapter, ids, attrs): | ||
"""Create device in {{ cookiecutter.system_of_record }}.""" | ||
raise NotImplementedError("Device creation is not implemented.") | ||
|
||
def update(self, attrs): | ||
"""Update device in {{ cookiecutter.system_of_record }}.""" | ||
raise NotImplementedError("Device updates are not implemented.") | ||
|
||
def delete(self): | ||
"""Delete device in {{ cookiecutter.system_of_record }}.""" | ||
raise NotImplementedError("Device deletion is not implemented.") | ||
{% endif %} |
1 change: 0 additions & 1 deletion
1
...t/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/__init__.py
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
...-ssot/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/base.py
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
...t/{{ cookiecutter.project_slug }}/{{ cookiecutter.app_name }}/diffsync/models/nautobot.py
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
...}/{{ cookiecutter.app_name }}/diffsync/models/{{ cookiecutter.system_of_record_slug }}.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters