Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Integrations for Controllers/ExternalIntegration #471

Merged
merged 49 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
393ce75
Update Diffsync to 2.0.0 and perform Linting
mattmiller87 Apr 17, 2024
1a852c7
fix: 🐛 Replace all instances of diffsync attributes with adapter.
jdrew82 May 14, 2024
44bb869
build: ⬆️ Rebuild and update dependencies for lockfile.
jdrew82 May 14, 2024
2411206
refactor: 🔥 Remove tenant_prefix from NautobotAdapter as it's unused.
jdrew82 Jun 21, 2024
c36f3cf
feat: ✨ Update ACI integration to use Controller model.
jdrew82 Jun 21, 2024
6dad7f1
build: ⬆️ Make Nautobot 2.2.0 minimum supported version.
jdrew82 Jun 21, 2024
c785eb9
fix: 🔥 Remove unused import
jdrew82 Jun 21, 2024
fdfde1f
feat: ✨ Update Device42 integration to use ExternalIntegration.
jdrew82 Jun 21, 2024
fe83472
refactor: 🔥 Remove aci_apics default_setting as no longer needed.
jdrew82 Jun 21, 2024
1c2be56
docs: 📝 Update ACI docs to reference Controller/ExternalIntegration u…
jdrew82 Jun 21, 2024
077708b
feat: ✨ Update IPFabric integration to use Controller object.
jdrew82 Jun 21, 2024
7610d4a
build: 🔥 Remove unused config settings for ACI integration.
jdrew82 Jun 21, 2024
510143a
build: 🔥 Remove IPFabric settings that are no longer used.
jdrew82 Jun 21, 2024
24d4ad8
fix: 🐛 Correct default booleans to be strings.
jdrew82 Jun 21, 2024
04e3622
refactor: ♻️ Update Nautobot Host to be pulled from env var directly.
jdrew82 Jun 21, 2024
f20262b
refactor: 🔥 Remove unused env vars
jdrew82 Jun 21, 2024
7931e54
docs: 📝 Update IPFabric documentation about using Controller/External…
jdrew82 Jun 21, 2024
8e1184d
feat: ✨ Add support for ControllerManagedDeviceGroup in ACI integration.
jdrew82 Jul 26, 2024
1127766
refactor: ♻️ Move code to get username/password from HTTP SecretsGrou…
jdrew82 Jul 26, 2024
d6f187b
feat: ✨ Update SSoT ChatOps command to use or request a Controller fo…
jdrew82 Jul 26, 2024
f3f3f33
test: 🚨 Address various linter complaints.
jdrew82 Jul 26, 2024
80a8430
refactor: ♻️ Move ControllerManagedDeviceGroup validation to utility …
jdrew82 Jul 30, 2024
4433ec9
style: Add help text to device_site Job var.
jdrew82 Jul 30, 2024
2db18d1
fix: 🐛 Correct remote_url and verify_ssl to come from ExternalIntegra…
jdrew82 Jul 30, 2024
9da9a20
fix: 🐛 Correct errors caused by rebase
jdrew82 Aug 13, 2024
fbd0695
fix: 🐛 Fix ACI signals to only try to iterate through APICs if they'r…
jdrew82 Aug 13, 2024
e69216a
fix: 🐛 Correct ObjectVar to use description instead of help_text.
jdrew82 Aug 13, 2024
fdd9b3c
fix: 🐛 Move client initialization to dunder init as init_ipf_client n…
jdrew82 Aug 13, 2024
8eddb26
style: 🚨 Sort imports
jdrew82 Aug 13, 2024
4b9cb2d
style: Change ordering of Job vars so Controller is first selection.
jdrew82 Aug 13, 2024
ba32ca7
fix: 🐛 Add check for existing ControllerManagedDeviceGroup on selecte…
jdrew82 Aug 13, 2024
05f2ff5
feat: ✨ Add controller_group attribute to Device DiffSyncModel to con…
jdrew82 Aug 13, 2024
c5bdb43
style: 🚨 Sort imports with ruff
jdrew82 Aug 13, 2024
c98e15a
style: 🚨 Formatting for black
jdrew82 Aug 14, 2024
abf54a0
revert: ⏪️ Revert IPFabric integration changes for adding Controller.
jdrew82 Aug 14, 2024
1bc39ac
build: ⬆️ Update project dependencies lockfile
jdrew82 Aug 14, 2024
f7b3170
test: 🚨 Remove unused import
jdrew82 Aug 14, 2024
207c026
build: ⏪️ Revert minimum Nautobot to 2.1.0
jdrew82 Aug 14, 2024
6ca3b4f
build: 📌 Pin django-debug-toolbar to version less than 4.4
jdrew82 Aug 14, 2024
9cf8a93
feat: ✨ Add checks for ExternalIntegration on Controller and SecretsG…
jdrew82 Aug 14, 2024
de58745
fix: 🐛 Add default value for tenant_prefix in case not defined in ext…
jdrew82 Aug 14, 2024
a4409ad
fix: 🐛 Correct var to be client.site instead of using dict key.
jdrew82 Aug 14, 2024
8df0631
fix: 🐛 Remove duplicate lines from rebase.
jdrew82 Aug 19, 2024
c3415d0
docs: 📝 Update Device42 Documentation with screenshots of ExternalInt…
jdrew82 Aug 19, 2024
9d84163
docs: ⏪️ Revert documentation changes for IPFabric integration.
jdrew82 Aug 19, 2024
b752eef
revert: ⏪️ Revert any changes to ChatOps command for Controller in IP…
jdrew82 Aug 19, 2024
2e1b146
fix: 🐛 Correct NB minimum version to 2.1.0 to match pyproject.toml an…
jdrew82 Aug 19, 2024
718b495
fix: ⏪️ Remove missed portions of container additions to IPFabric wor…
jdrew82 Aug 20, 2024
17e3acc
test: ✅ Adjust variable names to not conflict with vars in function a…
jdrew82 Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion development/development.env
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ NAUTOBOT_SSOT_ACI_TAG_DOWN_COLOR="FF3333"
NAUTOBOT_SSOT_ACI_MANUFACTURER_NAME="Cisco"
NAUTOBOT_SSOT_ACI_IGNORE_TENANTS="[mgmt,infra]"
NAUTOBOT_SSOT_ACI_COMMENTS="Created by ACI SSoT Integration"
NAUTOBOT_SSOT_ACI_SITE="Data Center"

