From b9fa8c133a7173538bb16b73ef7352050d869055 Mon Sep 17 00:00:00 2001 From: Jeff Kala Date: Fri, 24 May 2024 09:11:28 -0500 Subject: [PATCH 1/4] add unittest v1 --- .../nornir_plays/command_getter.py | 12 +- .../nornir_plays/formatter.py | 152 ++- .../nornir_plays/processor.py | 2 +- .../mock/cisco_ios/command_getter_result.json | 503 ++++++++ .../tests/mock/mock_cisco_ios.yml | 116 ++ .../tests/mock/post_results.py | 985 -------------- .../tests/mock/pre_results.py | 1129 ----------------- .../test_nornir_plays/test_command_getter.py | 169 +++ .../tests/test_nornir_plays/test_formatter.py | 353 ++++++ 9 files changed, 1249 insertions(+), 2172 deletions(-) create mode 100755 nautobot_device_onboarding/tests/mock/cisco_ios/command_getter_result.json create mode 100755 nautobot_device_onboarding/tests/mock/mock_cisco_ios.yml delete mode 100755 nautobot_device_onboarding/tests/mock/post_results.py delete mode 100755 nautobot_device_onboarding/tests/mock/pre_results.py create mode 100755 nautobot_device_onboarding/tests/test_nornir_plays/test_command_getter.py create mode 100755 nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py diff --git a/nautobot_device_onboarding/nornir_plays/command_getter.py b/nautobot_device_onboarding/nornir_plays/command_getter.py index ee0581d5..b302f0e8 100755 --- a/nautobot_device_onboarding/nornir_plays/command_getter.py +++ b/nautobot_device_onboarding/nornir_plays/command_getter.py @@ -51,7 +51,17 @@ def _get_commands_to_run(yaml_parsed_info, sync_vlans, sync_vrfs): """Using merged command mapper info and look up all commands that need to be run.""" all_commands = [] for key, value in yaml_parsed_info.items(): - if not key.startswith("_metadata"): + if key == "pre_processor": + for _, v in value.items(): + current_root_key = v.get("commands") + if isinstance(current_root_key, list): + # Means their is any "nested" structures. e.g multiple commands + for command in v["commands"]: + all_commands.append(command) + else: + if isinstance(current_root_key, dict): + all_commands.append(current_root_key) + else: # Deduplicate commands + parser key current_root_key = value.get("commands") if isinstance(current_root_key, list): diff --git a/nautobot_device_onboarding/nornir_plays/formatter.py b/nautobot_device_onboarding/nornir_plays/formatter.py index e1082cd1..de6ef86a 100755 --- a/nautobot_device_onboarding/nornir_plays/formatter.py +++ b/nautobot_device_onboarding/nornir_plays/formatter.py @@ -1,6 +1,7 @@ """Command Extraction and Formatting or SSoT Based Jobs.""" import json +from json.decoder import JSONDecodeError import logging from django.template import engines @@ -38,67 +39,74 @@ def get_django_env(): return jinja_env +def process_empty_result(iterable_type): + """Helper to map iterable_type on an empty result.""" + iterable_mapping = { + "dict": {}, + "str": "", + } + return iterable_mapping.get(iterable_type, []) + + +def normalize_processed_data(processed_data, iterable_type): + """Helper to normalize the processed data returned from jdiff/jmespath.""" + # If processed_data is an empty data structure, return default based on iterable_type + if not processed_data: + return process_empty_result(iterable_type) + if isinstance(processed_data, str): + try: + # If processed_data is a json string try to load it into a python datatype. + post_processed_data = json.loads(processed_data) + except (JSONDecodeError, TypeError): + post_processed_data = processed_data + else: + post_processed_data = processed_data + if isinstance(post_processed_data, list) and len(post_processed_data) == 1: + if isinstance(post_processed_data[0], str): + post_processed_data = post_processed_data[0] + else: + if isinstance(post_processed_data[0], dict): + if iterable_type: + if iterable_type == "dict": + post_processed_data = post_processed_data[0] + else: + post_processed_data = post_processed_data[0] + return post_processed_data + + def extract_and_post_process(parsed_command_output, yaml_command_element, j2_data_context, iter_type, job_debug): """Helper to extract and apply post_processing on a single element.""" logger = logger = setup_logger("DEVICE_ONBOARDING_ETL_LOGGER", job_debug) # if parsed_command_output is an empty data structure, no need to go through all the processing. - if parsed_command_output: - j2_env = get_django_env() - jpath_template = j2_env.from_string(yaml_command_element["jpath"]) - j2_rendered_jpath = jpath_template.render(**j2_data_context) - logger.debug("Post Rendered Jpath: %s", j2_rendered_jpath) + if not parsed_command_output: + return parsed_command_output, normalize_processed_data(parsed_command_output, iter_type) + j2_env = get_django_env() + # This just renders the jpath itself if any interpolation is needed. + jpath_template = j2_env.from_string(yaml_command_element["jpath"]) + j2_rendered_jpath = jpath_template.render(**j2_data_context) + logger.debug("Post Rendered Jpath: %s", j2_rendered_jpath) + try: if isinstance(parsed_command_output, str): - parsed_command_output = json.loads(parsed_command_output) - try: - extracted_value = extract_data_from_json(parsed_command_output, j2_rendered_jpath) - except TypeError as err: - logger.debug("Error occurred during extraction: %s", err) - extracted_value = [] - pre_processed_extracted = extracted_value - if yaml_command_element.get("post_processor"): - # j2 context data changes obj(hostname) -> extracted_value for post_processor - j2_data_context["obj"] = extracted_value - template = j2_env.from_string(yaml_command_element["post_processor"]) - extracted_processed = template.render(**j2_data_context) - else: - extracted_processed = extracted_value - if isinstance(extracted_processed, str): try: - post_processed_data = json.loads(extracted_processed) - except Exception: - post_processed_data = extracted_processed - else: - post_processed_data = extracted_processed - if isinstance(post_processed_data, list) and len(post_processed_data) == 0: - # means result was empty, change empty result to iterater_type if applicable. - if iter_type: - if iter_type == "dict": - post_processed_data = {} - if iter_type == "str": - post_processed_data = "" - if isinstance(post_processed_data, list) and len(post_processed_data) == 1: - if isinstance(post_processed_data[0], str): - post_processed_data = post_processed_data[0] - else: - if isinstance(post_processed_data[0], dict): - if iter_type: - if iter_type == "dict": - post_processed_data = post_processed_data[0] - else: - post_processed_data = post_processed_data[0] - logger.debug("Pre Processed Extracted: %s", pre_processed_extracted) - logger.debug("Post Processed Data: %s", post_processed_data) - return pre_processed_extracted, post_processed_data - if iter_type: - if iter_type == "dict": - post_processed_data = {} - if iter_type == "str": - post_processed_data = "" + parsed_command_output = json.loads(parsed_command_output) + except (JSONDecodeError, TypeError): + logger.debug("Parsed Command Output is a string but not jsonable: %s", parsed_command_output) + extracted_value = extract_data_from_json(parsed_command_output, j2_rendered_jpath) + except TypeError as err: + logger.debug("Error occurred during extraction: %s setting default extracted value to []", err) + extracted_value = [] + pre_processed_extracted = extracted_value + if yaml_command_element.get("post_processor"): + # j2 context data changes obj(hostname) -> extracted_value for post_processor + j2_data_context["obj"] = extracted_value + template = j2_env.from_string(yaml_command_element["post_processor"]) + extracted_processed = template.render(**j2_data_context) else: - post_processed_data = [] - logger.debug("Pre Processed Extracted: %s", parsed_command_output) + extracted_processed = extracted_value + post_processed_data = normalize_processed_data(extracted_processed, iter_type) + logger.debug("Pre Processed Extracted: %s", pre_processed_extracted) logger.debug("Post Processed Data: %s", post_processed_data) - return parsed_command_output, post_processed_data + return pre_processed_extracted, post_processed_data def perform_data_extraction(host, command_info_dict, command_outputs_dict, job_debug): @@ -106,12 +114,38 @@ def perform_data_extraction(host, command_info_dict, command_outputs_dict, job_d result_dict = {} sync_vlans = host.defaults.data.get("sync_vlans", False) sync_vrfs = host.defaults.data.get("sync_vrfs", False) + get_context_from_pre_processor = {} + if command_info_dict.get("pre_processor"): + # pre_processor: + # vlan_map: + # commands: + # - command: "show vlan" + # parser: "textfsm" + # jpath: "[*].{id: vid, name: name}" + for pre_processor_name, field_data in command_info_dict["pre_processor"].items(): + if isinstance(field_data["commands"], dict): + # only one command is specified as a dict force it to a list. + loop_commands = [field_data["commands"]] + else: + loop_commands = field_data["commands"] + for show_command_dict in loop_commands: + final_iterable_type = show_command_dict.get("iterable_type") + _, current_field_post = extract_and_post_process( + command_outputs_dict[show_command_dict["command"]], + show_command_dict, + {"obj": host.name, "original_host": host.name}, + final_iterable_type, + job_debug, + ) + get_context_from_pre_processor[pre_processor_name] = current_field_post for ssot_field, field_data in command_info_dict.items(): if not sync_vlans and ssot_field in ["interfaces__tagged_vlans", "interfaces__untagged_vlan"]: continue # If syncing vrfs isn't inscope remove the unneeded commands. if not sync_vrfs and ssot_field == "interfaces__vrf": continue + if ssot_field == "pre_processor": + continue if isinstance(field_data["commands"], dict): # only one command is specified as a dict force it to a list. loop_commands = [field_data["commands"]] @@ -120,10 +154,12 @@ def perform_data_extraction(host, command_info_dict, command_outputs_dict, job_d for show_command_dict in loop_commands: final_iterable_type = show_command_dict.get("iterable_type") if field_data.get("root_key"): + original_context = {"obj": host.name, "original_host": host.name} + merged_context = {**original_context, **get_context_from_pre_processor} root_key_pre, root_key_post = extract_and_post_process( command_outputs_dict[show_command_dict["command"]], show_command_dict, - {"obj": host.name, "original_host": host.name}, + merged_context, final_iterable_type, job_debug, ) @@ -139,19 +175,23 @@ def perform_data_extraction(host, command_info_dict, command_outputs_dict, job_d # a list of data that we want to become our nested key. E.g. current_key "Ethernet1/1" # These get passed into the render context for the template render to allow nested jpaths to use # the current_key context for more flexible jpath queries. + original_context = {"current_key": current_key, "obj": host.name, "original_host": host.name} + merged_context = {**original_context, **get_context_from_pre_processor} _, current_key_post = extract_and_post_process( command_outputs_dict[show_command_dict["command"]], show_command_dict, - {"current_key": current_key, "obj": host.name, "original_host": host.name}, + merged_context, final_iterable_type, job_debug, ) result_dict[field_nesting[0]][current_key][field_nesting[1]] = current_key_post else: + original_context = {"obj": host.name, "original_host": host.name} + merged_context = {**original_context, **get_context_from_pre_processor} _, current_field_post = extract_and_post_process( command_outputs_dict[show_command_dict["command"]], show_command_dict, - {"obj": host.name, "original_host": host.name}, + merged_context, final_iterable_type, job_debug, ) diff --git a/nautobot_device_onboarding/nornir_plays/processor.py b/nautobot_device_onboarding/nornir_plays/processor.py index 4621cd38..135c8963 100755 --- a/nautobot_device_onboarding/nornir_plays/processor.py +++ b/nautobot_device_onboarding/nornir_plays/processor.py @@ -60,7 +60,7 @@ def task_instance_completed(self, task: Task, host: Host, result: MultiResult) - ready_for_ssot_data = extract_show_data( host, parsed_command_outputs, task.params["command_getter_job"], self.kwargs["debug"] ) - self.logger.debug(f"read for ssot data {host.name} {ready_for_ssot_data}") + self.logger.debug(f"ready for ssot data {host.name} {ready_for_ssot_data}") self.data[host.name].update(ready_for_ssot_data) def subtask_instance_completed(self, task: Task, host: Host, result: MultiResult) -> None: diff --git a/nautobot_device_onboarding/tests/mock/cisco_ios/command_getter_result.json b/nautobot_device_onboarding/tests/mock/cisco_ios/command_getter_result.json new file mode 100755 index 00000000..1993d068 --- /dev/null +++ b/nautobot_device_onboarding/tests/mock/cisco_ios/command_getter_result.json @@ -0,0 +1,503 @@ +{ + "show version": [ + { + "config_register": "0x2102", + "hardware": ["WS-C4948E"], + "hostname": "dummy_rtr", + "mac_address": [], + "release": "fc1", + "reload_reason": "reload", + "restarted": "09:09:22 UTC Tue Apr 9 2013", + "rommon": "12.2(44r)SG9", + "running_image": "cat4500e-entservicesk9-mz.122-54.SG1.bin", + "serial": ["CAT1451S15C"], + "software_image": "cat4500e-ENTSERVICESK9-M", + "uptime": "2 years, 31 weeks, 6 days, 9 hours, 55 minutes", + "uptime_days": "6", + "uptime_hours": "9", + "uptime_minutes": "55", + "uptime_weeks": "31", + "uptime_years": "2", + "version": "12.2(54)SG1" + } + ], + "show interfaces": [ + { + "abort": "", + "bandwidth": "1000000 Kbit", + "bia": "fa16.3e57.336f", + "crc": "0", + "delay": "10 usec", + "description": "", + "duplex": "Auto-duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "iGbE", + "input_errors": "0", + "input_packets": "324", + "input_pps": "0", + "input_rate": "0", + "interface": "GigabitEthernet0/0", + "ip_address": "", + "last_input": "1d21h", + "last_output": "1d21h", + "last_output_hang": "never", + "link_status": "reset", + "mac_address": "fa16.3e57.336f", + "media_type": "unknown", + "mtu": "1500", + "output_errors": "0", + "output_packets": "703", + "output_pps": "0", + "output_rate": "0", + "overrun": "0", + "prefix_length": "", + "protocol_status": "down (notconnect)", + "queue_strategy": "fifo", + "runts": "0", + "speed": "Auto-speed", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "1000000 Kbit", + "bia": "fa16.3e4f.41cc", + "crc": "0", + "delay": "10 usec", + "description": "to iosvl2-2", + "duplex": "Auto-duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "iGbE", + "input_errors": "0", + "input_packets": "83", + "input_pps": "0", + "input_rate": "0", + "interface": "GigabitEthernet0/1", + "ip_address": "", + "last_input": "1d21h", + "last_output": "00:00:02", + "last_output_hang": "never", + "link_status": "up", + "mac_address": "fa16.3e4f.41cc", + "media_type": "unknown", + "mtu": "1500", + "output_errors": "0", + "output_packets": "15513", + "output_pps": "0", + "output_rate": "0", + "overrun": "0", + "prefix_length": "", + "protocol_status": "up (connected)", + "queue_strategy": "fifo", + "runts": "0", + "speed": "Auto-speed", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "1000000 Kbit", + "bia": "fa16.3ea3.3e49", + "crc": "0", + "delay": "10 usec", + "description": "to iosvl2-4", + "duplex": "Auto-duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "iGbE", + "input_errors": "0", + "input_packets": "8677", + "input_pps": "0", + "input_rate": "0", + "interface": "GigabitEthernet0/2", + "ip_address": "", + "last_input": "00:00:13", + "last_output": "00:00:00", + "last_output_hang": "never", + "link_status": "up", + "mac_address": "fa16.3ea3.3e49", + "media_type": "unknown", + "mtu": "1500", + "output_errors": "0", + "output_packets": "420798", + "output_pps": "2", + "output_rate": "1000", + "overrun": "0", + "prefix_length": "", + "protocol_status": "up (connected)", + "queue_strategy": "fifo", + "runts": "0", + "speed": "Auto-speed", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "1000000 Kbit", + "bia": "fa16.3e31.2c47", + "crc": "0", + "delay": "10 usec", + "description": "to iosvl2-3", + "duplex": "Auto-duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "iGbE", + "input_errors": "0", + "input_packets": "8638", + "input_pps": "0", + "input_rate": "0", + "interface": "GigabitEthernet0/3", + "ip_address": "", + "last_input": "00:00:28", + "last_output": "00:00:00", + "last_output_hang": "never", + "link_status": "up", + "mac_address": "fa16.3e31.2c47", + "media_type": "unknown", + "mtu": "1500", + "output_errors": "0", + "output_packets": "420819", + "output_pps": "2", + "output_rate": "1000", + "overrun": "0", + "prefix_length": "", + "protocol_status": "up (connected)", + "queue_strategy": "fifo", + "runts": "0", + "speed": "Auto-speed", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "1000000 Kbit", + "bia": "fa16.3ec8.50ab", + "crc": "0", + "delay": "10 usec", + "description": "to iosvl2-3", + "duplex": "Auto-duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "iGbE", + "input_errors": "0", + "input_packets": "8627", + "input_pps": "0", + "input_rate": "0", + "interface": "GigabitEthernet1/0", + "ip_address": "", + "last_input": "00:00:26", + "last_output": "00:00:00", + "last_output_hang": "never", + "link_status": "up", + "mac_address": "fa16.3ec8.50ab", + "media_type": "unknown", + "mtu": "1500", + "output_errors": "0", + "output_packets": "420790", + "output_pps": "2", + "output_rate": "2000", + "overrun": "0", + "prefix_length": "", + "protocol_status": "up (connected)", + "queue_strategy": "fifo", + "runts": "0", + "speed": "Auto-speed", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "100000 Kbit", + "bia": "fa16.3e4f.41cc", + "crc": "0", + "delay": "100 usec", + "description": "", + "duplex": "Auto-duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "EtherChannel", + "input_errors": "0", + "input_packets": "85", + "input_pps": "0", + "input_rate": "0", + "interface": "Port-channel1", + "ip_address": "", + "last_input": "1d21h", + "last_output": "never", + "last_output_hang": "never", + "link_status": "down", + "mac_address": "fa16.3e4f.41cc", + "media_type": "unknown", + "mtu": "1500", + "output_errors": "0", + "output_packets": "0", + "output_pps": "0", + "output_rate": "0", + "overrun": "0", + "prefix_length": "", + "protocol_status": "down (notconnect)", + "queue_strategy": "fifo", + "runts": "0", + "speed": "Auto-speed", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "100000 Kbit", + "bia": "fa16.3e4f.41cc", + "crc": "0", + "delay": "100 usec", + "description": "", + "duplex": "Auto-duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "EtherChannel", + "input_errors": "0", + "input_packets": "85", + "input_pps": "0", + "input_rate": "0", + "interface": "Port-channel3", + "ip_address": "", + "last_input": "1d21h", + "last_output": "never", + "last_output_hang": "never", + "link_status": "down", + "mac_address": "fa16.3e4f.41c2", + "media_type": "unknown", + "mtu": "1500", + "output_errors": "0", + "output_packets": "0", + "output_pps": "0", + "output_rate": "0", + "overrun": "0", + "prefix_length": "", + "protocol_status": "down (notconnect)", + "queue_strategy": "fifo", + "runts": "0", + "speed": "Auto-speed", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "0", + "bandwidth": "8000000 Kbit", + "bia": "", + "crc": "0", + "delay": "5000 usec", + "description": "Loopback", + "duplex": "", + "encapsulation": "LOOPBACK", + "frame": "0", + "giants": "0", + "hardware_type": "Loopback", + "input_errors": "0", + "input_packets": "0", + "input_pps": "0", + "input_rate": "0", + "interface": "Loopback0", + "ip_address": "", + "last_input": "never", + "last_output": "never", + "last_output_hang": "never", + "link_status": "up", + "mac_address": "", + "media_type": "", + "mtu": "1514", + "output_errors": "0", + "output_packets": "0", + "output_pps": "0", + "output_rate": "0", + "overrun": "0", + "prefix_length": "", + "protocol_status": "up", + "queue_strategy": "fifo", + "runts": "0", + "speed": "", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "1000000 Kbit", + "bia": "fa16.3e57.8001", + "crc": "0", + "delay": "10 usec", + "description": "OOB Management", + "duplex": "", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "Ethernet SVI", + "input_errors": "0", + "input_packets": "0", + "input_pps": "0", + "input_rate": "0", + "interface": "Vlan1", + "ip_address": "10.255.0.16", + "last_input": "never", + "last_output": "never", + "last_output_hang": "never", + "link_status": "up", + "mac_address": "fa16.3e57.8001", + "media_type": "", + "mtu": "1500", + "output_errors": "", + "output_packets": "4", + "output_pps": "0", + "output_rate": "0", + "overrun": "0", + "prefix_length": "16", + "protocol_status": "up", + "queue_strategy": "fifo", + "runts": "0", + "speed": "", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + }, + { + "abort": "", + "bandwidth": "1000000 Kbit", + "bia": "78da.6eaf.3b82", + "crc": "0", + "delay": "10 usec", + "description": "Port", + "duplex": "Full Duplex", + "encapsulation": "ARPA", + "frame": "0", + "giants": "0", + "hardware_type": "ASR1001", + "input_errors": "0", + "input_packets": "0", + "input_pps": "0", + "input_rate": "0", + "interface": "GigabitEthernet0/2", + "ip_address": "", + "last_input": "never", + "last_output": "never", + "last_output_hang": "never", + "link_status": "administratively down", + "mac_address": "78da.6eaf.3b82", + "media_type": "unknown media type", + "mtu": "1500", + "output_errors": "0", + "output_packets": "0", + "output_pps": "0", + "output_rate": "0", + "overrun": "0", + "prefix_length": "", + "protocol_status": "down", + "queue_strategy": "fifo", + "runts": "0", + "speed": "1000Mbps", + "vlan_id": "", + "vlan_id_inner": "", + "vlan_id_outer": "" + } + ], + "show vlan": [ + {"1": "foo"} + ], + "show interfaces switchport": [ + { + "interface": "Gi0/1", + "switchport": "Enabled", + "switchport_monitor": "", + "switchport_negotiation": "Off", + "mode": "trunk", + "admin_mode": "trunk", + "access_vlan": "1", + "native_vlan": "1", + "voice_vlan": "none", + "trunking_vlans": [ + "ALL" + ] + }, + { + "interface": "Gi0/2", + "switchport": "Enabled", + "switchport_monitor": "", + "switchport_negotiation": "On", + "mode": "static access", + "admin_mode": "dynamic auto", + "access_vlan": "100", + "native_vlan": "1", + "voice_vlan": "none", + "trunking_vlans": [ + "ALL" + ] + } + ], + "show ip interface": [ + { + "inbound_acl": "", + "interface": "GigabitEthernet0/0", + "ip_address": [], + "ip_helper": [], + "link_status": "administratively down", + "mtu": "", + "outgoing_acl": "", + "prefix_length": [], + "protocol_status": "down", + "vrf": "" + }, + { + "inbound_acl": "", + "interface": "GigabitEthernet0/1", + "ip_address": [], + "ip_helper": [], + "link_status": "administratively down", + "mtu": "", + "outgoing_acl": "", + "prefix_length": [], + "protocol_status": "down", + "vrf": "" + } + ], + "show etherchannel summary": [ + { + "bundle_name": "Po1", + "bundle_protocol": "LACP", + "bundle_status": "SU", + "group": "1", + "member_interface": [ + "Gi0/1", + "Gi0/2" + ], + "member_interface_status": [ + "P", + "P" + ] + }, + { + "bundle_name": "Po3", + "bundle_protocol": "LACP", + "bundle_status": "SU", + "group": "3", + "member_interface": [ + "Gi1/0" + ], + "member_interface_status": [ + "P" + ] + } + ] +} diff --git a/nautobot_device_onboarding/tests/mock/mock_cisco_ios.yml b/nautobot_device_onboarding/tests/mock/mock_cisco_ios.yml new file mode 100755 index 00000000..cc0b92a9 --- /dev/null +++ b/nautobot_device_onboarding/tests/mock/mock_cisco_ios.yml @@ -0,0 +1,116 @@ +--- +sync_devices: + hostname: + commands: + - command: "show version" + parser: "textfsm" + jpath: "[*].hostname" + serial: + commands: + - command: "show version" + parser: "textfsm" + jpath: "[*].serial[]" + post_processor: "{{ obj | unique | first }}" + device_type: + commands: + - command: "show version" + parser: "textfsm" + jpath: "[*].hardware[]" + post_processor: "{{ obj | unique | first }}" + mgmt_interface: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?ip_address=='{{ obj }}'].{name: interface, enabled: link_status}" + post_processor: "{{ (obj | selectattr('enabled', 'eq', 'up') | list | first ).name }}" + mask_length: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?ip_address=='{{ obj }}'].prefix_length" + post_processor: "{{ obj | unique | first }}" +sync_network_data: + pre_processor: + vlan_map: + commands: + - command: "show vlan" + parser: "textfsm" + jpath: "[*].{id: vid, name: name}" + serial: + commands: + - command: "show version" + parser: "textfsm" + jpath: "[*].serial[]" + interfaces: + root_key: true + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[*].interface" # when root_key=true this extracted value is what becomes interable in keys using __ under `current_key`. + post_processor: "{% set result={} %}{% for interface in obj %}{{ result.update({interface: {}}) or '' }}{% endfor %}{{ result | tojson }}" + interfaces__type: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?interface=='{{ current_key }}'].hardware_type" + post_processor: "{{ obj[0] | map_interface_type }}" + interfaces__ip_addresses: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?interface=='{{ current_key }}'].{ip_address: ip_address, prefix_length: prefix_length}" + iterable_type: "list" + interfaces__mtu: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?interface=='{{ current_key }}'].mtu" + interfaces__mac_address: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?interface=='{{ current_key }}'].mac_address" + interfaces__description: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?interface=='{{ current_key }}'].description" + interfaces__link_status: + commands: + - command: "show interfaces" + parser: "textfsm" + jpath: "[?interface=='{{ current_key }}'].link_status" + post_processor: "{{ obj[0] | interface_status_to_bool }}" + interfaces__802.1Q_mode: + commands: + - command: "show interfaces switchport" + parser: "textfsm" + jpath: "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, trunking_vlans: trunking_vlans}" + post_processor: "{{ obj | interface_mode_logic }}" + iterable_type: "str" + interfaces__lag: + commands: + - command: "show etherchannel summary" + parser: "textfsm" + jpath: "[?contains(@.member_interface, `{{ current_key | abbreviated_interface_name }}`)].bundle_name" + post_processor: "{% if obj | length > 0 %}{{ obj[0] | canonical_interface_name }}{% else %}{{ obj }}{% endif %}" + iterable_type: "str" + interfaces__vrf: + commands: + - command: "show ip interface" + parser: "textfsm" + jpath: "[?interface=='{{ current_key }}'].{name:vrf}" + post_processor: "{% if obj | length > 0 %}{{ obj[0] | key_exist_or_default('name') | tojson }}{% else %}{{ obj }}{% endif %}" + iterable_type: "dict" + interfaces__tagged_vlans: + commands: + - command: "show interfaces switchport" + parser: "textfsm" + jpath: "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, access_vlan: access_vlan, trunking_vlans: trunking_vlans}" + post_processor: "{{ obj | get_vlan_data | tojson }}" + interfaces__untagged_vlan: + commands: + - command: "show interfaces switchport" + parser: "textfsm" + jpath: "[?contains(interface, '{{ current_key }}')].{id: native_vlan}" + iterable_type: "dict" diff --git a/nautobot_device_onboarding/tests/mock/post_results.py b/nautobot_device_onboarding/tests/mock/post_results.py deleted file mode 100755 index 30a342d4..00000000 --- a/nautobot_device_onboarding/tests/mock/post_results.py +++ /dev/null @@ -1,985 +0,0 @@ -{ - "nxos": { - "platform": "cisco_nxos", - "manufacturer": "Cisco", - "network_driver": "cisco_nxos", - "serial": "9V6P9Q275MS", - "interfaces": [ - { - "Management0": { - "mtu": "1500", - "type": "other", - "ip_addresses": [{"ip_address": "10.1.1.7", "prefix_length": "24"}], - "mac_address": "5254.0004.9de4", - "description": "", - "link_status": True, - "lag": "", - "vrf": {"name": "management"}, - "802.1Q_mode": "", - "tagged_vlans": [], - "untagged_vlan": "", - } - }, - { - "Ethernet1/1": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0101", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/2": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0102", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/3": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0103", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/4": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0104", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/5": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0105", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/6": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0106", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/7": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0107", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/8": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0108", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/9": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0109", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/10": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.010a", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/11": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.010b", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/12": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.010c", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/13": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.010d", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/14": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.010e", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/15": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.010f", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/16": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0110", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/17": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0111", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/18": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0112", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/19": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0113", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/20": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0114", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/21": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0115", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/22": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0116", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/23": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0117", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/24": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0118", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/25": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0119", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/26": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.011a", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/27": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.011b", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/28": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.011c", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/29": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.011d", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/30": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.011e", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/31": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.011f", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/32": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0120", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/33": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0121", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/34": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0122", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/35": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0123", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/36": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0124", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/37": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0125", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/38": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0126", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/39": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0127", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/40": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0128", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/41": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0129", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/42": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.012a", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/43": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.012b", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/44": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.012c", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/45": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.012d", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/46": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.012e", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/47": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.012f", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/48": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0130", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/49": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0131", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/50": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0132", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/51": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0133", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/52": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0134", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/53": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0135", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/54": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0136", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/55": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0137", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/56": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0138", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/57": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0139", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/58": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.013a", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/59": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.013b", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/60": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.013c", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/61": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.013d", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/62": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.013e", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/63": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.013f", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - { - "Ethernet1/64": { - "mtu": "1500", - "type": "other", - "ip_addresses": [], - "mac_address": "5204.9de4.0140", - "description": "", - "link_status": False, - "lag": "", - "vrf": {}, - "802.1Q_mode": "access", - "tagged_vlans": [], - "untagged_vlan": {"name": "default", "id": "1"}, - } - }, - ], - } -} diff --git a/nautobot_device_onboarding/tests/mock/pre_results.py b/nautobot_device_onboarding/tests/mock/pre_results.py deleted file mode 100755 index 5b043f4c..00000000 --- a/nautobot_device_onboarding/tests/mock/pre_results.py +++ /dev/null @@ -1,1129 +0,0 @@ -{ - "nxos": { - "platform": "cisco_nxos", - "manufacturer": "Cisco", - "network_driver": "cisco_nxos", - "interface": [ - {"interface": "mgmt0"}, - {"interface": "Ethernet1/1"}, - {"interface": "Ethernet1/2"}, - {"interface": "Ethernet1/3"}, - {"interface": "Ethernet1/4"}, - {"interface": "Ethernet1/5"}, - {"interface": "Ethernet1/6"}, - {"interface": "Ethernet1/7"}, - {"interface": "Ethernet1/8"}, - {"interface": "Ethernet1/9"}, - {"interface": "Ethernet1/10"}, - {"interface": "Ethernet1/11"}, - {"interface": "Ethernet1/12"}, - {"interface": "Ethernet1/13"}, - {"interface": "Ethernet1/14"}, - {"interface": "Ethernet1/15"}, - {"interface": "Ethernet1/16"}, - {"interface": "Ethernet1/17"}, - {"interface": "Ethernet1/18"}, - {"interface": "Ethernet1/19"}, - {"interface": "Ethernet1/20"}, - {"interface": "Ethernet1/21"}, - {"interface": "Ethernet1/22"}, - {"interface": "Ethernet1/23"}, - {"interface": "Ethernet1/24"}, - {"interface": "Ethernet1/25"}, - {"interface": "Ethernet1/26"}, - {"interface": "Ethernet1/27"}, - {"interface": "Ethernet1/28"}, - {"interface": "Ethernet1/29"}, - {"interface": "Ethernet1/30"}, - {"interface": "Ethernet1/31"}, - {"interface": "Ethernet1/32"}, - {"interface": "Ethernet1/33"}, - {"interface": "Ethernet1/34"}, - {"interface": "Ethernet1/35"}, - {"interface": "Ethernet1/36"}, - {"interface": "Ethernet1/37"}, - {"interface": "Ethernet1/38"}, - {"interface": "Ethernet1/39"}, - {"interface": "Ethernet1/40"}, - {"interface": "Ethernet1/41"}, - {"interface": "Ethernet1/42"}, - {"interface": "Ethernet1/43"}, - {"interface": "Ethernet1/44"}, - {"interface": "Ethernet1/45"}, - {"interface": "Ethernet1/46"}, - {"interface": "Ethernet1/47"}, - {"interface": "Ethernet1/48"}, - {"interface": "Ethernet1/49"}, - {"interface": "Ethernet1/50"}, - {"interface": "Ethernet1/51"}, - {"interface": "Ethernet1/52"}, - {"interface": "Ethernet1/53"}, - {"interface": "Ethernet1/54"}, - {"interface": "Ethernet1/55"}, - {"interface": "Ethernet1/56"}, - {"interface": "Ethernet1/57"}, - {"interface": "Ethernet1/58"}, - {"interface": "Ethernet1/59"}, - {"interface": "Ethernet1/60"}, - {"interface": "Ethernet1/61"}, - {"interface": "Ethernet1/62"}, - {"interface": "Ethernet1/63"}, - {"interface": "Ethernet1/64"}, - ], - "type": [ - {"interface": "mgmt0", "type": "Ethernet"}, - {"interface": "Ethernet1/1", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/2", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/3", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/4", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/5", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/6", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/7", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/8", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/9", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/10", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/11", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/12", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/13", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/14", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/15", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/16", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/17", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/18", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/19", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/20", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/21", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/22", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/23", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/24", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/25", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/26", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/27", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/28", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/29", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/30", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/31", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/32", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/33", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/34", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/35", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/36", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/37", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/38", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/39", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/40", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/41", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/42", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/43", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/44", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/45", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/46", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/47", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/48", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/49", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/50", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/51", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/52", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/53", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/54", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/55", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/56", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/57", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/58", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/59", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/60", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/61", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/62", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/63", "type": "100/1000/10000 Ethernet"}, - {"interface": "Ethernet1/64", "type": "100/1000/10000 Ethernet"}, - ], - "mtu": [ - {"interface": "mgmt0", "mtu": "1500"}, - {"interface": "Ethernet1/1", "mtu": "1500"}, - {"interface": "Ethernet1/2", "mtu": "1500"}, - {"interface": "Ethernet1/3", "mtu": "1500"}, - {"interface": "Ethernet1/4", "mtu": "1500"}, - {"interface": "Ethernet1/5", "mtu": "1500"}, - {"interface": "Ethernet1/6", "mtu": "1500"}, - {"interface": "Ethernet1/7", "mtu": "1500"}, - {"interface": "Ethernet1/8", "mtu": "1500"}, - {"interface": "Ethernet1/9", "mtu": "1500"}, - {"interface": "Ethernet1/10", "mtu": "1500"}, - {"interface": "Ethernet1/11", "mtu": "1500"}, - {"interface": "Ethernet1/12", "mtu": "1500"}, - {"interface": "Ethernet1/13", "mtu": "1500"}, - {"interface": "Ethernet1/14", "mtu": "1500"}, - {"interface": "Ethernet1/15", "mtu": "1500"}, - {"interface": "Ethernet1/16", "mtu": "1500"}, - {"interface": "Ethernet1/17", "mtu": "1500"}, - {"interface": "Ethernet1/18", "mtu": "1500"}, - {"interface": "Ethernet1/19", "mtu": "1500"}, - {"interface": "Ethernet1/20", "mtu": "1500"}, - {"interface": "Ethernet1/21", "mtu": "1500"}, - {"interface": "Ethernet1/22", "mtu": "1500"}, - {"interface": "Ethernet1/23", "mtu": "1500"}, - {"interface": "Ethernet1/24", "mtu": "1500"}, - {"interface": "Ethernet1/25", "mtu": "1500"}, - {"interface": "Ethernet1/26", "mtu": "1500"}, - {"interface": "Ethernet1/27", "mtu": "1500"}, - {"interface": "Ethernet1/28", "mtu": "1500"}, - {"interface": "Ethernet1/29", "mtu": "1500"}, - {"interface": "Ethernet1/30", "mtu": "1500"}, - {"interface": "Ethernet1/31", "mtu": "1500"}, - {"interface": "Ethernet1/32", "mtu": "1500"}, - {"interface": "Ethernet1/33", "mtu": "1500"}, - {"interface": "Ethernet1/34", "mtu": "1500"}, - {"interface": "Ethernet1/35", "mtu": "1500"}, - {"interface": "Ethernet1/36", "mtu": "1500"}, - {"interface": "Ethernet1/37", "mtu": "1500"}, - {"interface": "Ethernet1/38", "mtu": "1500"}, - {"interface": "Ethernet1/39", "mtu": "1500"}, - {"interface": "Ethernet1/40", "mtu": "1500"}, - {"interface": "Ethernet1/41", "mtu": "1500"}, - {"interface": "Ethernet1/42", "mtu": "1500"}, - {"interface": "Ethernet1/43", "mtu": "1500"}, - {"interface": "Ethernet1/44", "mtu": "1500"}, - {"interface": "Ethernet1/45", "mtu": "1500"}, - {"interface": "Ethernet1/46", "mtu": "1500"}, - {"interface": "Ethernet1/47", "mtu": "1500"}, - {"interface": "Ethernet1/48", "mtu": "1500"}, - {"interface": "Ethernet1/49", "mtu": "1500"}, - {"interface": "Ethernet1/50", "mtu": "1500"}, - {"interface": "Ethernet1/51", "mtu": "1500"}, - {"interface": "Ethernet1/52", "mtu": "1500"}, - {"interface": "Ethernet1/53", "mtu": "1500"}, - {"interface": "Ethernet1/54", "mtu": "1500"}, - {"interface": "Ethernet1/55", "mtu": "1500"}, - {"interface": "Ethernet1/56", "mtu": "1500"}, - {"interface": "Ethernet1/57", "mtu": "1500"}, - {"interface": "Ethernet1/58", "mtu": "1500"}, - {"interface": "Ethernet1/59", "mtu": "1500"}, - {"interface": "Ethernet1/60", "mtu": "1500"}, - {"interface": "Ethernet1/61", "mtu": "1500"}, - {"interface": "Ethernet1/62", "mtu": "1500"}, - {"interface": "Ethernet1/63", "mtu": "1500"}, - {"interface": "Ethernet1/64", "mtu": "1500"}, - ], - "mac_address": [ - {"interface": "mgmt0", "mac_address": "5254.0004.9de4"}, - {"interface": "Ethernet1/1", "mac_address": "5204.9de4.0101"}, - {"interface": "Ethernet1/2", "mac_address": "5204.9de4.0102"}, - {"interface": "Ethernet1/3", "mac_address": "5204.9de4.0103"}, - {"interface": "Ethernet1/4", "mac_address": "5204.9de4.0104"}, - {"interface": "Ethernet1/5", "mac_address": "5204.9de4.0105"}, - {"interface": "Ethernet1/6", "mac_address": "5204.9de4.0106"}, - {"interface": "Ethernet1/7", "mac_address": "5204.9de4.0107"}, - {"interface": "Ethernet1/8", "mac_address": "5204.9de4.0108"}, - {"interface": "Ethernet1/9", "mac_address": "5204.9de4.0109"}, - {"interface": "Ethernet1/10", "mac_address": "5204.9de4.010a"}, - {"interface": "Ethernet1/11", "mac_address": "5204.9de4.010b"}, - {"interface": "Ethernet1/12", "mac_address": "5204.9de4.010c"}, - {"interface": "Ethernet1/13", "mac_address": "5204.9de4.010d"}, - {"interface": "Ethernet1/14", "mac_address": "5204.9de4.010e"}, - {"interface": "Ethernet1/15", "mac_address": "5204.9de4.010f"}, - {"interface": "Ethernet1/16", "mac_address": "5204.9de4.0110"}, - {"interface": "Ethernet1/17", "mac_address": "5204.9de4.0111"}, - {"interface": "Ethernet1/18", "mac_address": "5204.9de4.0112"}, - {"interface": "Ethernet1/19", "mac_address": "5204.9de4.0113"}, - {"interface": "Ethernet1/20", "mac_address": "5204.9de4.0114"}, - {"interface": "Ethernet1/21", "mac_address": "5204.9de4.0115"}, - {"interface": "Ethernet1/22", "mac_address": "5204.9de4.0116"}, - {"interface": "Ethernet1/23", "mac_address": "5204.9de4.0117"}, - {"interface": "Ethernet1/24", "mac_address": "5204.9de4.0118"}, - {"interface": "Ethernet1/25", "mac_address": "5204.9de4.0119"}, - {"interface": "Ethernet1/26", "mac_address": "5204.9de4.011a"}, - {"interface": "Ethernet1/27", "mac_address": "5204.9de4.011b"}, - {"interface": "Ethernet1/28", "mac_address": "5204.9de4.011c"}, - {"interface": "Ethernet1/29", "mac_address": "5204.9de4.011d"}, - {"interface": "Ethernet1/30", "mac_address": "5204.9de4.011e"}, - {"interface": "Ethernet1/31", "mac_address": "5204.9de4.011f"}, - {"interface": "Ethernet1/32", "mac_address": "5204.9de4.0120"}, - {"interface": "Ethernet1/33", "mac_address": "5204.9de4.0121"}, - {"interface": "Ethernet1/34", "mac_address": "5204.9de4.0122"}, - {"interface": "Ethernet1/35", "mac_address": "5204.9de4.0123"}, - {"interface": "Ethernet1/36", "mac_address": "5204.9de4.0124"}, - {"interface": "Ethernet1/37", "mac_address": "5204.9de4.0125"}, - {"interface": "Ethernet1/38", "mac_address": "5204.9de4.0126"}, - {"interface": "Ethernet1/39", "mac_address": "5204.9de4.0127"}, - {"interface": "Ethernet1/40", "mac_address": "5204.9de4.0128"}, - {"interface": "Ethernet1/41", "mac_address": "5204.9de4.0129"}, - {"interface": "Ethernet1/42", "mac_address": "5204.9de4.012a"}, - {"interface": "Ethernet1/43", "mac_address": "5204.9de4.012b"}, - {"interface": "Ethernet1/44", "mac_address": "5204.9de4.012c"}, - {"interface": "Ethernet1/45", "mac_address": "5204.9de4.012d"}, - {"interface": "Ethernet1/46", "mac_address": "5204.9de4.012e"}, - {"interface": "Ethernet1/47", "mac_address": "5204.9de4.012f"}, - {"interface": "Ethernet1/48", "mac_address": "5204.9de4.0130"}, - {"interface": "Ethernet1/49", "mac_address": "5204.9de4.0131"}, - {"interface": "Ethernet1/50", "mac_address": "5204.9de4.0132"}, - {"interface": "Ethernet1/51", "mac_address": "5204.9de4.0133"}, - {"interface": "Ethernet1/52", "mac_address": "5204.9de4.0134"}, - {"interface": "Ethernet1/53", "mac_address": "5204.9de4.0135"}, - {"interface": "Ethernet1/54", "mac_address": "5204.9de4.0136"}, - {"interface": "Ethernet1/55", "mac_address": "5204.9de4.0137"}, - {"interface": "Ethernet1/56", "mac_address": "5204.9de4.0138"}, - {"interface": "Ethernet1/57", "mac_address": "5204.9de4.0139"}, - {"interface": "Ethernet1/58", "mac_address": "5204.9de4.013a"}, - {"interface": "Ethernet1/59", "mac_address": "5204.9de4.013b"}, - {"interface": "Ethernet1/60", "mac_address": "5204.9de4.013c"}, - {"interface": "Ethernet1/61", "mac_address": "5204.9de4.013d"}, - {"interface": "Ethernet1/62", "mac_address": "5204.9de4.013e"}, - {"interface": "Ethernet1/63", "mac_address": "5204.9de4.013f"}, - {"interface": "Ethernet1/64", "mac_address": "5204.9de4.0140"}, - ], - "description": [ - {"interface": "mgmt0", "description": ""}, - {"interface": "Ethernet1/1", "description": ""}, - {"interface": "Ethernet1/2", "description": ""}, - {"interface": "Ethernet1/3", "description": ""}, - {"interface": "Ethernet1/4", "description": ""}, - {"interface": "Ethernet1/5", "description": ""}, - {"interface": "Ethernet1/6", "description": ""}, - {"interface": "Ethernet1/7", "description": ""}, - {"interface": "Ethernet1/8", "description": ""}, - {"interface": "Ethernet1/9", "description": ""}, - {"interface": "Ethernet1/10", "description": ""}, - {"interface": "Ethernet1/11", "description": ""}, - {"interface": "Ethernet1/12", "description": ""}, - {"interface": "Ethernet1/13", "description": ""}, - {"interface": "Ethernet1/14", "description": ""}, - {"interface": "Ethernet1/15", "description": ""}, - {"interface": "Ethernet1/16", "description": ""}, - {"interface": "Ethernet1/17", "description": ""}, - {"interface": "Ethernet1/18", "description": ""}, - {"interface": "Ethernet1/19", "description": ""}, - {"interface": "Ethernet1/20", "description": ""}, - {"interface": "Ethernet1/21", "description": ""}, - {"interface": "Ethernet1/22", "description": ""}, - {"interface": "Ethernet1/23", "description": ""}, - {"interface": "Ethernet1/24", "description": ""}, - {"interface": "Ethernet1/25", "description": ""}, - {"interface": "Ethernet1/26", "description": ""}, - {"interface": "Ethernet1/27", "description": ""}, - {"interface": "Ethernet1/28", "description": ""}, - {"interface": "Ethernet1/29", "description": ""}, - {"interface": "Ethernet1/30", "description": ""}, - {"interface": "Ethernet1/31", "description": ""}, - {"interface": "Ethernet1/32", "description": ""}, - {"interface": "Ethernet1/33", "description": ""}, - {"interface": "Ethernet1/34", "description": ""}, - {"interface": "Ethernet1/35", "description": ""}, - {"interface": "Ethernet1/36", "description": ""}, - {"interface": "Ethernet1/37", "description": ""}, - {"interface": "Ethernet1/38", "description": ""}, - {"interface": "Ethernet1/39", "description": ""}, - {"interface": "Ethernet1/40", "description": ""}, - {"interface": "Ethernet1/41", "description": ""}, - {"interface": "Ethernet1/42", "description": ""}, - {"interface": "Ethernet1/43", "description": ""}, - {"interface": "Ethernet1/44", "description": ""}, - {"interface": "Ethernet1/45", "description": ""}, - {"interface": "Ethernet1/46", "description": ""}, - {"interface": "Ethernet1/47", "description": ""}, - {"interface": "Ethernet1/48", "description": ""}, - {"interface": "Ethernet1/49", "description": ""}, - {"interface": "Ethernet1/50", "description": ""}, - {"interface": "Ethernet1/51", "description": ""}, - {"interface": "Ethernet1/52", "description": ""}, - {"interface": "Ethernet1/53", "description": ""}, - {"interface": "Ethernet1/54", "description": ""}, - {"interface": "Ethernet1/55", "description": ""}, - {"interface": "Ethernet1/56", "description": ""}, - {"interface": "Ethernet1/57", "description": ""}, - {"interface": "Ethernet1/58", "description": ""}, - {"interface": "Ethernet1/59", "description": ""}, - {"interface": "Ethernet1/60", "description": ""}, - {"interface": "Ethernet1/61", "description": ""}, - {"interface": "Ethernet1/62", "description": ""}, - {"interface": "Ethernet1/63", "description": ""}, - {"interface": "Ethernet1/64", "description": ""}, - ], - "link_status": [ - {"interface": "mgmt0", "link_status": "up"}, - {"interface": "Ethernet1/1", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/2", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/3", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/4", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/5", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/6", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/7", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/8", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/9", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/10", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/11", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/12", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/13", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/14", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/15", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/16", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/17", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/18", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/19", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/20", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/21", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/22", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/23", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/24", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/25", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/26", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/27", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/28", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/29", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/30", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/31", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/32", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/33", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/34", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/35", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/36", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/37", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/38", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/39", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/40", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/41", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/42", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/43", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/44", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/45", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/46", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/47", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/48", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/49", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/50", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/51", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/52", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/53", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/54", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/55", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/56", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/57", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/58", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/59", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/60", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/61", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/62", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/63", "link_status": "down (Link not connected)"}, - {"interface": "Ethernet1/64", "link_status": "down (Link not connected)"}, - ], - "mode": [ - {"interface": "mgmt0", "mode": ""}, - {"interface": "Ethernet1/1", "mode": "access"}, - {"interface": "Ethernet1/2", "mode": "access"}, - {"interface": "Ethernet1/3", "mode": "access"}, - {"interface": "Ethernet1/4", "mode": "access"}, - {"interface": "Ethernet1/5", "mode": "access"}, - {"interface": "Ethernet1/6", "mode": "access"}, - {"interface": "Ethernet1/7", "mode": "access"}, - {"interface": "Ethernet1/8", "mode": "access"}, - {"interface": "Ethernet1/9", "mode": "access"}, - {"interface": "Ethernet1/10", "mode": "access"}, - {"interface": "Ethernet1/11", "mode": "access"}, - {"interface": "Ethernet1/12", "mode": "access"}, - {"interface": "Ethernet1/13", "mode": "access"}, - {"interface": "Ethernet1/14", "mode": "access"}, - {"interface": "Ethernet1/15", "mode": "access"}, - {"interface": "Ethernet1/16", "mode": "access"}, - {"interface": "Ethernet1/17", "mode": "access"}, - {"interface": "Ethernet1/18", "mode": "access"}, - {"interface": "Ethernet1/19", "mode": "access"}, - {"interface": "Ethernet1/20", "mode": "access"}, - {"interface": "Ethernet1/21", "mode": "access"}, - {"interface": "Ethernet1/22", "mode": "access"}, - {"interface": "Ethernet1/23", "mode": "access"}, - {"interface": "Ethernet1/24", "mode": "access"}, - {"interface": "Ethernet1/25", "mode": "access"}, - {"interface": "Ethernet1/26", "mode": "access"}, - {"interface": "Ethernet1/27", "mode": "access"}, - {"interface": "Ethernet1/28", "mode": "access"}, - {"interface": "Ethernet1/29", "mode": "access"}, - {"interface": "Ethernet1/30", "mode": "access"}, - {"interface": "Ethernet1/31", "mode": "access"}, - {"interface": "Ethernet1/32", "mode": "access"}, - {"interface": "Ethernet1/33", "mode": "access"}, - {"interface": "Ethernet1/34", "mode": "access"}, - {"interface": "Ethernet1/35", "mode": "access"}, - {"interface": "Ethernet1/36", "mode": "access"}, - {"interface": "Ethernet1/37", "mode": "access"}, - {"interface": "Ethernet1/38", "mode": "access"}, - {"interface": "Ethernet1/39", "mode": "access"}, - {"interface": "Ethernet1/40", "mode": "access"}, - {"interface": "Ethernet1/41", "mode": "access"}, - {"interface": "Ethernet1/42", "mode": "access"}, - {"interface": "Ethernet1/43", "mode": "access"}, - {"interface": "Ethernet1/44", "mode": "access"}, - {"interface": "Ethernet1/45", "mode": "access"}, - {"interface": "Ethernet1/46", "mode": "access"}, - {"interface": "Ethernet1/47", "mode": "access"}, - {"interface": "Ethernet1/48", "mode": "access"}, - {"interface": "Ethernet1/49", "mode": "access"}, - {"interface": "Ethernet1/50", "mode": "access"}, - {"interface": "Ethernet1/51", "mode": "access"}, - {"interface": "Ethernet1/52", "mode": "access"}, - {"interface": "Ethernet1/53", "mode": "access"}, - {"interface": "Ethernet1/54", "mode": "access"}, - {"interface": "Ethernet1/55", "mode": "access"}, - {"interface": "Ethernet1/56", "mode": "access"}, - {"interface": "Ethernet1/57", "mode": "access"}, - {"interface": "Ethernet1/58", "mode": "access"}, - {"interface": "Ethernet1/59", "mode": "access"}, - {"interface": "Ethernet1/60", "mode": "access"}, - {"interface": "Ethernet1/61", "mode": "access"}, - {"interface": "Ethernet1/62", "mode": "access"}, - {"interface": "Ethernet1/63", "mode": "access"}, - {"interface": "Ethernet1/64", "mode": "access"}, - ], - "serial": "9KEBYWRFVPR", - "ip_addresses": {"interface": "mgmt0", "ip_address": "10.1.1.7"}, - "prefix_length": {"interface": "mgmt0", "prefix_length": "10.1.1.0/24"}, - "vrf_interfaces": {"interface": "mgmt0", "name": "management"}, - "vlans": { - "interfaces": [ - "Eth1/1", - "Eth1/2", - "Eth1/3", - "Eth1/4", - "Eth1/5", - "Eth1/6", - "Eth1/7", - "Eth1/8", - "Eth1/9", - "Eth1/10", - "Eth1/11", - "Eth1/12", - "Eth1/13", - "Eth1/14", - "Eth1/15", - "Eth1/16", - "Eth1/17", - "Eth1/18", - "Eth1/19", - "Eth1/20", - "Eth1/21", - "Eth1/22", - "Eth1/23", - "Eth1/24", - "Eth1/25", - "Eth1/26", - "Eth1/27", - "Eth1/28", - "Eth1/29", - "Eth1/30", - "Eth1/31", - "Eth1/32", - "Eth1/33", - "Eth1/34", - "Eth1/35", - "Eth1/36", - "Eth1/37", - "Eth1/38", - "Eth1/39", - "Eth1/40", - "Eth1/41", - "Eth1/42", - "Eth1/43", - "Eth1/44", - "Eth1/45", - "Eth1/46", - "Eth1/47", - "Eth1/48", - "Eth1/49", - "Eth1/50", - "Eth1/51", - "Eth1/52", - "Eth1/53", - "Eth1/54", - "Eth1/55", - "Eth1/56", - "Eth1/57", - "Eth1/58", - "Eth1/59", - "Eth1/60", - "Eth1/61", - "Eth1/62", - "Eth1/63", - "Eth1/64", - ], - "vlan_name": "default", - "vlan_id": "1", - "status": "active", - }, - "interface_vlans": [ - { - "interface": "Ethernet1/1", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/2", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/3", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/4", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/5", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/6", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/7", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/8", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/9", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/10", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/11", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/12", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/13", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/14", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/15", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/16", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/17", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/18", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/19", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/20", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/21", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/22", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/23", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/24", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/25", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/26", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/27", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/28", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/29", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/30", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/31", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/32", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/33", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/34", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/35", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/36", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/37", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/38", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/39", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/40", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/41", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/42", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/43", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/44", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/45", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/46", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/47", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/48", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/49", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/50", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/51", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/52", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/53", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/54", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/55", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/56", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/57", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/58", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/59", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/60", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/61", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/62", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/63", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - { - "interface": "Ethernet1/64", - "mode": "access", - "access_vlan": "1", - "access_vlan_name": "default", - "native_vlan": "1", - "trunking_vlans": "1-4094", - "voice_vlan": "none", - }, - ], - } -} diff --git a/nautobot_device_onboarding/tests/test_nornir_plays/test_command_getter.py b/nautobot_device_onboarding/tests/test_nornir_plays/test_command_getter.py new file mode 100755 index 00000000..7297f1da --- /dev/null +++ b/nautobot_device_onboarding/tests/test_nornir_plays/test_command_getter.py @@ -0,0 +1,169 @@ +"""Test for nornir plays in command_getter.""" + +import os +import unittest +import yaml +from nautobot_device_onboarding.nornir_plays.command_getter import _get_commands_to_run + +MOCK_DIR = os.path.join("nautobot_device_onboarding", "tests", "mock") + + +class TestGetCommandsToRun(unittest.TestCase): + + def setUp(self): + with open(f"{MOCK_DIR}/mock_cisco_ios.yml", "r", encoding="utf-8") as mock_file_data: + self.expected_data = yaml.safe_load(mock_file_data) + + def test_deduplicate_command_list_sync_devices(self): + """Test dedup on sync_devices ssot job.""" + get_commands_to_run = _get_commands_to_run( + self.expected_data["sync_devices"], sync_vlans=False, sync_vrfs=False + ) + expected_commands_to_run = [ + {"command": "show version", "jpath": "[*].hostname", "parser": "textfsm"}, + { + "command": "show interfaces", + "jpath": "[?ip_address=='{{ obj }}'].{name: interface, enabled: link_status}", + "parser": "textfsm", + "post_processor": "{{ (obj | selectattr('enabled', 'eq', 'up') | list | first ).name }}", + }, + ] + self.assertEqual(get_commands_to_run, expected_commands_to_run) + + def test_deduplicate_command_list_sync_data_no_vrfs_no_vlans(self): + """Test dedup on sync_network_data ssot job.""" + get_commands_to_run = _get_commands_to_run( + self.expected_data["sync_network_data"], sync_vlans=False, sync_vrfs=False + ) + expected_commands_to_run = [ + {"command": "show vlan", "parser": "textfsm", "jpath": "[*].{id: vid, name: name}"}, + {"command": "show version", "parser": "textfsm", "jpath": "[*].serial[]"}, + { + "command": "show interfaces", + "parser": "textfsm", + "jpath": "[*].interface", + "post_processor": "{% set result={} %}{% for interface in obj %}{{ result.update({interface: {}}) or '' }}{% endfor %}{{ result | tojson }}", + }, + { + "command": "show interfaces switchport", + "parser": "textfsm", + "jpath": "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, trunking_vlans: trunking_vlans}", + "post_processor": "{{ obj | interface_mode_logic }}", + "iterable_type": "str", + }, + { + "command": "show etherchannel summary", + "parser": "textfsm", + "jpath": "[?contains(@.member_interface, `{{ current_key | abbreviated_interface_name }}`)].bundle_name", + "post_processor": "{% if obj | length > 0 %}{{ obj[0] | canonical_interface_name }}{% else %}{{ obj }}{% endif %}", + "iterable_type": "str", + }, + ] + self.assertEqual(get_commands_to_run, expected_commands_to_run) + + def test_deduplicate_command_list_sync_data_with_vrfs_no_vlans(self): + """Test dedup on sync_network_data ssot job.""" + get_commands_to_run = _get_commands_to_run( + self.expected_data["sync_network_data"], sync_vlans=False, sync_vrfs=True + ) + expected_commands_to_run = [ + {"command": "show vlan", "parser": "textfsm", "jpath": "[*].{id: vid, name: name}"}, + {"command": "show version", "parser": "textfsm", "jpath": "[*].serial[]"}, + { + "command": "show interfaces", + "parser": "textfsm", + "jpath": "[*].interface", + "post_processor": "{% set result={} %}{% for interface in obj %}{{ result.update({interface: {}}) or '' }}{% endfor %}{{ result | tojson }}", + }, + { + "command": "show interfaces switchport", + "parser": "textfsm", + "jpath": "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, trunking_vlans: trunking_vlans}", + "post_processor": "{{ obj | interface_mode_logic }}", + "iterable_type": "str", + }, + { + "command": "show etherchannel summary", + "parser": "textfsm", + "jpath": "[?contains(@.member_interface, `{{ current_key | abbreviated_interface_name }}`)].bundle_name", + "post_processor": "{% if obj | length > 0 %}{{ obj[0] | canonical_interface_name }}{% else %}{{ obj }}{% endif %}", + "iterable_type": "str", + }, + { + "command": "show ip interface", + "parser": "textfsm", + "jpath": "[?interface=='{{ current_key }}'].{name:vrf}", + "post_processor": "{% if obj | length > 0 %}{{ obj[0] | key_exist_or_default('name') | tojson }}{% else %}{{ obj }}{% endif %}", + "iterable_type": "dict", + }, + ] + self.assertEqual(get_commands_to_run, expected_commands_to_run) + + def test_deduplicate_command_list_sync_data_no_vrfs_with_vlans(self): + """Test dedup on sync_network_data ssot job.""" + get_commands_to_run = _get_commands_to_run( + self.expected_data["sync_network_data"], sync_vlans=True, sync_vrfs=False + ) + expected_commands_to_run = [ + {"command": "show vlan", "parser": "textfsm", "jpath": "[*].{id: vid, name: name}"}, + {"command": "show version", "parser": "textfsm", "jpath": "[*].serial[]"}, + { + "command": "show interfaces", + "parser": "textfsm", + "jpath": "[*].interface", + "post_processor": "{% set result={} %}{% for interface in obj %}{{ result.update({interface: {}}) or '' }}{% endfor %}{{ result | tojson }}", + }, + { + "command": "show interfaces switchport", + "parser": "textfsm", + "jpath": "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, trunking_vlans: trunking_vlans}", + "post_processor": "{{ obj | interface_mode_logic }}", + "iterable_type": "str", + }, + { + "command": "show etherchannel summary", + "parser": "textfsm", + "jpath": "[?contains(@.member_interface, `{{ current_key | abbreviated_interface_name }}`)].bundle_name", + "post_processor": "{% if obj | length > 0 %}{{ obj[0] | canonical_interface_name }}{% else %}{{ obj }}{% endif %}", + "iterable_type": "str", + }, + ] + self.assertEqual(get_commands_to_run, expected_commands_to_run) + + def test_deduplicate_command_list_sync_data_with_vrfs_and_vlans(self): + """Test dedup on sync_network_data ssot job.""" + get_commands_to_run = _get_commands_to_run( + self.expected_data["sync_network_data"], sync_vlans=True, sync_vrfs=True + ) + expected_commands_to_run = [ + {"command": "show vlan", "parser": "textfsm", "jpath": "[*].{id: vid, name: name}"}, + {"command": "show version", "parser": "textfsm", "jpath": "[*].serial[]"}, + { + "command": "show interfaces", + "parser": "textfsm", + "jpath": "[*].interface", + "post_processor": "{% set result={} %}{% for interface in obj %}{{ result.update({interface: {}}) or '' }}{% endfor %}{{ result | tojson }}", + }, + { + "command": "show interfaces switchport", + "parser": "textfsm", + "jpath": "[?interface=='{{ current_key | abbreviated_interface_name }}'].{admin_mode: admin_mode, mode: mode, trunking_vlans: trunking_vlans}", + "post_processor": "{{ obj | interface_mode_logic }}", + "iterable_type": "str", + }, + { + "command": "show etherchannel summary", + "parser": "textfsm", + "jpath": "[?contains(@.member_interface, `{{ current_key | abbreviated_interface_name }}`)].bundle_name", + "post_processor": "{% if obj | length > 0 %}{{ obj[0] | canonical_interface_name }}{% else %}{{ obj }}{% endif %}", + "iterable_type": "str", + }, + { + "command": "show ip interface", + "parser": "textfsm", + "jpath": "[?interface=='{{ current_key }}'].{name:vrf}", + "post_processor": "{% if obj | length > 0 %}{{ obj[0] | key_exist_or_default('name') | tojson }}{% else %}{{ obj }}{% endif %}", + "iterable_type": "dict", + }, + ] + self.assertEqual(get_commands_to_run, expected_commands_to_run) diff --git a/nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py b/nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py new file mode 100755 index 00000000..74e3e8c6 --- /dev/null +++ b/nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py @@ -0,0 +1,353 @@ +"""Test for nornir plays in command_getter.""" + +import os +import json +import unittest +import yaml +from nornir.core.inventory import ConnectionOptions, Host, Defaults +from nautobot_device_onboarding.nornir_plays.formatter import perform_data_extraction, extract_and_post_process + +MOCK_DIR = os.path.join("nautobot_device_onboarding", "tests", "mock") + + +class TestFormatter(unittest.TestCase): + + def setUp(self): + self.maxDiff = None + with open(f"{MOCK_DIR}/mock_cisco_ios.yml", "r", encoding="utf-8") as parsing_info: + self.platform_parsing_info = yaml.safe_load(parsing_info) + with open(f"{MOCK_DIR}/cisco_ios/command_getter_result.json", "r", encoding="utf-8") as command_info: + self.command_outputs = json.loads(command_info.read()) + self.host = Host( + name="10.255.0.16", + hostname="10.255.0.16", + port=22, + username="username", + password="password", + platform="cisco_ios", + connection_options={ + "netmiko": ConnectionOptions( + hostname="10.255.0.16", + port=22, + username="username", + password="password", + platform="platform", + ) + }, + defaults=Defaults(data={"sync_vlans": False, "sync_vrfs": False}), + ) + + def test_perform_data_extraction_simple_host_values(self): + self.assertEqual("10.255.0.16", self.host.name) + self.assertFalse(self.host.data.get("sync_vlans")) + self.assertFalse(self.host.data.get("sync_vrfs")) + + def test_perform_data_extraction_sync_devices(self): + actual_result = perform_data_extraction( + self.host, self.platform_parsing_info["sync_devices"], self.command_outputs, job_debug=False + ) + expected_parsed_result = { + "device_type": "WS-C4948E", + "hostname": "dummy_rtr", + "mask_length": 16, + "mgmt_interface": "Vlan1", + "serial": "CAT1451S15C", + } + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_empty_command_result_str(self): + parsed_command_output = "" + actual_result = extract_and_post_process( + parsed_command_output, + self.platform_parsing_info["sync_devices"]["serial"], + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = ("", []) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_empty_command_result_list(self): + parsed_command_output = [] + actual_result = extract_and_post_process( + parsed_command_output, + self.platform_parsing_info["sync_devices"]["serial"], + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = ([], []) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_empty_command_result_dict(self): + parsed_command_output = {} + actual_result = extract_and_post_process( + parsed_command_output, + self.platform_parsing_info["sync_devices"]["serial"], + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = ({}, []) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_empty_command_result_str_with_iterable(self): + parsed_command_output = "" + actual_result = extract_and_post_process( + parsed_command_output, + self.platform_parsing_info["sync_devices"]["serial"], + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + "str", + False, + ) + expected_parsed_result = ("", "") + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_empty_command_result_list_with_iterable(self): + parsed_command_output = [] + actual_result = extract_and_post_process( + parsed_command_output, + self.platform_parsing_info["sync_devices"]["serial"], + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + "dict", + False, + ) + expected_parsed_result = ([], {}) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_empty_command_result_dict_with_iterable(self): + parsed_command_output = {} + actual_result = extract_and_post_process( + parsed_command_output, + self.platform_parsing_info["sync_devices"]["serial"], + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + "dict", + False, + ) + expected_parsed_result = ({}, {}) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_dict_with_iterable(self): + parsed_command_output = self.command_outputs["show version"] + actual_result = extract_and_post_process( + parsed_command_output, + self.platform_parsing_info["sync_devices"]["serial"]["commands"][0], + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = (["CAT1451S15C"], "CAT1451S15C") + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_json_string(self): + parsed_command_output = '{"foo": "bar"}' + actual_result = extract_and_post_process( + parsed_command_output, + { + "command": "show version", + "parser": "textfsm", + "jpath": "foo", + }, + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = ("bar", "bar") + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_python_dict(self): + parsed_command_output = {"foo": "bar"} + actual_result = extract_and_post_process( + parsed_command_output, + { + "command": "show version", + "parser": "textfsm", + "jpath": "foo", + }, + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = ("bar", "bar") + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_non_json_string(self): + parsed_command_output = "jeff" + actual_result = extract_and_post_process( + parsed_command_output, + { + "command": "show version", + "parser": "textfsm", + "jpath": "foo", + }, + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = ([], []) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_non_json_string_with_iterable(self): + parsed_command_output = "jeff" + actual_result = extract_and_post_process( + parsed_command_output, + { + "command": "show version", + "parser": "textfsm", + "jpath": "foo", + }, + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + "dict", + False, + ) + expected_parsed_result = ([], {}) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_list_to_dict(self): + parsed_command_output = [{"foo": {"bar": "moo"}}] + actual_result = extract_and_post_process( + parsed_command_output, + { + "command": "show version", + "parser": "textfsm", + "jpath": "[*].foo", + }, + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + "dict", + False, + ) + expected_parsed_result = ([{"bar": "moo"}], {"bar": "moo"}) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_list_to_string(self): + parsed_command_output = ["foo"] + actual_result = extract_and_post_process( + parsed_command_output, + { + "command": "show version", + "parser": "textfsm", + "jpath": "[*]", + }, + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + "str", + False, + ) + expected_parsed_result = (["foo"], "foo") + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_result_default_iterable(self): + parsed_command_output = [{"foo": {"bar": "moo"}}] + actual_result = extract_and_post_process( + parsed_command_output, + { + "command": "show version", + "parser": "textfsm", + "jpath": "[*].foo", + }, + {"obj": "1.1.1.1", "original_host": "1.1.1.1"}, + None, + False, + ) + expected_parsed_result = ([{"bar": "moo"}], [{"bar": "moo"}]) + self.assertEqual(expected_parsed_result, actual_result) + + def test_extract_and_post_process_sync_network_no_vlans_no_vrfs(self): + actual_result = perform_data_extraction( + self.host, self.platform_parsing_info["sync_network_data"], self.command_outputs, job_debug=False + ) + expected_parsed_result = { + "serial": "CAT1451S15C", + "interfaces": { + "GigabitEthernet0/0": { + "ip_addresses": [{"ip_address": "", "prefix_length": ""}], + "mac_address": "fa16.3e57.336f", + "mtu": "1500", + "description": "", + "link_status": "False", + "802.1Q_mode": "", + "lag": [], + "type": "other", + }, + "GigabitEthernet0/1": { + "802.1Q_mode": "tagged-all", + "description": "to iosvl2-2", + "ip_addresses": [{"ip_address": "", "prefix_length": ""}], + "lag": "Port-channel1", + "link_status": "True", + "mac_address": "fa16.3e4f.41cc", + "mtu": "1500", + "type": "other", + }, + "GigabitEthernet0/2": { + "802.1Q_mode": "access", + "description": ["to iosvl2-4", "Port"], + "ip_addresses": [{"ip_address": "", "prefix_length": ""}, {"ip_address": "", "prefix_length": ""}], + "lag": "Port-channel1", + "link_status": "True", + "mac_address": ["fa16.3ea3.3e49", "78da.6eaf.3b82"], + "mtu": ["1500", "1500"], + "type": "other", + }, + "GigabitEthernet0/3": { + "802.1Q_mode": "", + "description": "to iosvl2-3", + "ip_addresses": [{"ip_address": "", "prefix_length": ""}], + "lag": [], + "link_status": "True", + "mac_address": "fa16.3e31.2c47", + "mtu": "1500", + "type": "other", + }, + "GigabitEthernet1/0": { + "802.1Q_mode": "", + "description": "to iosvl2-3", + "ip_addresses": [{"ip_address": "", "prefix_length": ""}], + "lag": "Port-channel3", + "link_status": "True", + "mac_address": "fa16.3ec8.50ab", + "mtu": "1500", + "type": "other", + }, + "Loopback0": { + "802.1Q_mode": "", + "description": "Loopback", + "ip_addresses": [{"ip_address": "", "prefix_length": ""}], + "lag": [], + "link_status": "True", + "mac_address": "", + "mtu": "1514", + "type": "other", + }, + "Port-channel1": { + "802.1Q_mode": "", + "description": "", + "ip_addresses": [{"ip_address": "", "prefix_length": ""}], + "lag": [], + "link_status": "False", + "mac_address": "fa16.3e4f.41cc", + "mtu": "1500", + "type": "lag", + }, + "Port-channel3": { + "802.1Q_mode": "", + "description": "", + "ip_addresses": [{"ip_address": "", "prefix_length": ""}], + "lag": [], + "link_status": "False", + "mac_address": "fa16.3e4f.41c2", + "mtu": "1500", + "type": "lag", + }, + "Vlan1": { + "802.1Q_mode": "", + "description": "OOB Management", + "ip_addresses": [{"ip_address": "10.255.0.16", "prefix_length": "16"}], + "lag": [], + "link_status": "True", + "mac_address": "fa16.3e57.8001", + "mtu": "1500", + "type": "virtual", + }, + }, + } + self.assertEqual(expected_parsed_result, actual_result) From f4d1984656cdd8dedaf76207520afb6d630e51db Mon Sep 17 00:00:00 2001 From: Jeff Kala Date: Fri, 24 May 2024 09:43:46 -0500 Subject: [PATCH 2/4] remove merge conflict additions in processor, bandit cleanups --- development/docker-compose.base.yml | 1 - development/docker-compose.dev.yml | 1 - development/docker-compose.mysql.yml | 2 - development/docker-compose.postgres.yml | 2 - development/docker-compose.redis.yml | 1 - .../nornir_plays/formatter.py | 6 - .../nornir_plays/processor.py | 2 - .../tests/test_nornir_plays/test_formatter.py | 4 +- poetry.lock | 110 ++---------------- 9 files changed, 12 insertions(+), 117 deletions(-) diff --git a/development/docker-compose.base.yml b/development/docker-compose.base.yml index e6a6c59b..bdfbcdcc 100644 --- a/development/docker-compose.base.yml +++ b/development/docker-compose.base.yml @@ -13,7 +13,6 @@ x-nautobot-base: &nautobot-base - "creds.env" tty: true -version: "3.8" services: nautobot: depends_on: diff --git a/development/docker-compose.dev.yml b/development/docker-compose.dev.yml index 8855621a..ea6a6257 100644 --- a/development/docker-compose.dev.yml +++ b/development/docker-compose.dev.yml @@ -3,7 +3,6 @@ # any override will need to include these volumes to use them. # see: https://github.com/docker/compose/issues/3729 --- -version: "3.8" services: nautobot: command: "nautobot-server runserver 0.0.0.0:8080" diff --git a/development/docker-compose.mysql.yml b/development/docker-compose.mysql.yml index 062ada94..a8fe3129 100644 --- a/development/docker-compose.mysql.yml +++ b/development/docker-compose.mysql.yml @@ -1,6 +1,4 @@ --- -version: "3.8" - services: nautobot: environment: diff --git a/development/docker-compose.postgres.yml b/development/docker-compose.postgres.yml index 12d1de31..8d96fdba 100644 --- a/development/docker-compose.postgres.yml +++ b/development/docker-compose.postgres.yml @@ -1,6 +1,4 @@ --- -version: "3.8" - services: nautobot: environment: diff --git a/development/docker-compose.redis.yml b/development/docker-compose.redis.yml index 6da9fa01..b5e266a3 100644 --- a/development/docker-compose.redis.yml +++ b/development/docker-compose.redis.yml @@ -1,5 +1,4 @@ --- -version: "3.8" services: redis: image: "redis:6-alpine" diff --git a/nautobot_device_onboarding/nornir_plays/formatter.py b/nautobot_device_onboarding/nornir_plays/formatter.py index de6ef86a..d9ef04c7 100755 --- a/nautobot_device_onboarding/nornir_plays/formatter.py +++ b/nautobot_device_onboarding/nornir_plays/formatter.py @@ -116,12 +116,6 @@ def perform_data_extraction(host, command_info_dict, command_outputs_dict, job_d sync_vrfs = host.defaults.data.get("sync_vrfs", False) get_context_from_pre_processor = {} if command_info_dict.get("pre_processor"): - # pre_processor: - # vlan_map: - # commands: - # - command: "show vlan" - # parser: "textfsm" - # jpath: "[*].{id: vid, name: name}" for pre_processor_name, field_data in command_info_dict["pre_processor"].items(): if isinstance(field_data["commands"], dict): # only one command is specified as a dict force it to a list. diff --git a/nautobot_device_onboarding/nornir_plays/processor.py b/nautobot_device_onboarding/nornir_plays/processor.py index 80728269..5de57f0c 100755 --- a/nautobot_device_onboarding/nornir_plays/processor.py +++ b/nautobot_device_onboarding/nornir_plays/processor.py @@ -61,8 +61,6 @@ def task_instance_completed(self, task: Task, host: Host, result: MultiResult) - ready_for_ssot_data = extract_show_data( host, parsed_command_outputs, task.params["command_getter_job"], self.kwargs["debug"] ) - self.logger.debug(f"ready for ssot data {host.name} {ready_for_ssot_data}") - self.data[host.name].update(ready_for_ssot_data) if task.params["command_getter_job"] == "sync_devices": try: validate(ready_for_ssot_data, NETWORK_DEVICES_SCHEMA) diff --git a/nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py b/nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py index 74e3e8c6..11c058ac 100755 --- a/nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py +++ b/nautobot_device_onboarding/tests/test_nornir_plays/test_formatter.py @@ -23,14 +23,14 @@ def setUp(self): hostname="10.255.0.16", port=22, username="username", - password="password", + password="password", # nosec platform="cisco_ios", connection_options={ "netmiko": ConnectionOptions( hostname="10.255.0.16", port=22, username="username", - password="password", + password="password", # nosec platform="platform", ) }, diff --git a/poetry.lock b/poetry.lock index ddb307f2..cfb343d5 100755 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "amqp" @@ -1485,13 +1485,13 @@ six = ">=1.12" [[package]] name = "griffe" -version = "0.45.1" +version = "0.45.2" description = "Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API." optional = false python-versions = ">=3.8" files = [ - {file = "griffe-0.45.1-py3-none-any.whl", hash = "sha256:12194c10ae07a7f46708741ad78419362cf8e5c883f449c7c48de1686611b853"}, - {file = "griffe-0.45.1.tar.gz", hash = "sha256:84ce9243a9e63c07d55563a735a0d07ef70b46c455616c174010e7fc816f4648"}, + {file = "griffe-0.45.2-py3-none-any.whl", hash = "sha256:297ec8530d0c68e5b98ff86fb588ebc3aa3559bb5dc21f3caea8d9542a350133"}, + {file = "griffe-0.45.2.tar.gz", hash = "sha256:83ce7dcaafd8cb7f43cbf1a455155015a1eb624b1ffd93249e5e1c4a22b2fdb2"}, ] [package.dependencies] @@ -2339,15 +2339,12 @@ typing-extensions = ">=4.3.0" [[package]] name = "nautobot" version = "2.2.4" -version = "2.2.4" description = "Source of truth and network automation platform." optional = false python-versions = "<3.12,>=3.8" files = [ {file = "nautobot-2.2.4-py3-none-any.whl", hash = "sha256:2d27a99557b55475b0cdf3a4d9e04ab4cfd0a048d4a1e4bd3f6b63056b93c723"}, {file = "nautobot-2.2.4.tar.gz", hash = "sha256:a96f970d871e62153804a74693b5fe2f5406f87b2f0d5fffadddaabd69e47b90"}, - {file = "nautobot-2.2.4-py3-none-any.whl", hash = "sha256:2d27a99557b55475b0cdf3a4d9e04ab4cfd0a048d4a1e4bd3f6b63056b93c723"}, - {file = "nautobot-2.2.4.tar.gz", hash = "sha256:a96f970d871e62153804a74693b5fe2f5406f87b2f0d5fffadddaabd69e47b90"}, ] [package.dependencies] @@ -2379,7 +2376,6 @@ GitPython = ">=3.1.43,<3.2.0" graphene-django = ">=2.16.0,<2.17.0" graphene-django-optimizer = ">=0.8.0,<0.9.0" Jinja2 = ">=3.1.4,<3.2.0" -Jinja2 = ">=3.1.4,<3.2.0" jsonschema = ">=4.7.0,<5.0.0" Markdown = ">=3.5.2,<3.6.0" MarkupSafe = ">=2.1.5,<2.2.0" @@ -2897,15 +2893,12 @@ files = [ [[package]] name = "platformdirs" version = "4.2.2" -version = "4.2.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" files = [ {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, - {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, - {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, ] [package.extras] @@ -3615,7 +3608,6 @@ rpds-py = ">=0.7.0" [[package]] name = "regex" version = "2024.5.15" -version = "2024.5.15" description = "Alternative regular expression module, to replace re." optional = false python-versions = ">=3.8" @@ -3699,85 +3691,6 @@ files = [ {file = "regex-2024.5.15-cp39-cp39-win32.whl", hash = "sha256:71a455a3c584a88f654b64feccc1e25876066c4f5ef26cd6dd711308aa538694"}, {file = "regex-2024.5.15-cp39-cp39-win_amd64.whl", hash = "sha256:cab12877a9bdafde5500206d1020a584355a97884dfd388af3699e9137bf7388"}, {file = "regex-2024.5.15.tar.gz", hash = "sha256:d3ee02d9e5f482cc8309134a91eeaacbdd2261ba111b0fef3748eeb4913e6a2c"}, - {file = "regex-2024.5.15-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a81e3cfbae20378d75185171587cbf756015ccb14840702944f014e0d93ea09f"}, - {file = "regex-2024.5.15-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7b59138b219ffa8979013be7bc85bb60c6f7b7575df3d56dc1e403a438c7a3f6"}, - {file = "regex-2024.5.15-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a0bd000c6e266927cb7a1bc39d55be95c4b4f65c5be53e659537537e019232b1"}, - {file = "regex-2024.5.15-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5eaa7ddaf517aa095fa8da0b5015c44d03da83f5bd49c87961e3c997daed0de7"}, - {file = "regex-2024.5.15-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ba68168daedb2c0bab7fd7e00ced5ba90aebf91024dea3c88ad5063c2a562cca"}, - {file = "regex-2024.5.15-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6e8d717bca3a6e2064fc3a08df5cbe366369f4b052dcd21b7416e6d71620dca1"}, - {file = "regex-2024.5.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1337b7dbef9b2f71121cdbf1e97e40de33ff114801263b275aafd75303bd62b5"}, - {file = "regex-2024.5.15-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f9ebd0a36102fcad2f03696e8af4ae682793a5d30b46c647eaf280d6cfb32796"}, - {file = "regex-2024.5.15-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:9efa1a32ad3a3ea112224897cdaeb6aa00381627f567179c0314f7b65d354c62"}, - {file = "regex-2024.5.15-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:1595f2d10dff3d805e054ebdc41c124753631b6a471b976963c7b28543cf13b0"}, - {file = "regex-2024.5.15-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:b802512f3e1f480f41ab5f2cfc0e2f761f08a1f41092d6718868082fc0d27143"}, - {file = "regex-2024.5.15-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:a0981022dccabca811e8171f913de05720590c915b033b7e601f35ce4ea7019f"}, - {file = "regex-2024.5.15-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:19068a6a79cf99a19ccefa44610491e9ca02c2be3305c7760d3831d38a467a6f"}, - {file = "regex-2024.5.15-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:1b5269484f6126eee5e687785e83c6b60aad7663dafe842b34691157e5083e53"}, - {file = "regex-2024.5.15-cp310-cp310-win32.whl", hash = "sha256:ada150c5adfa8fbcbf321c30c751dc67d2f12f15bd183ffe4ec7cde351d945b3"}, - {file = "regex-2024.5.15-cp310-cp310-win_amd64.whl", hash = "sha256:ac394ff680fc46b97487941f5e6ae49a9f30ea41c6c6804832063f14b2a5a145"}, - {file = "regex-2024.5.15-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:f5b1dff3ad008dccf18e652283f5e5339d70bf8ba7c98bf848ac33db10f7bc7a"}, - {file = "regex-2024.5.15-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c6a2b494a76983df8e3d3feea9b9ffdd558b247e60b92f877f93a1ff43d26656"}, - {file = "regex-2024.5.15-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a32b96f15c8ab2e7d27655969a23895eb799de3665fa94349f3b2fbfd547236f"}, - {file = "regex-2024.5.15-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:10002e86e6068d9e1c91eae8295ef690f02f913c57db120b58fdd35a6bb1af35"}, - {file = "regex-2024.5.15-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ec54d5afa89c19c6dd8541a133be51ee1017a38b412b1321ccb8d6ddbeb4cf7d"}, - {file = "regex-2024.5.15-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:10e4ce0dca9ae7a66e6089bb29355d4432caed736acae36fef0fdd7879f0b0cb"}, - {file = "regex-2024.5.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3e507ff1e74373c4d3038195fdd2af30d297b4f0950eeda6f515ae3d84a1770f"}, - {file = "regex-2024.5.15-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d1f059a4d795e646e1c37665b9d06062c62d0e8cc3c511fe01315973a6542e40"}, - {file = "regex-2024.5.15-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:0721931ad5fe0dda45d07f9820b90b2148ccdd8e45bb9e9b42a146cb4f695649"}, - {file = "regex-2024.5.15-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:833616ddc75ad595dee848ad984d067f2f31be645d603e4d158bba656bbf516c"}, - {file = "regex-2024.5.15-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:287eb7f54fc81546346207c533ad3c2c51a8d61075127d7f6d79aaf96cdee890"}, - {file = "regex-2024.5.15-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:19dfb1c504781a136a80ecd1fff9f16dddf5bb43cec6871778c8a907a085bb3d"}, - {file = "regex-2024.5.15-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:119af6e56dce35e8dfb5222573b50c89e5508d94d55713c75126b753f834de68"}, - {file = "regex-2024.5.15-cp311-cp311-win32.whl", hash = "sha256:1c1c174d6ec38d6c8a7504087358ce9213d4332f6293a94fbf5249992ba54efa"}, - {file = "regex-2024.5.15-cp311-cp311-win_amd64.whl", hash = "sha256:9e717956dcfd656f5055cc70996ee2cc82ac5149517fc8e1b60261b907740201"}, - {file = "regex-2024.5.15-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:632b01153e5248c134007209b5c6348a544ce96c46005d8456de1d552455b014"}, - {file = "regex-2024.5.15-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e64198f6b856d48192bf921421fdd8ad8eb35e179086e99e99f711957ffedd6e"}, - {file = "regex-2024.5.15-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:68811ab14087b2f6e0fc0c2bae9ad689ea3584cad6917fc57be6a48bbd012c49"}, - {file = "regex-2024.5.15-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f8ec0c2fea1e886a19c3bee0cd19d862b3aa75dcdfb42ebe8ed30708df64687a"}, - {file = "regex-2024.5.15-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d0c0c0003c10f54a591d220997dd27d953cd9ccc1a7294b40a4be5312be8797b"}, - {file = "regex-2024.5.15-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2431b9e263af1953c55abbd3e2efca67ca80a3de8a0437cb58e2421f8184717a"}, - {file = "regex-2024.5.15-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a605586358893b483976cffc1723fb0f83e526e8f14c6e6614e75919d9862cf"}, - {file = "regex-2024.5.15-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:391d7f7f1e409d192dba8bcd42d3e4cf9e598f3979cdaed6ab11288da88cb9f2"}, - {file = "regex-2024.5.15-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:9ff11639a8d98969c863d4617595eb5425fd12f7c5ef6621a4b74b71ed8726d5"}, - {file = "regex-2024.5.15-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:4eee78a04e6c67e8391edd4dad3279828dd66ac4b79570ec998e2155d2e59fd5"}, - {file = "regex-2024.5.15-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:8fe45aa3f4aa57faabbc9cb46a93363edd6197cbc43523daea044e9ff2fea83e"}, - {file = "regex-2024.5.15-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:d0a3d8d6acf0c78a1fff0e210d224b821081330b8524e3e2bc5a68ef6ab5803d"}, - {file = "regex-2024.5.15-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c486b4106066d502495b3025a0a7251bf37ea9540433940a23419461ab9f2a80"}, - {file = "regex-2024.5.15-cp312-cp312-win32.whl", hash = "sha256:c49e15eac7c149f3670b3e27f1f28a2c1ddeccd3a2812cba953e01be2ab9b5fe"}, - {file = "regex-2024.5.15-cp312-cp312-win_amd64.whl", hash = "sha256:673b5a6da4557b975c6c90198588181029c60793835ce02f497ea817ff647cb2"}, - {file = "regex-2024.5.15-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:87e2a9c29e672fc65523fb47a90d429b70ef72b901b4e4b1bd42387caf0d6835"}, - {file = "regex-2024.5.15-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c3bea0ba8b73b71b37ac833a7f3fd53825924165da6a924aec78c13032f20850"}, - {file = "regex-2024.5.15-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:bfc4f82cabe54f1e7f206fd3d30fda143f84a63fe7d64a81558d6e5f2e5aaba9"}, - {file = "regex-2024.5.15-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e5bb9425fe881d578aeca0b2b4b3d314ec88738706f66f219c194d67179337cb"}, - {file = "regex-2024.5.15-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:64c65783e96e563103d641760664125e91bd85d8e49566ee560ded4da0d3e704"}, - {file = "regex-2024.5.15-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cf2430df4148b08fb4324b848672514b1385ae3807651f3567871f130a728cc3"}, - {file = "regex-2024.5.15-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5397de3219a8b08ae9540c48f602996aa6b0b65d5a61683e233af8605c42b0f2"}, - {file = "regex-2024.5.15-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:455705d34b4154a80ead722f4f185b04c4237e8e8e33f265cd0798d0e44825fa"}, - {file = "regex-2024.5.15-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:b2b6f1b3bb6f640c1a92be3bbfbcb18657b125b99ecf141fb3310b5282c7d4ed"}, - {file = "regex-2024.5.15-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:3ad070b823ca5890cab606c940522d05d3d22395d432f4aaaf9d5b1653e47ced"}, - {file = "regex-2024.5.15-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:5b5467acbfc153847d5adb21e21e29847bcb5870e65c94c9206d20eb4e99a384"}, - {file = "regex-2024.5.15-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:e6662686aeb633ad65be2a42b4cb00178b3fbf7b91878f9446075c404ada552f"}, - {file = "regex-2024.5.15-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:2b4c884767504c0e2401babe8b5b7aea9148680d2e157fa28f01529d1f7fcf67"}, - {file = "regex-2024.5.15-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:3cd7874d57f13bf70078f1ff02b8b0aa48d5b9ed25fc48547516c6aba36f5741"}, - {file = "regex-2024.5.15-cp38-cp38-win32.whl", hash = "sha256:e4682f5ba31f475d58884045c1a97a860a007d44938c4c0895f41d64481edbc9"}, - {file = "regex-2024.5.15-cp38-cp38-win_amd64.whl", hash = "sha256:d99ceffa25ac45d150e30bd9ed14ec6039f2aad0ffa6bb87a5936f5782fc1569"}, - {file = "regex-2024.5.15-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:13cdaf31bed30a1e1c2453ef6015aa0983e1366fad2667657dbcac7b02f67133"}, - {file = "regex-2024.5.15-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:cac27dcaa821ca271855a32188aa61d12decb6fe45ffe3e722401fe61e323cd1"}, - {file = "regex-2024.5.15-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7dbe2467273b875ea2de38ded4eba86cbcbc9a1a6d0aa11dcf7bd2e67859c435"}, - {file = "regex-2024.5.15-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:64f18a9a3513a99c4bef0e3efd4c4a5b11228b48aa80743be822b71e132ae4f5"}, - {file = "regex-2024.5.15-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d347a741ea871c2e278fde6c48f85136c96b8659b632fb57a7d1ce1872547600"}, - {file = "regex-2024.5.15-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1878b8301ed011704aea4c806a3cadbd76f84dece1ec09cc9e4dc934cfa5d4da"}, - {file = "regex-2024.5.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4babf07ad476aaf7830d77000874d7611704a7fcf68c9c2ad151f5d94ae4bfc4"}, - {file = "regex-2024.5.15-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:35cb514e137cb3488bce23352af3e12fb0dbedd1ee6e60da053c69fb1b29cc6c"}, - {file = "regex-2024.5.15-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:cdd09d47c0b2efee9378679f8510ee6955d329424c659ab3c5e3a6edea696294"}, - {file = "regex-2024.5.15-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:72d7a99cd6b8f958e85fc6ca5b37c4303294954eac1376535b03c2a43eb72629"}, - {file = "regex-2024.5.15-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:a094801d379ab20c2135529948cb84d417a2169b9bdceda2a36f5f10977ebc16"}, - {file = "regex-2024.5.15-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:c0c18345010870e58238790a6779a1219b4d97bd2e77e1140e8ee5d14df071aa"}, - {file = "regex-2024.5.15-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:16093f563098448ff6b1fa68170e4acbef94e6b6a4e25e10eae8598bb1694b5d"}, - {file = "regex-2024.5.15-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:e38a7d4e8f633a33b4c7350fbd8bad3b70bf81439ac67ac38916c4a86b465456"}, - {file = "regex-2024.5.15-cp39-cp39-win32.whl", hash = "sha256:71a455a3c584a88f654b64feccc1e25876066c4f5ef26cd6dd711308aa538694"}, - {file = "regex-2024.5.15-cp39-cp39-win_amd64.whl", hash = "sha256:cab12877a9bdafde5500206d1020a584355a97884dfd388af3699e9137bf7388"}, - {file = "regex-2024.5.15.tar.gz", hash = "sha256:d3ee02d9e5f482cc8309134a91eeaacbdd2261ba111b0fef3748eeb4913e6a2c"}, ] [[package]] @@ -4061,13 +3974,13 @@ files = [ [[package]] name = "scp" -version = "0.14.5" +version = "0.15.0" description = "scp module for paramiko" optional = false python-versions = "*" files = [ - {file = "scp-0.14.5-py2.py3-none-any.whl", hash = "sha256:d224535dd8ed00294f52b0e0e18fde7a6fb7a3d06b97ede9e3f750fa7bf75c09"}, - {file = "scp-0.14.5.tar.gz", hash = "sha256:64f0015899b3d212cb8088e7d40ebaf0686889ff0e243d5c1242efe8b50f053e"}, + {file = "scp-0.15.0-py2.py3-none-any.whl", hash = "sha256:9e7f721e5ac563c33eb0831d0f949c6342f1c28c3bdc3b02f39d77b5ea20df7e"}, + {file = "scp-0.15.0.tar.gz", hash = "sha256:f1b22e9932123ccf17eebf19e0953c6e9148f589f93d91b872941a696305c83f"}, ] [package.dependencies] @@ -4352,15 +4265,12 @@ test = ["argcomplete (>=3.0.3)", "mypy (>=1.7.0)", "pre-commit", "pytest (>=7.0, [[package]] name = "transitions" version = "0.9.1" -version = "0.9.1" description = "A lightweight, object-oriented Python state machine implementation with many extensions." optional = false python-versions = "*" files = [ {file = "transitions-0.9.1-py2.py3-none-any.whl", hash = "sha256:e76ad7bf44d46bd03bc50f269cebfa5affef28534c92b87b43e60b03d8925864"}, {file = "transitions-0.9.1.tar.gz", hash = "sha256:3542c37108e93e2ae5f215208ec5732c94a772937854a102cd7345b967fee61b"}, - {file = "transitions-0.9.1-py2.py3-none-any.whl", hash = "sha256:e76ad7bf44d46bd03bc50f269cebfa5affef28534c92b87b43e60b03d8925864"}, - {file = "transitions-0.9.1.tar.gz", hash = "sha256:3542c37108e93e2ae5f215208ec5732c94a772937854a102cd7345b967fee61b"}, ] [package.dependencies] @@ -4404,13 +4314,13 @@ docs = ["mkdocs (==1.2.4)", "mkdocs-material (==7.2.2)", "mkdocs-material-extens [[package]] name = "typing-extensions" -version = "4.11.0" +version = "4.12.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, - {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, + {file = "typing_extensions-4.12.0-py3-none-any.whl", hash = "sha256:b349c66bea9016ac22978d800cfff206d5f9816951f12a7d0ec5578b0a819594"}, + {file = "typing_extensions-4.12.0.tar.gz", hash = "sha256:8cbcdc8606ebcb0d95453ad7dc5065e6237b6aa230a31e81d0f440c30fed5fd8"}, ] [[package]] From 393edc272ef5970c23e71e674c3261954379ee3f Mon Sep 17 00:00:00 2001 From: Jeff Kala Date: Fri, 24 May 2024 09:51:41 -0500 Subject: [PATCH 3/4] pylint disables and formatting --- .../adapters/sync_network_data_adapters.py | 20 +++++++++---------- nautobot_device_onboarding/jobs.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nautobot_device_onboarding/diffsync/adapters/sync_network_data_adapters.py b/nautobot_device_onboarding/diffsync/adapters/sync_network_data_adapters.py index b0d735b8..1ad645b2 100644 --- a/nautobot_device_onboarding/diffsync/adapters/sync_network_data_adapters.py +++ b/nautobot_device_onboarding/diffsync/adapters/sync_network_data_adapters.py @@ -406,7 +406,7 @@ def load_devices(self): last_network_data_sync=datetime.datetime.now().date().isoformat(), ) self.add(network_device) - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception(error=err, hostname=hostname, data=device_data, model_type="device") continue # for interface in device_data["interfaces"]: @@ -467,7 +467,7 @@ def load_ip_addresses(self): "DiffSync store. This is a duplicate IP Address." ) continue - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="ip_address" ) @@ -496,7 +496,7 @@ def load_vlans(self): self.add(network_vlan) except diffsync.exceptions.ObjectAlreadyExists: continue - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="vlan" ) @@ -513,7 +513,7 @@ def load_vlans(self): self.add(network_vlan) except diffsync.exceptions.ObjectAlreadyExists: continue - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="vlan" ) @@ -536,7 +536,7 @@ def load_vrfs(self): self.add(network_vrf) except diffsync.exceptions.ObjectAlreadyExists: continue - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="vrf" ) @@ -559,7 +559,7 @@ def load_ip_address_to_interfaces(self): ), ) self.add(network_ip_address_to_interface) - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="ip_address to interface" ) @@ -578,7 +578,7 @@ def load_tagged_vlans_to_interface(self): tagged_vlans=interface_data["tagged_vlans"], ) self.add(network_tagged_vlans_to_interface) - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="tagged vlan to interface" ) @@ -597,7 +597,7 @@ def load_untagged_vlan_to_interface(self): untagged_vlan=interface_data["untagged_vlan"], ) self.add(network_untagged_vlan_to_interface) - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="untagged vlan to interface" ) @@ -616,7 +616,7 @@ def load_lag_to_interface(self): lag__interface__name=interface_data["lag"] if interface_data["lag"] else "", ) self.add(network_lag_to_interface) - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="lag to interface" ) @@ -635,7 +635,7 @@ def load_vrf_to_interface(self): vrf=interface_data["vrf"], ) self.add(network_vrf_to_interface) - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self._handle_general_load_exception( error=err, hostname=hostname, data=device_data, model_type="vrf to interface" ) diff --git a/nautobot_device_onboarding/jobs.py b/nautobot_device_onboarding/jobs.py index 0f76a5c5..cd1fb08a 100755 --- a/nautobot_device_onboarding/jobs.py +++ b/nautobot_device_onboarding/jobs.py @@ -629,7 +629,7 @@ def run( cf.content_types.add(ContentType.objects.get_for_model(Device)) if self.debug: self.logger.debug("Custom field found or created") - except Exception as err: + except Exception as err: # pylint: disable=broad-exception-caught self.logger.error(f"Failed to get or create last_network_data_sync custom field, {err}") return From 7471881bb10150b0e08ef56116d0709ad497e1ce Mon Sep 17 00:00:00 2001 From: Jeff Kala Date: Fri, 24 May 2024 11:22:20 -0500 Subject: [PATCH 4/4] add debug for ntc-template parsed result --- nautobot_device_onboarding/nornir_plays/processor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nautobot_device_onboarding/nornir_plays/processor.py b/nautobot_device_onboarding/nornir_plays/processor.py index 5de57f0c..75d45914 100755 --- a/nautobot_device_onboarding/nornir_plays/processor.py +++ b/nautobot_device_onboarding/nornir_plays/processor.py @@ -44,6 +44,10 @@ def task_instance_completed(self, task: Task, host: Host, result: MultiResult) - f"task_instance_completed Task Name: {task.name}", extra={"object": task.host}, ) + if self.kwargs["debug"]: + self.logger.debug( + f"task_instance_completed {task.host} Task result {result.result}.", extra={"object": task.host} + ) # If any main task resulted in a failed:True then add that key so ssot side can ignore that entry. if result[0].failed: if task.params["command_getter_job"] == "sync_devices":