Skip to content

Commit

Permalink
Merge pull request #168 from nautobot/feat-rc1_update
Browse files Browse the repository at this point in the history
Update for Nautobot 2.0.0.rc1 Support
  • Loading branch information
jdrew82 authored Aug 24, 2023
2 parents b497e23 + ef0b63f commit df16704
Show file tree
Hide file tree
Showing 14 changed files with 680 additions and 650 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
fail-fast: true
matrix:
python-version: ["3.10"]
nautobot-version: ["2.0.0-beta.2"]
nautobot-version: ["2.0.0-rc.1"]
env:
INVOKE_NAUTOBOT_SSOT_PYTHON_VER: "${{ matrix.python-version }}"
INVOKE_NAUTOBOT_SSOT_NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
Expand Down Expand Up @@ -119,13 +119,9 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.10"]
db-backend: ["postgresql"]
nautobot-version: ["2.0.0-beta.2"]
include:
- python-version: "3.10"
db-backend: "mysql"
nautobot-version: "2.0.0-beta.2"
python-version: ["3.8", "3.9", "3.10"]
db-backend: ["postgresql", "mysql"]
nautobot-version: ["2.0.0-rc.1"]
runs-on: "ubuntu-20.04"
env:
INVOKE_NAUTOBOT_SSOT_PYTHON_VER: "${{ matrix.python-version }}"
Expand Down
2 changes: 2 additions & 0 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ RUN pip install -c constraints.txt -r poetry_freeze_dev.txt

COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py
# !!! USE CAUTION WHEN MODIFYING LINES ABOVE

USER root
2 changes: 1 addition & 1 deletion nautobot_ssot/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Meta:
fields = ["sync", "action", "status"]


class SyncForm(BootstrapMixin, forms.Form):
class SyncForm(BootstrapMixin, forms.Form): # pylint: disable=nb-incorrect-base-class
"""Base class for dynamic form generation for a SyncWorker."""

dry_run = forms.BooleanField(
Expand Down
4 changes: 2 additions & 2 deletions nautobot_ssot/integrations/aristacv/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def _read_settings() -> dict:
"400GBASE-ZR": "400gbase-x-qsfpdd",
}

CLOUDVISION_PLATFORM = "arista_eos_cloudvision"
CLOUDVISION_PLATFORM = "Arista EOS-CloudVision"

ARISTA_PLATFORM = "arista_eos"
ARISTA_PLATFORM = "arista.eos.eos"
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def load_devices(self):
new_cvp = self.device(
name="CloudVision",
serial="",
status="active",
status="Active",
device_model="CloudVision",
version=cvp_version,
uuid=None,
Expand Down
20 changes: 10 additions & 10 deletions nautobot_ssot/integrations/aristacv/diffsync/models/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ def create(cls, diffsync, ids, attrs):
)

if APP_SETTINGS.get("create_controller") and "CloudVision" in ids["name"]:
platform = OrmPlatform.objects.get(slug=CLOUDVISION_PLATFORM)
platform = OrmPlatform.objects.get(name=CLOUDVISION_PLATFORM)
else:
platform = OrmPlatform.objects.get(slug=ARISTA_PLATFORM)
platform = OrmPlatform.objects.get(name=ARISTA_PLATFORM)

device_type_object = nautobot.verify_device_type_object(attrs["device_model"])

