Skip to content

Commit

Permalink
Merge pull request #429 from nautobot/develop
Browse files Browse the repository at this point in the history
Release v2.6.0
  • Loading branch information
jdrew82 authored Apr 16, 2024
2 parents fd32997 + a9c2123 commit bd4aa05
Show file tree
Hide file tree
Showing 39 changed files with 1,568 additions and 635 deletions.
1 change: 1 addition & 0 deletions changes/427.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Created release for 2.6.0
89 changes: 89 additions & 0 deletions development/run_example_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""Executes a job locally for testing purposes.
To run this script use the following command:
```
invoke nbshell \
--plain \
--file development/run_example_job.py \
--env RUN_SSOT_TARGET_JOB=False \
--env RUN_SSOT_JOB_DRY_RUN=True
```
Passing environment variables to the script is optional. The script will default to running the data source job with a dry run enabled.
"""

import json
import os

from django.core.management import call_command
from nautobot.core.settings_funcs import is_truthy
from nautobot.extras.choices import SecretsGroupAccessTypeChoices
from nautobot.extras.choices import SecretsGroupSecretTypeChoices
from nautobot.extras.models import ExternalIntegration
from nautobot.extras.models import Job
from nautobot.extras.models import Secret
from nautobot.extras.models import SecretsGroup
from nautobot.extras.models import SecretsGroupAssociation

_TOKEN = 40 * "a"
os.environ["NAUTOBOT_DEMO_TOKEN"] = _TOKEN

_NAUTOBOT_DEMO_URL = "https://demo.nautobot.com"
_DRY_RUN = is_truthy(os.getenv("RUN_SSOT_JOB_DRY_RUN", "True"))

module_name = "nautobot_ssot.jobs.examples"
is_target_job = is_truthy(os.getenv("RUN_SSOT_TARGET_JOB", "False"))
job_class_name = "ExampleDataTarget" if is_target_job else "ExampleDataSource"

job = Job.objects.get(module_name=module_name, job_class_name=job_class_name)
if not job.enabled:
job.enabled = True
job.validated_save()

nautobot_demo, created = ExternalIntegration.objects.get_or_create(
name="Nautobot Demo",
defaults={
"remote_url": _NAUTOBOT_DEMO_URL,
"verify_ssl": False,
},
)

if created:
secret = Secret.objects.create(
name="nautobot-demo-token",
provider="environment-variable",
parameters={"variable": "NAUTOBOT_DEMO_TOKEN"},
)
secrets_group = SecretsGroup.objects.create(name="Nautobot Demo Group")
SecretsGroupAssociation.objects.create(
secret=secret,
secrets_group=secrets_group,
access_type=SecretsGroupAccessTypeChoices.TYPE_HTTP,
secret_type=SecretsGroupSecretTypeChoices.TYPE_TOKEN,
)
nautobot_demo.secrets_group = secrets_group
nautobot_demo.validated_save()

data: dict = {
"debug": True,
"dryrun": _DRY_RUN,
"memory_profiling": False,
}

if is_target_job:
data["target"] = str(nautobot_demo.pk)
data["target_url"] = _NAUTOBOT_DEMO_URL
data["target_token"] = _TOKEN
else:
data["source"] = str(nautobot_demo.pk)
data["source_url"] = _NAUTOBOT_DEMO_URL
data["source_token"] = _TOKEN

call_command(
"runjob",
f"{module_name}.{job_class_name}",
data=json.dumps(data),
username="admin",
local=True, # Enable to run the job locally (not as a celery task)
)
6 changes: 3 additions & 3 deletions docs/admin/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ sudo systemctl restart nautobot nautobot-worker nautobot-scheduler

The app behavior can be controlled with the following list of settings:

| Key | Example | Default | Description |
| ------------------- | ------- | ------- | ---------------------------------------------------------- |
| `hide_example_jobs` | `True` | `False` | A boolean to represent whether or display the example job. |
| Key | Example | Default | Description |
| ------------------- | ------- | ------- | ----------------------------------------------------------------- |
| `hide_example_jobs` | `True` | `False` | A boolean to represent whether or not to display the example job. |

## Integrations Configuration

Expand Down
55 changes: 55 additions & 0 deletions docs/admin/release_notes/version_1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,58 @@
- [161](https://github.com/nautobot/nautobot-app-ssot/pull/161) - Reverts ChatOps dependency removal by @snaselj
- [213](https://github.com/nautobot/nautobot-app-ssot/pull/213) - fix: :bug: Several fixes in the ACI integration by @chadell
- [205](https://github.com/nautobot/nautobot-app-ssot/pull/205) - Migrate PR #164 from Arista Child Repo by @qduk

## v1.6.1 - 2024-02-21

## Fixed

- [243](https://github.com/nautobot/nautobot-app-ssot/pull/243) - Fix Infoblox import_subnet for ltm-1.6 by @jdrew82
- [261](https://github.com/nautobot/nautobot-app-ssot/pull/261) - Fix Device42 documentation. by @jdrew82

## Changed

- [245](https://github.com/nautobot/nautobot-app-ssot/pull/245) - IPFabric integration settings updates by @alhogan

- [357](https://github.com/nautobot/nautobot-app-ssot/pull/357) - Backport contrib changes to LTM by @Kircheneer
- [361](https://github.com/nautobot/nautobot-app-ssot/pull/361) - Backport of #350 by @Kircheneer
- [363](https://github.com/nautobot/nautobot-app-ssot/pull/363) - Backport #362 by @Kircheneer

## v1.6.2 - 2024-03-12

## Fixed

- [386](https://github.com/nautobot/nautobot-app-ssot/pull/386) - Fixes bug in backport of contrib custom relationship handling

## Changed

- [386](https://github.com/nautobot/nautobot-app-ssot/pull/386) - Improves error handling in contrib (backport of #374)
- [373](https://github.com/nautobot/nautobot-app-ssot/pull/373) - Change contrib.NautobotModel.get_from_db to use a PK (backport of #371)

## v1.6.3 - 2024-03-20

## Fixed

- [396](https://github.com/nautobot/nautobot-app-ssot/pull/396) - Fix custom one-to-many relationships (backport of #393)
- [396](https://github.com/nautobot/nautobot-app-ssot/pull/396) - Use `typing.get_args` in favor of accessing `__args__` directly (backport of #390)
- [396](https://github.com/nautobot/nautobot-app-ssot/pull/396) - Fixed issue with generic relationships and `NautobotAdapter.load` (backport of #388)
- [396](https://github.com/nautobot/nautobot-app-ssot/pull/396) - Allow foreign keys inside of many to many relationships (backport of #377)

## Housekeeping

- Replicate module and test module structure for contrib code in LTM branch

## v1.6.4 - 2024-04-16

## Fixed

- [243](https://github.com/nautobot/nautobot-app-ssot/pull/243) - Fix Infoblox import_subnet for ltm-1.6 by @jdrew82
- [261](https://github.com/nautobot/nautobot-app-ssot/pull/261) - Fix Device42 documentation. by @jdrew82
- [419](https://github.com/nautobot/nautobot-app-ssot/pull/419) - Fix Device42 Plugin Settings for LTM by @jdrew82

## Changed

- [245](https://github.com/nautobot/nautobot-app-ssot/pull/245) - IPFabric integration settings updates by @alhogan
- [357](https://github.com/nautobot/nautobot-app-ssot/pull/357) - backport contrib changes to LTM by @Kircheneer
- [361](https://github.com/nautobot/nautobot-app-ssot/pull/361) - Backport of #350 by @Kircheneer
- [363](https://github.com/nautobot/nautobot-app-ssot/pull/363) - Backport #362 by @Kircheneer
- [373](https://github.com/nautobot/nautobot-app-ssot/pull/373) - change contrib.NautobotModel.get_from_db to use a PK by @Kircheneer
25 changes: 25 additions & 0 deletions docs/admin/release_notes/version_2.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# v2.6 Release Notes

## [v2.6.0 (2024-04-16)](https://github.com/nautobot/nautobot-app-ssot/releases/tag/v2.6.0)

### Added

- [#367](https://github.com/nautobot/nautobot-app-ssot/issues/367) - Added support of Roles, Platforms, Manufacturers, DeviceTypes, and Devices to example Jobs.

### Changed

- [#398](https://github.com/nautobot/nautobot-app-ssot/issues/398) - Changed Arista Cloud Vision jobs to optionally use ExternalIntegration.
- [#414](https://github.com/nautobot/nautobot-app-ssot/issues/414) - Changed IPFabric interface media matching to fall back on interface names.

### Fixed

- [#367](https://github.com/nautobot/nautobot-app-ssot/issues/367) - Fixed issues with example Jobs.
- [#407](https://github.com/nautobot/nautobot-app-ssot/issues/407) - Fixed logic check for 'hide_example_jobs' when defined, and also set to False.
- [#409](https://github.com/nautobot/nautobot-app-ssot/issues/409) - Fixed tagging and custom field updates for Nautobot objects synced to/from Infoblox.
- [#413](https://github.com/nautobot/nautobot-app-ssot/issues/413) - Fixed method of retrieving objects from IPFabric's technology categories.

### Housekeeping

- [#418](https://github.com/nautobot/nautobot-app-ssot/issues/418) - Unpins multiple dependencies.
- [#421](https://github.com/nautobot/nautobot-app-ssot/issues/421) - Opened prometheus-client dependency range and removed direct drf-spectacular dependency.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ nav:
- Compatibility Matrix: "admin/compatibility_matrix.md"
- Release Notes:
- "admin/release_notes/index.md"
- v2.6: "admin/release_notes/version_2.6.md"
- v2.5: "admin/release_notes/version_2.5.md"
- v2.4: "admin/release_notes/version_2.4.md"
- v2.3: "admin/release_notes/version_2.3.md"
Expand Down
1 change: 1 addition & 0 deletions nautobot_ssot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class NautobotSSOTAppConfig(NautobotAppConfig):
"aristacv_from_cloudvision_default_site": "",
"aristacv_hostname_patterns": [],
"aristacv_import_active": False,
"aristacv_external_integration_name": "",
"aristacv_role_mappings": {},
"aristacv_site_mappings": {},
"aristacv_verify": True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
"""Storage of data that will not change throughout the life cycle of the application."""

from django.conf import settings


def _read_settings() -> dict:
config = settings.PLUGINS_CONFIG["nautobot_ssot"]
return config


APP_SETTINGS = _read_settings()
ARISTA_PLATFORM = "arista.eos.eos"
CLOUDVISION_PLATFORM = "Arista EOS-CloudVision"
DEFAULT_APPLY_IMPORT_TAG = False
DEFAULT_CREATE_CONTROLLER = False
DEFAULT_CVAAS_URL = "https://www.arista.io"
DEFAULT_DELETE_DEVICES_ON_SYNC = False
DEFAULT_DEVICE_ROLE = "network"
DEFAULT_DEVICE_ROLE_COLOR = "ff0000"
DEFAULT_DEVICE_STATUS = "cloudvision_imported"
DEFAULT_DEVICE_STATUS_COLOR = "ff0000"
DEFAULT_IMPORT_ACTIVE = False
DEFAULT_SITE = "cloudvision_imported"
DEFAULT_VERIFY_SSL = True

PORT_TYPE_MAP = {
"xcvr1000BaseT": "1000base-t",
Expand Down Expand Up @@ -83,7 +87,3 @@ def _read_settings() -> dict:
"400GBASE-2FR4": "400gbase-x-osfp",
"400GBASE-ZR": "400gbase-x-qsfpdd",
}

CLOUDVISION_PLATFORM = "Arista EOS-CloudVision"

ARISTA_PLATFORM = "arista.eos.eos"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from diffsync import DiffSync
from diffsync.exceptions import ObjectAlreadyExists, ObjectNotFound

from nautobot_ssot.integrations.aristacv.constant import APP_SETTINGS
from nautobot_ssot.integrations.aristacv.diffsync.models.cloudvision import (
CloudvisionCustomField,
CloudvisionDevice,
Expand All @@ -17,6 +16,7 @@
CloudvisionIPAddress,
CloudvisionIPAssignment,
)
from nautobot_ssot.integrations.aristacv.types import CloudVisionAppConfig
from nautobot_ssot.integrations.aristacv.utils import cloudvision


Expand All @@ -41,8 +41,13 @@ def __init__(self, *args, job=None, conn: cloudvision.CloudvisionApi, **kwargs):

def load_devices(self):
"""Load devices from CloudVision."""
if APP_SETTINGS.get("aristacv_create_controller"):
cvp_version = cloudvision.get_cvp_version()
config: CloudVisionAppConfig = self.job.app_config
if config.hostname_patterns and not (config.site_mappings and config.role_mappings):
self.job.logger.warning(
"Configuration found for aristacv_hostname_patterns but no aristacv_site_mappings or aristacv_role_mappings. Please ensure your mappings are defined."
)
if config.create_controller:
cvp_version = cloudvision.get_cvp_version(config)
cvp_ver_cf = self.cf(name="arista_eos", value=cvp_version, device_name="CloudVision")
try:
self.add(cvp_ver_cf)
Expand Down Expand Up @@ -258,10 +263,4 @@ def load_device_tags(self, device):

def load(self):
"""Load devices and associated data from CloudVision."""
if APP_SETTINGS.get("aristacv_hostname_patterns") and not (
APP_SETTINGS.get("aristacv_site_mappings") and APP_SETTINGS.get("aristacv_role_mappings")
):
self.job.logger.warning(
"Configuration found for aristacv_hostname_patterns but no aristacv_site_mappings or aristacv_role_mappings. Please ensure your mappings are defined."
)
self.load_devices()
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from diffsync import DiffSync
from diffsync.exceptions import ObjectNotFound, ObjectAlreadyExists

from nautobot_ssot.integrations.aristacv.constant import APP_SETTINGS
from nautobot_ssot.integrations.aristacv.diffsync.models.nautobot import (
NautobotDevice,
NautobotCustomField,
Expand All @@ -21,6 +20,7 @@
NautobotIPAssignment,
NautobotPort,
)
from nautobot_ssot.integrations.aristacv.types import CloudVisionAppConfig
from nautobot_ssot.integrations.aristacv.utils import nautobot


Expand Down Expand Up @@ -166,8 +166,9 @@ def sync_complete(self, source: DiffSync, *args, **kwargs):
self.job.logger.warning(f"Deletion failed for protected object: {nautobot_object}. {err}")
self.objects_to_delete[grouping] = []

config: CloudVisionAppConfig = self.job.app_config # type: ignore
# if Controller is created we need to ensure all imported Devices have RelationshipAssociation to it.
if APP_SETTINGS.get("aristacv_create_controller"):
if config.create_controller:
self.job.logger.info("Creating Relationships between CloudVision and connected Devices.")
controller_relation = OrmRelationship.objects.get(label="Controller -> Device")
device_ct = ContentType.objects.get_for_model(OrmDevice)
Expand Down
Loading

0 comments on commit bd4aa05

Please sign in to comment.