Skip to content

Commit

Permalink
fix: 🐛 Making suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrew82 committed Aug 21, 2024
1 parent b2896ca commit cff516a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
30 changes: 8 additions & 22 deletions nautobot_ssot/integrations/aci/diffsync/client.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
"""All interactions with ACI.""" # pylint: disable=too-many-lines, too-many-instance-attributes, too-many-arguments

# pylint: disable=invalid-name
from copy import deepcopy
from datetime import datetime, timedelta
from ipaddress import ip_network

import logging
import re
import sys
from copy import deepcopy
from datetime import datetime, timedelta
from ipaddress import ip_network

import requests
import urllib3

from .utils import (
tenant_from_dn,
ap_from_dn,
node_from_dn,
pod_from_dn,
bd_from_dn,
fex_id_from_dn,
interface_from_dn,
bd_from_dn,
node_from_dn,
pod_from_dn,
tenant_from_dn,
)


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -339,7 +337,7 @@ def get_vrfs(self, tenant: str) -> list:

def get_bds(self, tenant: str = "all") -> dict:
"""Return Bridge Domains and Subnets from the Cisco APIC."""
# TODO: rewrite using one API call -> https://10.101.40.2/api/node/class/fvBD.json?query-target=subtree&target-subtree-class=fvBD,fvRsCtx,fvSubnet
# TODO: rewrite using one API call -> https://<ip>/api/node/class/fvBD.json?query-target=subtree&target-subtree-class=fvBD,fvRsCtx,fvSubnet
if tenant == "all":
resp = self._get(
"/api/node/class/fvBD.json?query-target=subtree&target-subtree-class=fvBD,fvRsCtx,fvSubnet"
Expand Down Expand Up @@ -432,12 +430,6 @@ def get_nodes(self) -> dict:
subnet = node["topSystem"]["attributes"]["tepPool"]
else:
subnet = ""
# if node["topSystem"]["attributes"]["tepPool"] != "0.0.0.0": # nosec: B104
# subnet = node["topSystem"]["attributes"]["tepPool"]
# elif mgmt_addr:
# subnet = ip_network(mgmt_addr, strict=False).with_prefixlen
# else:
# subnet = ""
node_id = node["topSystem"]["attributes"]["id"]
node_dict[node_id]["oob_ip"] = mgmt_addr
node_dict[node_id]["subnet"] = subnet
Expand Down Expand Up @@ -491,12 +483,6 @@ def get_controllers(self) -> dict:
subnet = node["topSystem"]["attributes"]["tepPool"]
else:
subnet = ""
# if node["topSystem"]["attributes"]["tepPool"] != "0.0.0.0": # nosec: B104
# subnet = node["topSystem"]["attributes"]["tepPool"]
# elif mgmt_addr:
# subnet = ip_network(mgmt_addr, strict=False).with_prefixlen
# else:
# subnet = ""
node_id = node["topSystem"]["attributes"]["id"]
node_dict[node_id]["pod_id"] = node["topSystem"]["attributes"]["podId"]
node_dict[node_id]["oob_ip"] = mgmt_addr
Expand Down
10 changes: 3 additions & 7 deletions nautobot_ssot/integrations/aci/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from django.urls import reverse
from nautobot.core.settings_funcs import is_truthy
from nautobot.extras.jobs import BooleanVar, ChoiceVar, Job
from nautobot_ssot.jobs.base import DataMapping, DataSource

from nautobot_ssot.integrations.aci.constant import PLUGIN_CFG
from nautobot_ssot.integrations.aci.diffsync.adapters.aci import AciAdapter
from nautobot_ssot.integrations.aci.diffsync.adapters.nautobot import NautobotAdapter
from nautobot_ssot.integrations.aci.constant import PLUGIN_CFG
from nautobot_ssot.jobs.base import DataMapping, DataSource

name = "Cisco ACI SSoT" # pylint: disable=invalid-name, abstract-method

Expand Down Expand Up @@ -48,11 +49,6 @@ class Meta: # pylint: disable=too-few-public-methods
data_source_icon = static("nautobot_ssot_aci/aci.png")
description = "Sync information from ACI to Nautobot"

def __init__(self):
"""Initialize ExampleYAMLDataSource."""
super().__init__()
self.diffsync_flags = (self.diffsync_flags,)

@classmethod
def data_mappings(cls):
"""Shows mapping of models between ACI and Nautobot."""
Expand Down
4 changes: 2 additions & 2 deletions nautobot_ssot/tests/aci/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# pylint: disable=import-outside-toplevel, invalid-name
import unittest
from unittest.mock import patch, Mock
from unittest.mock import Mock, patch

from nautobot_ssot.integrations.aci.diffsync.client import AciApi, RequestHTTPError


Expand All @@ -20,7 +21,6 @@ def setUp(self):
verify=False,
site="ACI",
) # nosec
self.maxDiff = None

@patch.object(AciApi, "_handle_request")
@patch.object(AciApi, "_login")
Expand Down

0 comments on commit cff516a

Please sign in to comment.