NAUTOBOT_SSOT_ENABLE_ARISTACV="False"
NAUTOBOT_ARISTACV_CONTROLLER_SITE=""
Expand Down
26 changes: 6 additions & 20 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,8 @@
# "slack_api_token": os.getenv("SLACK_API_TOKEN"),
# "slack_signing_secret": os.getenv("SLACK_SIGNING_SECRET"),
# "session_cache_timeout": 3600,
# "ipfabric_api_token": os.getenv("IPFABRIC_API_TOKEN"),
# "ipfabric_host": os.getenv("IPFABRIC_HOST"),
# },
"nautobot_ssot": {
# URL and credentials should be configured as environment variables on the host system
"aci_apics": {x: os.environ[x] for x in os.environ if "APIC" in x},
# Tag which will be created and applied to all synchronized objects.
"aci_tag": os.getenv("NAUTOBOT_SSOT_ACI_TAG"),
"aci_tag_color": os.getenv("NAUTOBOT_SSOT_ACI_TAG_COLOR"),
Expand All @@ -161,23 +157,21 @@
"aci_ignore_tenants": os.getenv("NAUTOBOT_SSOT_ACI_IGNORE_TENANTS", "").split(","),
# The below value will appear in the Comments field on objects created in Nautobot
"aci_comments": os.getenv("NAUTOBOT_SSOT_ACI_COMMENTS"),
# Site to associate objects. Specify existing, or a new site with this name will be created.
"aci_site": os.getenv("NAUTOBOT_SSOT_ACI_SITE"),
"aristacv_apply_import_tag": is_truthy(os.getenv("NAUTOBOT_ARISTACV_IMPORT_TAG", False)),
"aristacv_apply_import_tag": is_truthy(os.getenv("NAUTOBOT_ARISTACV_IMPORT_TAG", "false")),
"aristacv_controller_site": os.getenv("NAUTOBOT_ARISTACV_CONTROLLER_SITE", ""),
"aristacv_create_controller": is_truthy(os.getenv("NAUTOBOT_ARISTACV_CREATE_CONTROLLER", False)),
"aristacv_create_controller": is_truthy(os.getenv("NAUTOBOT_ARISTACV_CREATE_CONTROLLER", "false")),
"aristacv_cvaas_url": os.getenv("NAUTOBOT_ARISTACV_CVAAS_URL", "www.arista.io:443"),
"aristacv_cvp_host": os.getenv("NAUTOBOT_ARISTACV_CVP_HOST", ""),
"aristacv_cvp_password": os.getenv("NAUTOBOT_ARISTACV_CVP_PASSWORD", ""),
"aristacv_cvp_port": os.getenv("NAUTOBOT_ARISTACV_CVP_PORT", "443"),
"aristacv_cvp_token": os.getenv("NAUTOBOT_ARISTACV_CVP_TOKEN", ""),
"aristacv_cvp_user": os.getenv("NAUTOBOT_ARISTACV_CVP_USERNAME", ""),
"aristacv_delete_devices_on_sync": is_truthy(os.getenv("NAUTOBOT_ARISTACV_DELETE_ON_SYNC", False)),
"aristacv_delete_devices_on_sync": is_truthy(os.getenv("NAUTOBOT_ARISTACV_DELETE_ON_SYNC", "false")),
"aristacv_from_cloudvision_default_device_role": "network",
"aristacv_from_cloudvision_default_device_role_color": "ff0000",
"aristacv_from_cloudvision_default_site": "cloudvision_imported",
"aristacv_hostname_patterns": [r"(?P<site>\w{2,3}\d+)-(?P<role>\w+)-\d+"],
"aristacv_import_active": is_truthy(os.getenv("NAUTOBOT_ARISTACV_IMPORT_ACTIVE", False)),
"aristacv_import_active": is_truthy(os.getenv("NAUTOBOT_ARISTACV_IMPORT_ACTIVE", "false")),
"aristacv_role_mappings": {
"bb": "backbone",
"edge": "edge",
Expand All @@ -190,7 +184,7 @@
"ams01": "Amsterdam",
"atl01": "Atlanta",
},
"aristacv_verify": is_truthy(os.getenv("NAUTOBOT_ARISTACV_VERIFY", True)),
"aristacv_verify": is_truthy(os.getenv("NAUTOBOT_ARISTACV_VERIFY", "true")),
"enable_aci": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_ACI")),
"enable_aristacv": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_ARISTACV")),
"enable_device42": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_DEVICE42")),
Expand All @@ -199,10 +193,6 @@
"enable_itential": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_ITENTIAL")),
"enable_servicenow": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_SERVICENOW")),
"hide_example_jobs": is_truthy(os.getenv("NAUTOBOT_SSOT_HIDE_EXAMPLE_JOBS")),
"device42_host": os.getenv("NAUTOBOT_SSOT_DEVICE42_HOST", ""),
"device42_username": os.getenv("NAUTOBOT_SSOT_DEVICE42_USERNAME", ""),
"device42_password": os.getenv("NAUTOBOT_SSOT_DEVICE42_PASSWORD", ""),
"device42_verify_ssl": False,
"device42_defaults": {
"site_status": "Active",
"rack_status": "Active",
Expand Down Expand Up @@ -230,13 +220,9 @@
"infoblox_password": os.getenv("NAUTOBOT_SSOT_INFOBLOX_PASSWORD"),
"infoblox_url": os.getenv("NAUTOBOT_SSOT_INFOBLOX_URL"),
"infoblox_username": os.getenv("NAUTOBOT_SSOT_INFOBLOX_USERNAME"),
"infoblox_verify_ssl": is_truthy(os.getenv("NAUTOBOT_SSOT_INFOBLOX_VERIFY_SSL", True)),
"infoblox_verify_ssl": is_truthy(os.getenv("NAUTOBOT_SSOT_INFOBLOX_VERIFY_SSL", "true")),
"infoblox_wapi_version": os.getenv("NAUTOBOT_SSOT_INFOBLOX_WAPI_VERSION", "v2.12"),
"infoblox_network_view": os.getenv("NAUTOBOT_SSOT_INFOBLOX_NETWORK_VIEW", ""),
"ipfabric_api_token": os.getenv("NAUTOBOT_SSOT_IPFABRIC_API_TOKEN"),
"ipfabric_host": os.getenv("NAUTOBOT_SSOT_IPFABRIC_HOST"),
"ipfabric_ssl_verify": is_truthy(os.getenv("NAUTOBOT_SSOT_IPFABRIC_SSL_VERIFY", "False")),
"nautobot_host": os.getenv("NAUTOBOT_HOST"),
"servicenow_instance": os.getenv("SERVICENOW_INSTANCE", ""),
"servicenow_password": os.getenv("SERVICENOW_PASSWORD", ""),
"servicenow_username": os.getenv("SERVICENOW_USERNAME", ""),
Expand Down
34 changes: 8 additions & 26 deletions docs/admin/integrations/aci_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ pip install nautobot-ssot[aci]

## Configuration

!!! note
Legacy configuration settings defined in `nautobot_config.py` for `aci_apics` is now deprecated. All information related to communicating to an APIC has been updated to use the Controller and its related ExternalIntegration objects.

Integration behavior can be controlled with the following settings:

| Setting Name<br>(* required) | Type | Description |
|---|:---:|---|
| <p>aci_apics_*</p> | | Per-APIC settings. See per-APIC settings section for details. |
| aci_tag* | _String_ | Tag which is created and applied to all <br>synchronized objects. |
| aci_tag_color* | _String_ | Hex color code used for the tag. |
| aci_tag_up* | _String_ | Tag indicating the state applied to synchronized <br>interfaces. |
Expand All @@ -33,8 +35,6 @@ Below is an example snippet from `nautobot_config.py` that demonstrates how to e
PLUGINS_CONFIG = {
"nautobot_ssot": {
"enable_aci": True,
# URL and credentials should be configured as environment variables on the host system
"aci_apics": {x: os.environ[x] for x in os.environ if "APIC" in x},
# Tag which will be created and applied to all synchronized objects.
"aci_tag": "ACI",
"aci_tag_color": "0047AB",
Expand All @@ -54,36 +54,21 @@ PLUGINS_CONFIG = {

### Per-APIC settings

The APIC URL and credentials need to be created as environment variables on the host system.

You can configure multiple APIC instances for synchronization. To do this, append `_` character, followed by an identifier, to the names of environment variables.

In the example below, configured APIC uses `NTC` for an identifier. Instead of `NTC` you could, for example, use `CHCG01` to configure an APIC instance in your Chicago facility.

```bash
export NAUTOBOT_APIC_BASE_URI_NTC=https://aci.cloud.networktocode.com
export NAUTOBOT_APIC_USERNAME_NTC=admin
export NAUTOBOT_APIC_PASSWORD_NTC=not_so_secret_password
export NAUTOBOT_APIC_VERIFY_NTC=False
export NAUTOBOT_APIC_SITE_NTC="NTC ACI"
export NAUTOBOT_APIC_TENANT_PREFIX_NTC="NTC_ACI"
```

The identifier is used to select APIC from the SSoT dashboard when initiating a synchronization job:
All APIC specific settings have been updated to use the Controller and related ExternalIntegration objects. The ExternalIntegration object that is assigned to the Controller will define the APIC base URL, user credentials, and SSL verification. It will also have a `tenant_prefix` key in the `extra_config` section of the ExternalIntegration to define the Tenant prefix.

![image](../../images/aci-dashboard-apic.png)
The `aci_apics` setting from the `nautobot_config.py` file is no longer used and any configuration found for it will be automatically migrated into a Controller and an ExternalIntegration object.

## Nautobot Objects Affected by Settings

A Site will be created in Nautobot with the name specified in the `NAUTOBOT_APIC_SITE` environment variable and resources created by the integration will be assigned to this site.
The Job form has been updated to allow specifying a Location for the imported objects. If that is left unspecified then the Location associated to the specified Controller will be used.

Tenants imported from ACI will be prepended with the unique name specified by the corresponding `TENANT_PREFIX` variable. This uniquely identifies tenants which might have the same name, but belong to two different APIC clusters.
Tenants imported from ACI will be prefixed with the unique name specified by the corresponding `tenant_prefix` key in the Controller's associated ExternalIntegration `extra_config`. This uniquely identifies tenants which might have the same name, but belong to two different APIC clusters.

## Configuring Device Templates

To create a new Nautobot Device Type mapping to a specific ACI leaf or spine switch model you need to provide YAML file describing that model. This model definition includes interface template with the ports and transceiver types (ex. 10GE SFP+) specification.

The YAML files need to be placed in the `nautobot_ssot/integrations/aci/diffsync/device-types` directory. Their names need to match the model name as it appears in the ACI Fabric Membership area of the APIC dashboard.
The YAML files need to be placed in the `nautobot_ssot/integrations/aci/diffsync/device-types` directory. Their names need to match the model name as it appears in the ACI Fabric Membership area of the APIC dashboard.

For example, given a Model name of `N9K-C9396PX` as shown below, the YAML file should be named `N9K-C9396PX.yaml`.

Expand Down Expand Up @@ -114,15 +99,13 @@ There are example YAML files for a few common switch models in `nautobot_ssot/in
PLUGINS_CONFIG = {
# "nautobot_ssot_aci": { REMOVE THIS APP CONFIGURATION
# MOVE CONFIGURATION TO `nautobot_ssot` SECTION
# "apics": {x: os.environ[x] for x in os.environ if "NAUTOBOT_APIC" in x},
# "tag": "ACI",
# ...
# }
"nautobot_ssot": {
# Enable Cisco ACI integration
"enable_aci": True,
# Following lines are moved from `nautobot_ssot_aci` and prefixed with `aci_`
"aci_apics": {x: os.environ[x] for x in os.environ if "NAUTOBOT_APIC" in x},
"aci_tag": "ACI",
...
}
Expand All @@ -133,5 +116,4 @@ There are example YAML files for a few common switch models in `nautobot_ssot/in
Configuration keys are prefixed with `aci_`.

!!! note
Environment variables defining APICs access must contain `APIC`.
Other environment variables for this integration are prefixed with `NAUTOBOT_SSOT_ACI_`.
21 changes: 13 additions & 8 deletions docs/admin/integrations/device42_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ pip install nautobot-ssot[device42]

## Configuration

Integration behavior can be controlled with the following settings:
Access to your Device42 instance is defined using the [ExternalIntegration](https://docs.nautobot.com/projects/core/en/stable/user-guide/platform-functionality/externalintegration/) model which allows you to utilize this integration with multiple instances concurrently. Please bear in mind that it will synchronize all data 1:1 with the specified instance to match exactly, meaning it will delete data missing from an instance, unless you have the `device42_delete_on_sync` option set to False. Each ExternalIntegration must specify a SecretsGroup that contains Secrets that contain the Device42 Username and Password to authenticate against that instance. You can find Secrets and SecretsGroups available under the Secrets menu.

| Configuration Variable | Type | Usage |
| ---------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| device42_host | string | This defines the FQDN of the Device42 instance, ie `https://device42.example.com`. |
| device42_username | string | This defines the username of the account used to connect to the Device42 API endpoint. |
| device42_password | string | This defines the password of the account used to connect to the Device42 API endpoint. |
| device42_verify | boolean | This denotes whether SSL validation of the Device42 endpoint should be enabled or not. |
![Device42 Username](../../images/device42_username.png)

When creating Sites and Racks in Nautobot it is required to define a Status for each. It is also required to define a Role for your Device when created. You may define the default for each of those objects being imported with the respective values in your `nautobot_config.py` file.
![Device42 Password](../../images/device42_password.png)

![Device42 SecretsGroup](../../images/device42_secretsgroup.png)

Please note that is it imperative for the SecretsGroup used with the specified Controller uses HTTP(S) Access type and Username and Password respectively for each Secret. Also note that the name of the Secrets or SecretsGroup are irrelevant but are recommended to be relevant to the instance in question.

Once the SecretsGroup is created you'll need to create the ExternalIntegration. You'll find this under the Extensibility menu.

![Device42 ExternalIntegration](../../images/device42_externalintegration.png)

When creating Locations and Racks in Nautobot it is required to define a Status for each. It is also required to define a Role for your Device when created. You may define the default for each of those objects being imported with the respective values in your `nautobot_config.py` file.

| Configuration Variable | Type | Usage | Default |
| --------------------------------------------------- | ------ | ---------------------------------------------------------- | -------------------- |
Expand Down
Binary file added docs/images/device42_externalintegration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/device42_job-form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/device42_password.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/device42_secretsgroup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/device42_username.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/user/integrations/device42.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ From the Dashboard, you can also view more information about the App by clicking

![Detail View](../../images/device42_detail-view.png)

To start the synchronization, simply click the `Sync Now` button on the Dashboard to start the Job. You should be presented with the Job form below:
To start the synchronization, simply select the ExternalIntegration that corresponds to your desired instance and then click the `Sync Now` button on the Dashboard to start the Job. You should be presented with the Job form below:

![Job Form](../../images/device42_job-form.png)

Expand Down
14 changes: 6 additions & 8 deletions nautobot_ssot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""App declaration for nautobot_ssot."""

import logging
import os
from importlib import metadata


import packaging
from django.conf import settings
from nautobot.extras.plugins import NautobotAppConfig
from nautobot.core.settings_funcs import is_truthy
import packaging
from nautobot.extras.plugins import NautobotAppConfig

from nautobot_ssot.integrations.utils import each_enabled_integration_module
from nautobot_ssot.utils import logger

logger = logging.getLogger("nautobot.ssot")
__version__ = metadata.version(__name__)


Expand All @@ -25,8 +25,7 @@
]

_MIN_NAUTOBOT_VERSION = {
"nautobot_ssot_aristacv": "2.1",
"nautobot_ssot_infoblox": "2.1",
"nautobot_ssot_aci": "2.2",
}


Expand Down Expand Up @@ -69,10 +68,9 @@ class NautobotSSOTAppConfig(NautobotAppConfig):
description = "Nautobot app that enables Single Source of Truth. Allows users to aggregate distributed data sources and/or distribute Nautobot data to other data sources such as databases and SDN controllers."
base_url = "ssot"
required_settings = []
min_version = "2.0.0"
min_version = "2.1.0"
max_version = "2.9999"
default_settings = {
"aci_apics": [],
"aci_tag": "",
"aci_tag_color": "",
"aci_tag_up": "",
Expand Down
21 changes: 9 additions & 12 deletions nautobot_ssot/integrations/aci/diffsync/adapters/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# pylint: disable=duplicate-code


import logging
import os
import re
Expand All @@ -20,7 +19,6 @@
from nautobot_ssot.integrations.aci.diffsync.models import NautobotInterface
from nautobot_ssot.integrations.aci.diffsync.models import NautobotIPAddress
from nautobot_ssot.integrations.aci.diffsync.models import NautobotPrefix
from nautobot_ssot.integrations.aci.diffsync.client import AciApi
from nautobot_ssot.integrations.aci.diffsync.utils import load_yamlfile


Expand Down Expand Up @@ -52,7 +50,7 @@ class AciAdapter(Adapter):
"ip_address",
]

def __init__(self, *args, job=None, sync=None, client, **kwargs):
def __init__(self, *args, job=None, sync=None, client, tenant_prefix, **kwargs):
"""Initialize ACI.

Args:
Expand All @@ -63,15 +61,9 @@ def __init__(self, *args, job=None, sync=None, client, **kwargs):
super().__init__(*args, **kwargs)
self.job = job
self.sync = sync
self.conn = AciApi(
username=client["username"],
password=client["password"],
base_uri=client["base_uri"],
verify=client["verify"],
site=client["site"],
)
self.site = client.get("site")
self.tenant_prefix = client.get("tenant_prefix")
self.conn = client
self.site = client.site
self.tenant_prefix = tenant_prefix
self.nodes = self.conn.get_nodes()
self.controllers = self.conn.get_controllers()
self.nodes.update(self.controllers)
Expand Down Expand Up @@ -426,6 +418,11 @@ def load_devices(self):
pod_id=value["pod_id"],
site=self.site,
site_tag=self.site,
controller_group=(
self.job.apic.controller_managed_device_group.name
if self.job.apic.controller_managed_device_group
else ""
),
)
self.add(new_device)

Expand Down
10 changes: 6 additions & 4 deletions nautobot_ssot/integrations/aci/diffsync/adapters/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@ class NautobotAdapter(Adapter):
"ip_address",
]

def __init__(self, *args, job=None, sync=None, client, **kwargs):
def __init__(self, *args, job=None, sync=None, site_name: str, **kwargs):
"""Initialize Nautobot.

Args:
job (object, optional): Nautobot job. Defaults to None.
sync (object, optional): Nautobot DiffSync. Defaults to None.
client (object): ACI credentials.
site_name (str): Name of Site to filter objects on.
"""
super().__init__(*args, **kwargs)
self.job = job
self.sync = sync
self.site = client.get("site")
self.site = site_name
self.site_tag = Tag.objects.get_or_create(name=self.site)[0]
self.tenant_prefix = client.get("tenant_prefix")

def sync_complete(self, source: Adapter, *args, **kwargs):
"""Clean up function for DiffSync sync.
Expand Down Expand Up @@ -185,6 +184,9 @@ def load_devices(self):
node_id=nbdevice.custom_field_data["aci_node_id"],
pod_id=nbdevice.custom_field_data["aci_pod_id"],
site_tag=self.site,
controller_group=(
nbdevice.controller_managed_device_group.name if nbdevice.controller_managed_device_group else ""
),
)
self.add(_device)

Expand Down
Loading
Loading