new_device = OrmDevice(
status=OrmStatus.objects.get(slug=attrs["status"]),
status=OrmStatus.objects.get(name=attrs["status"]),
device_type=device_type_object,
device_role=role,
platform=platform,
Expand All @@ -90,7 +90,7 @@ def create(cls, diffsync, ids, attrs):
try:
new_device.validated_save()
if LIFECYCLE_MGMT and attrs.get("version"):
software_lcm = cls._add_software_lcm(platform=platform.slug, version=attrs["version"])
software_lcm = cls._add_software_lcm(platform=platform.name, version=attrs["version"])
cls._assign_version_to_device(diffsync=diffsync, device=new_device, software_lcm=software_lcm)
return super().create(ids=ids, diffsync=diffsync, attrs=attrs)
except ValidationError as err:
Expand All @@ -102,15 +102,15 @@ def update(self, attrs):
dev = OrmDevice.objects.get(id=self.uuid)
if not dev.platform:
if dev.name != "CloudVision":
dev.platform = OrmPlatform.objects.get(slug="arista_eos")
dev.platform = OrmPlatform.objects.get(name=ARISTA_PLATFORM)
else:
dev.platform = OrmPlatform.objects.get(slug="arista_eos_cloudvision")
dev.platform = OrmPlatform.objects.get(name=CLOUDVISION_PLATFORM)
if "device_model" in attrs:
dev.device_type = nautobot.verify_device_type_object(attrs["device_model"])
if "serial" in attrs:
dev.serial = attrs["serial"]
if "version" in attrs and LIFECYCLE_MGMT:
software_lcm = self._add_software_lcm(platform=dev.platform.slug, version=attrs["version"])
software_lcm = self._add_software_lcm(platform=dev.platform.name, version=attrs["version"])
self._assign_version_to_device(diffsync=self.diffsync, device=dev, software_lcm=software_lcm)
try:
dev.validated_save()
Expand All @@ -131,7 +131,7 @@ def delete(self):
@staticmethod
def _add_software_lcm(platform: str, version: str):
"""Add OS Version as SoftwareLCM if Device Lifecycle Plugin found."""
_platform = OrmPlatform.objects.get(slug=platform)
_platform = OrmPlatform.objects.get(name=platform)
try:
os_ver = SoftwareLCM.objects.get(device_platform=_platform, version=version)
except SoftwareLCM.DoesNotExist:
Expand Down Expand Up @@ -181,7 +181,7 @@ def create(cls, diffsync, ids, attrs):
mac_address=attrs["mac_addr"],
mtu=attrs["mtu"],
mode=attrs["mode"],
status=OrmStatus.objects.get(slug=attrs["status"]),
status=OrmStatus.objects.get(name=attrs["status"]),
type=attrs["port_type"],
)
try:
Expand All @@ -208,7 +208,7 @@ def update(self, attrs):
if "mtu" in attrs:
_port.mtu = attrs["mtu"]
if "status" in attrs:
_port.status = OrmStatus.objects.get(slug=attrs["status"])
_port.status = OrmStatus.objects.get(name=attrs["status"])
if "port_type" in attrs:
_port.type = attrs["port_type"]
try:
Expand Down
9 changes: 6 additions & 3 deletions nautobot_ssot/integrations/aristacv/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ def post_migrate_create_platform(apps=global_apps, **kwargs):
"""Callback function for post_migrate() -- create Arista Platform."""
Platform = apps.get_model("dcim", "Platform")
Manufacturer = apps.get_model("dcim", "Manufacturer")
Platform.objects.get_or_create(
Platform.objects.update_or_create(
name="arista.eos.eos",
napalm_driver="eos",
manufacturer=Manufacturer.objects.get(name="Arista"),
defaults={
"napalm_driver": "eos",
"network_driver": "arista_eos",
"manufacturer": Manufacturer.objects.get(name="Arista"),
},
)

if APP_SETTINGS.get("create_controller"):
Expand Down
2 changes: 1 addition & 1 deletion nautobot_ssot/integrations/aristacv/utils/cloudvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def get_devices(client):
"fqdn": resp.value.fqdn.value,
"sw_ver": resp.value.software_version.value,
"model": resp.value.model_name.value,
"status": "active" if resp.value.streaming_status == 2 else "offline",
"status": "Active" if resp.value.streaming_status == 2 else "Offline",
"system_mac_address": resp.value.system_mac_address.value,
}
devices.append(device)
Expand Down
2 changes: 1 addition & 1 deletion nautobot_ssot/integrations/servicenow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from nautobot.core.models import BaseModel


class SSOTServiceNowConfig(BaseModel):
class SSOTServiceNowConfig(BaseModel): # pylint: disable=nb-string-field-blank-null
"""Singleton data model describing the configuration of this plugin."""

def delete(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions nautobot_ssot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@extras_features(
"custom_links",
)
class Sync(BaseModel):
class Sync(BaseModel): # pylint: disable=nb-string-field-blank-null
"""High-level overview of a data sync event/process/attempt.
Essentially an extension of the JobResult model to add a few additional fields.
Expand Down Expand Up @@ -136,7 +136,7 @@ def get_target_url(self):
)


class SyncLogEntry(BaseModel):
class SyncLogEntry(BaseModel): # pylint: disable=nb-string-field-blank-null
"""Record of a single event during a data sync operation.
Detailed sync logs are recorded in this model, rather than in JobResult.data, because
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"device_id": "JPE12345678",
"hostname": "ams01-edge-01.ntc.com",
"fqdn": "ams01-edge-01.ntc.com",
"status": "active",
"status": "Active",
"sw_ver": "4.26.5M",
"model": "DCS-7280CR2-60",
"system_mac_address": "12:34:56:78:ab:cd"
Expand All @@ -12,7 +12,7 @@
"device_id": "JPE12345679",
"hostname": "ams01-edge-02.ntc.com",
"fqdn": "ams01-edge-02.ntc.com",
"status": "active",
"status": "Active",
"sw_ver": "4.26.5M",
"model": "DCS-7280CR2-60",
"system_mac_address": "12:34:56:78:ab:ce"
Expand Down
2 changes: 1 addition & 1 deletion nautobot_ssot/tests/aristacv/test_utils_cloudvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_get_active_devices(self):
"device_id": "JPE12345678",
"hostname": "ams01-edge-01.ntc.com",
"fqdn": "ams01-edge-01.ntc.com",
"status": "active",
"status": "Active",
"sw_ver": "4.26.5M",
"model": "DCS-7280CR2-60",
"system_mac_address": "12:34:56:78:ab:cd",
Expand Down
Loading

0 comments on commit df16704

Please sign in to comment.