diff --git a/.bandit.yml b/.bandit.yml index 6483944..0637a44 100644 --- a/.bandit.yml +++ b/.bandit.yml @@ -1,2 +1,2 @@ --- -skips: ["B101"] +skips: ["B101", "B113"] diff --git a/.pylintrc b/.pylintrc index d383bc5..f0c4188 100644 --- a/.pylintrc +++ b/.pylintrc @@ -143,7 +143,8 @@ disable=print-statement, comprehension-escape, import-error, too-many-lines, - too-many-return-statements + too-many-return-statements, + missing-timeout # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/99_clean_env.yml b/99_clean_env.yml index c4eb24d..feae3de 100644 --- a/99_clean_env.yml +++ b/99_clean_env.yml @@ -225,55 +225,41 @@ is_full_depth: "{{ item.full_depth }}" state: "{{ install_state }}" loop: - - { - "model": "IOSv", - "manufacturer": "Cisco", - "slug": "iosv", - "part_number": "iosv", - "full_depth": False, - } - - { - "model": "nxosv", - "manufacturer": "Cisco", - "slug": "nxosv", - "part_number": "nxosv", - "full_depth": False, - } - - { - "model": "nx-osv-chassis-nx-osv-supervisor-module", - "manufacturer": "Cisco", - "slug": "nx-osv-chassis-nx-osv-supervisor-module", - "part_number": "nx-osv-chassis-nx-osv-supervisor-module", - "full_depth": False, - } - - { - "model": "CSR1000v", - "manufacturer": "Cisco", - "slug": "csr1000v", - "part_number": "csr1000v", - "full_depth": False, - } - - { - "model": "ASAv", - "manufacturer": "Cisco", - "slug": "asav", - "part_number": "asav", - "full_depth": False, - } - - { - "model": "CustomServer", - "manufacturer": "CustomBuild", - "slug": "customserver", - "part_number": "home", - "full_depth": True, - } - - { - "model": "vEOS", - "manufacturer": "Arista", - "slug": "veos", - "part_number": "veos", - "full_depth": False, - } + - model: "IOSv" + manufacturer: "Cisco" + slug: "iosv" + part_number: "iosv" + full_depth: False + - model: "nxosv" + manufacturer: "Cisco" + slug: "nxosv" + part_number: "nxosv" + full_depth: False + - model: "nx-osv-chassis-nx-osv-supervisor-module" + manufacturer: "Cisco" + slug: "nx-osv-chassis-nx-osv-supervisor-module" + part_number: "nx-osv-chassis-nx-osv-supervisor-module" + full_depth: False + - model: "CSR1000v" + manufacturer: "Cisco" + slug: "csr1000v" + part_number: "csr1000v" + full_depth: False + - model: "ASAv" + manufacturer: "Cisco" + slug: "asav" + part_number: "asav" + full_depth: False + - model: "CustomServer" + manufacturer: "CustomBuild" + slug: "customserver" + part_number: "home" + full_depth: True + - model: "vEOS" + manufacturer: "Arista" + slug: "veos" + part_number: "veos" + full_depth: False tags: [devices] - name: "TASK 11: DELETE MANUFACTURERS" diff --git a/Dockerfile b/Dockerfile index ea51675..58e82f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,9 @@ -FROM python:3.9-slim-buster +FROM python:3.9 COPY . /local WORKDIR /local RUN apt-get update && apt-get install apt-utils -y RUN cat requirements.system | xargs apt-get install -y -RUN mkdir /opt/ntc-templates && \ - git clone https://github.com/networktocode/ntc-templates.git /opt/ntc-templates RUN pip install --no-cache -r requirements.txt RUN ansible-galaxy collection install -r requirements.yml diff --git a/Makefile b/Makefile index f0ae3d6..06f371c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ IMG_NAME=ntc-jv/ansible -IMG_VERSION=1.0.0 +IMG_VERSION=1.1.0 .DEFAULT_GOAL := test .PHONY: test @@ -24,9 +24,9 @@ pylint: lint: @echo "Starting lint" docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) yamllint --strict . - docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) ansible-lint . + # docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) ansible-lint . docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) make pylint - docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) black --check + docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) black --check . docker run -v $(shell pwd):/local $(IMG_NAME):$(IMG_VERSION) bandit --recursive --config .bandit.yml ./ @echo "Completed lint" diff --git a/plugins/filter/filter.py b/plugins/filter/filter.py index 2a9f285..f285d4f 100644 --- a/plugins/filter/filter.py +++ b/plugins/filter/filter.py @@ -220,9 +220,7 @@ def get_interface_id(vm_name, nautobot_url, nautobot_headers): Args: vm_name (string): Name of the VM """ - url = ( - f"{nautobot_url}/api/virtualization/interfaces/?virtual_machine={vm_name}" - ) + url = f"{nautobot_url}/api/virtualization/interfaces/?virtual_machine={vm_name}" result = requests.get(url, headers=nautobot_headers) return result.json()["results"][0]["id"] diff --git a/requirements.txt b/requirements.txt index ad74b64..f964535 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -ansible-base==2.10.11 -ansible-lint +ansible==2.9.27 +# ansible-lint bandit black paramiko @@ -7,5 +7,6 @@ pylint pynautobot pytest pytest-pythonpath +ntc-templates textfsm yamllint \ No newline at end of file diff --git a/tests/test_build_ipv4_from_facts.py b/tests/test_build_ipv4_from_facts.py index 81ceb75..461f6a6 100644 --- a/tests/test_build_ipv4_from_facts.py +++ b/tests/test_build_ipv4_from_facts.py @@ -3,6 +3,7 @@ """ from plugins.filter.filter import FilterModule + def test_build_ipv4_from_facts(): """ Unit test of building ipv4 facts @@ -13,50 +14,24 @@ def test_build_ipv4_from_facts(): "net__hostname": "nxos01", "net__os": "7.3(0)D1(1)", "net__platform": "NX-OSv Chassis", - "net_all_ipv4_addresses": [ - "172.31.1.101" - ], + "net_all_ipv4_addresses": ["172.31.1.101"], "net_all_ipv6_addresses": [], "net_api": "cliconf", "net_fan_info": [ - { - "hw_ver": "0.0", - "model": null, - "name": "ChassisFan1", - "status": "Ok" - }, - { - "hw_ver": "0.0", - "model": null, - "name": "ChassisFan2", - "status": "None" - }, - { - "hw_ver": "--", - "model": "--", - "name": "Fan_in_PS1", - "status": "Ok" - }, - { - "hw_ver": "--", - "model": "--", - "name": "Fan_in_PS2", - "status": "Failure" - } - ], - "net_features_enabled": [ - "privilege" - ], - "net_filesystems": [ - "bootflash:" + {"hw_ver": "0.0", "model": null, "name": "ChassisFan1", "status": "Ok"}, + {"hw_ver": "0.0", "model": null, "name": "ChassisFan2", "status": "None"}, + {"hw_ver": "--", "model": "--", "name": "Fan_in_PS1", "status": "Ok"}, + {"hw_ver": "--", "model": "--", "name": "Fan_in_PS2", "status": "Failure"}, ], + "net_features_enabled": ["privilege"], + "net_filesystems": ["bootflash:"], "net_gather_network_resources": [], "net_gather_subset": [ "hardware", "default", "legacy", "interfaces", - "features" + "features", ], "net_hostname": "nxos01", "net_image": "bootflash:///titanium-d1.7.3.0.D1.1.bin", @@ -69,7 +44,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/10": { "bandwidth": 1000000, @@ -79,7 +54,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/11": { "bandwidth": 1000000, @@ -89,7 +64,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/12": { "bandwidth": 1000000, @@ -99,7 +74,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/13": { "bandwidth": 1000000, @@ -109,7 +84,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/14": { "bandwidth": 1000000, @@ -119,7 +94,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/15": { "bandwidth": 1000000, @@ -129,7 +104,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/16": { "bandwidth": 1000000, @@ -139,7 +114,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/17": { "bandwidth": 1000000, @@ -149,7 +124,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/18": { "bandwidth": 1000000, @@ -159,7 +134,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/19": { "bandwidth": 1000000, @@ -169,7 +144,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/2": { "bandwidth": 1000000, @@ -179,7 +154,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/20": { "bandwidth": 1000000, @@ -189,7 +164,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/21": { "bandwidth": 1000000, @@ -199,7 +174,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/22": { "bandwidth": 1000000, @@ -209,7 +184,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/23": { "bandwidth": 1000000, @@ -219,7 +194,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/24": { "bandwidth": 1000000, @@ -229,7 +204,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/25": { "bandwidth": 1000000, @@ -239,7 +214,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/26": { "bandwidth": 1000000, @@ -249,7 +224,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/27": { "bandwidth": 1000000, @@ -259,7 +234,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/28": { "bandwidth": 1000000, @@ -269,7 +244,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/29": { "bandwidth": 1000000, @@ -279,7 +254,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/3": { "bandwidth": 1000000, @@ -289,7 +264,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/30": { "bandwidth": 1000000, @@ -299,7 +274,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/31": { "bandwidth": 1000000, @@ -309,7 +284,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/32": { "bandwidth": 1000000, @@ -319,7 +294,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/33": { "bandwidth": 1000000, @@ -329,7 +304,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/34": { "bandwidth": 1000000, @@ -339,7 +314,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/35": { "bandwidth": 1000000, @@ -349,7 +324,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/36": { "bandwidth": 1000000, @@ -359,7 +334,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/37": { "bandwidth": 1000000, @@ -369,7 +344,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/38": { "bandwidth": 1000000, @@ -379,7 +354,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/39": { "bandwidth": 1000000, @@ -389,7 +364,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/4": { "bandwidth": 1000000, @@ -399,7 +374,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/40": { "bandwidth": 1000000, @@ -409,7 +384,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/41": { "bandwidth": 1000000, @@ -419,7 +394,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/42": { "bandwidth": 1000000, @@ -429,7 +404,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/43": { "bandwidth": 1000000, @@ -439,7 +414,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/44": { "bandwidth": 1000000, @@ -449,7 +424,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/45": { "bandwidth": 1000000, @@ -459,7 +434,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/46": { "bandwidth": 1000000, @@ -469,7 +444,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/47": { "bandwidth": 1000000, @@ -479,7 +454,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/48": { "bandwidth": 1000000, @@ -489,7 +464,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/5": { "bandwidth": 1000000, @@ -499,7 +474,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/6": { "bandwidth": 1000000, @@ -509,7 +484,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/7": { "bandwidth": 1000000, @@ -519,7 +494,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/8": { "bandwidth": 1000000, @@ -529,7 +504,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet2/9": { "bandwidth": 1000000, @@ -539,7 +514,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/1": { "bandwidth": 1000000, @@ -549,7 +524,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/10": { "bandwidth": 1000000, @@ -559,7 +534,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/11": { "bandwidth": 1000000, @@ -569,7 +544,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/12": { "bandwidth": 1000000, @@ -579,7 +554,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/13": { "bandwidth": 1000000, @@ -589,7 +564,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/14": { "bandwidth": 1000000, @@ -599,7 +574,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/15": { "bandwidth": 1000000, @@ -609,7 +584,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/16": { "bandwidth": 1000000, @@ -619,7 +594,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/17": { "bandwidth": 1000000, @@ -629,7 +604,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/18": { "bandwidth": 1000000, @@ -639,7 +614,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/19": { "bandwidth": 1000000, @@ -649,7 +624,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/2": { "bandwidth": 1000000, @@ -659,7 +634,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/20": { "bandwidth": 1000000, @@ -669,7 +644,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/21": { "bandwidth": 1000000, @@ -679,7 +654,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/22": { "bandwidth": 1000000, @@ -689,7 +664,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/23": { "bandwidth": 1000000, @@ -699,7 +674,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/24": { "bandwidth": 1000000, @@ -709,7 +684,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/25": { "bandwidth": 1000000, @@ -719,7 +694,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/26": { "bandwidth": 1000000, @@ -729,7 +704,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/27": { "bandwidth": 1000000, @@ -739,7 +714,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/28": { "bandwidth": 1000000, @@ -749,7 +724,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/29": { "bandwidth": 1000000, @@ -759,7 +734,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/3": { "bandwidth": 1000000, @@ -769,7 +744,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/30": { "bandwidth": 1000000, @@ -779,7 +754,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/31": { "bandwidth": 1000000, @@ -789,7 +764,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/32": { "bandwidth": 1000000, @@ -799,7 +774,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/33": { "bandwidth": 1000000, @@ -809,7 +784,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/34": { "bandwidth": 1000000, @@ -819,7 +794,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/35": { "bandwidth": 1000000, @@ -829,7 +804,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/36": { "bandwidth": 1000000, @@ -839,7 +814,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/37": { "bandwidth": 1000000, @@ -849,7 +824,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/38": { "bandwidth": 1000000, @@ -859,7 +834,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/39": { "bandwidth": 1000000, @@ -869,7 +844,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/4": { "bandwidth": 1000000, @@ -879,7 +854,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/40": { "bandwidth": 1000000, @@ -889,7 +864,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/41": { "bandwidth": 1000000, @@ -899,7 +874,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/42": { "bandwidth": 1000000, @@ -909,7 +884,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/43": { "bandwidth": 1000000, @@ -919,7 +894,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/44": { "bandwidth": 1000000, @@ -929,7 +904,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/45": { "bandwidth": 1000000, @@ -939,7 +914,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/46": { "bandwidth": 1000000, @@ -949,7 +924,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/47": { "bandwidth": 1000000, @@ -959,7 +934,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/48": { "bandwidth": 1000000, @@ -969,7 +944,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/5": { "bandwidth": 1000000, @@ -979,7 +954,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/6": { "bandwidth": 1000000, @@ -989,7 +964,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/7": { "bandwidth": 1000000, @@ -999,7 +974,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/8": { "bandwidth": 1000000, @@ -1009,7 +984,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet3/9": { "bandwidth": 1000000, @@ -1019,7 +994,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/1": { "bandwidth": 1000000, @@ -1029,7 +1004,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/10": { "bandwidth": 1000000, @@ -1039,7 +1014,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/11": { "bandwidth": 1000000, @@ -1049,7 +1024,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/12": { "bandwidth": 1000000, @@ -1059,7 +1034,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/13": { "bandwidth": 1000000, @@ -1069,7 +1044,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/14": { "bandwidth": 1000000, @@ -1079,7 +1054,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/15": { "bandwidth": 1000000, @@ -1089,7 +1064,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/16": { "bandwidth": 1000000, @@ -1099,7 +1074,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/17": { "bandwidth": 1000000, @@ -1109,7 +1084,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/18": { "bandwidth": 1000000, @@ -1119,7 +1094,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/19": { "bandwidth": 1000000, @@ -1129,7 +1104,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/2": { "bandwidth": 1000000, @@ -1139,7 +1114,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/20": { "bandwidth": 1000000, @@ -1149,7 +1124,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/21": { "bandwidth": 1000000, @@ -1159,7 +1134,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/22": { "bandwidth": 1000000, @@ -1169,7 +1144,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/23": { "bandwidth": 1000000, @@ -1179,7 +1154,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/24": { "bandwidth": 1000000, @@ -1189,7 +1164,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/25": { "bandwidth": 1000000, @@ -1199,7 +1174,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/26": { "bandwidth": 1000000, @@ -1209,7 +1184,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/27": { "bandwidth": 1000000, @@ -1219,7 +1194,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/28": { "bandwidth": 1000000, @@ -1229,7 +1204,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/29": { "bandwidth": 1000000, @@ -1239,7 +1214,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/3": { "bandwidth": 1000000, @@ -1249,7 +1224,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/30": { "bandwidth": 1000000, @@ -1259,7 +1234,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/31": { "bandwidth": 1000000, @@ -1269,7 +1244,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/32": { "bandwidth": 1000000, @@ -1279,7 +1254,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/33": { "bandwidth": 1000000, @@ -1289,7 +1264,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/34": { "bandwidth": 1000000, @@ -1299,7 +1274,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/35": { "bandwidth": 1000000, @@ -1309,7 +1284,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/36": { "bandwidth": 1000000, @@ -1319,7 +1294,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/37": { "bandwidth": 1000000, @@ -1329,7 +1304,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/38": { "bandwidth": 1000000, @@ -1339,7 +1314,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/39": { "bandwidth": 1000000, @@ -1349,7 +1324,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/4": { "bandwidth": 1000000, @@ -1359,7 +1334,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/40": { "bandwidth": 1000000, @@ -1369,7 +1344,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/41": { "bandwidth": 1000000, @@ -1379,7 +1354,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/42": { "bandwidth": 1000000, @@ -1389,7 +1364,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/43": { "bandwidth": 1000000, @@ -1399,7 +1374,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/44": { "bandwidth": 1000000, @@ -1409,7 +1384,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/45": { "bandwidth": 1000000, @@ -1419,7 +1394,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/46": { "bandwidth": 1000000, @@ -1429,7 +1404,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/47": { "bandwidth": 1000000, @@ -1439,7 +1414,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/48": { "bandwidth": 1000000, @@ -1449,7 +1424,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/5": { "bandwidth": 1000000, @@ -1459,7 +1434,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/6": { "bandwidth": 1000000, @@ -1469,7 +1444,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/7": { "bandwidth": 1000000, @@ -1479,7 +1454,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/8": { "bandwidth": 1000000, @@ -1489,7 +1464,7 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "Ethernet4/9": { "bandwidth": 1000000, @@ -1499,22 +1474,19 @@ def test_build_ipv4_from_facts(): "mtu": "1500", "speed": "auto-speed", "state": "down", - "type": "Ethernet" + "type": "Ethernet", }, "mgmt0": { "bandwidth": 1000000, "duplex": "full", - "ipv4": { - "address": "172.31.1.101", - "masklen": 24 - }, + "ipv4": {"address": "172.31.1.101", "masklen": 24}, "macaddress": "0c25.ea9d.9000", "mode": "routed", "mtu": "1500", "speed": "1000 Mb/s", "state": "up", - "type": "Ethernet" - } + "type": "Ethernet", + }, }, "net_interfaces_list": [ "mgmt0", @@ -1661,44 +1633,44 @@ def test_build_ipv4_from_facts(): "Ethernet4/45", "Ethernet4/46", "Ethernet4/47", - "Ethernet4/48" + "Ethernet4/48", ], "net_license_hostid": "TBEA9D9000B", "net_memfree_mb": 982.23046875, "net_memtotal_mb": 2992.91015625, - "net_model": "NX-OSv Chassis (\"NX-OSv Supervisor Module\")", + "net_model": 'NX-OSv Chassis ("NX-OSv Supervisor Module")', "net_module": [ { "model": "N7K-SUP1", "ports": 0, "status": "active *", - "type": "NX-OSv Supervisor Module" + "type": "NX-OSv Supervisor Module", }, { "model": "N7K-F248XP-25", "ports": 48, "status": "ok", - "type": "NX-OSv Ethernet Module" + "type": "NX-OSv Ethernet Module", }, { "model": "N7K-F248XP-25", "ports": 48, "status": "ok", - "type": "NX-OSv Ethernet Module" + "type": "NX-OSv Ethernet Module", }, { "model": "N7K-F248XP-25", "ports": 48, "status": "ok", - "type": "NX-OSv Ethernet Module" - } + "type": "NX-OSv Ethernet Module", + }, ], "net_neighbors": { "mgmt0": [ { "host": "rtr-1.josh-v.com", "port": "GigabitEthernet0/1", - "sysname": "rtr-1.josh-v.com" + "sysname": "rtr-1.josh-v.com", } ] }, @@ -1709,24 +1681,22 @@ def test_build_ipv4_from_facts(): "model": "DS-CAC-845W", "number": 1, "status": "Ok", - "watts": "3274.32" + "watts": "3274.32", }, { "amps": "0.00", "model": "------------", "number": 2, "status": "Absent", - "watts": "0.00" - } + "watts": "0.00", + }, ], "net_python_version": "3.7.7", "net_serialnum": "TMEA9D9000B", "net_system": "nxos", "net_version": "7.3(0)D1(1)", - "net_vlan_list": [ - 1 - ], - "network_resources": {} + "net_vlan_list": [1], + "network_resources": {}, } test_data = { @@ -1735,25 +1705,16 @@ def test_build_ipv4_from_facts(): "192.168.0.167", "172.31.1.1", "10.100.1.1", - "10.50.50.1" + "10.50.50.1", ], "net_all_ipv6_addresses": [], "net_api": "cliconf", - "net_filesystems": [ - "flash0:" - ], + "net_filesystems": ["flash0:"], "net_filesystems_info": { - "flash0:": { - "spacefree_kb": 1948176.0, - "spacetotal_kb": 2092496.0 - } + "flash0:": {"spacefree_kb": 1948176.0, "spacetotal_kb": 2092496.0} }, "net_gather_network_resources": [], - "net_gather_subset": [ - "interfaces", - "default", - "hardware" - ], + "net_gather_subset": ["interfaces", "default", "hardware"], "net_hostname": "rtr-1", "net_image": "flash0:/vios-adventerprisek9-m", "net_interfaces": { @@ -1761,52 +1722,37 @@ def test_build_ipv4_from_facts(): "bandwidth": 1000000, "description": null, "duplex": "Auto", - "ipv4": [ - { - "address": "192.168.0.167", - "subnet": "24" - } - ], + "ipv4": [{"address": "192.168.0.167", "subnet": "24"}], "lineprotocol": "up", "macaddress": "0c25.ea08.4900", "mediatype": "RJ45", "mtu": 1500, "operstatus": "up", - "type": "iGbE" + "type": "iGbE", }, "GigabitEthernet0/1": { "bandwidth": 1000000, "description": null, "duplex": "Auto", - "ipv4": [ - { - "address": "172.31.1.1", - "subnet": "24" - } - ], + "ipv4": [{"address": "172.31.1.1", "subnet": "24"}], "lineprotocol": "up", "macaddress": "0c25.ea08.4901", "mediatype": "RJ45", "mtu": 1500, "operstatus": "up", - "type": "iGbE" + "type": "iGbE", }, "GigabitEthernet0/2": { "bandwidth": 1000000, "description": null, "duplex": "Auto", - "ipv4": [ - { - "address": "10.100.1.1", - "subnet": "24" - } - ], + "ipv4": [{"address": "10.100.1.1", "subnet": "24"}], "lineprotocol": "up", "macaddress": "0c25.ea08.4902", "mediatype": "RJ45", "mtu": 1500, "operstatus": "up", - "type": "iGbE" + "type": "iGbE", }, "GigabitEthernet0/3": { "bandwidth": 1000000, @@ -1818,25 +1764,20 @@ def test_build_ipv4_from_facts(): "mediatype": "RJ45", "mtu": 1500, "operstatus": "down", - "type": "iGbE" + "type": "iGbE", }, "Loopback0": { "bandwidth": 8000000, "description": null, "duplex": null, - "ipv4": [ - { - "address": "10.50.50.1", - "subnet": "32" - } - ], + "ipv4": [{"address": "10.50.50.1", "subnet": "32"}], "lineprotocol": "up", "macaddress": null, "mediatype": null, "mtu": 1514, "operstatus": "up", - "type": null - } + "type": null, + }, }, "net_iostype": "IOS", "net_memfree_mb": 253007.0703125, @@ -1844,52 +1785,32 @@ def test_build_ipv4_from_facts(): "net_model": "IOSv", "net_neighbors": { "GigabitEthernet0/0": [ - { - "host": "joshv-sw01.josh-v.com", - "port": "GigabitEthernet1/0/47" - } + {"host": "joshv-sw01.josh-v.com", "port": "GigabitEthernet1/0/47"} ], "GigabitEthernet0/1": [ - { - "host": "nxos01(TBEA9D9000B)", - "port": "mgmt0" - }, - { - "host": "nxos03(TBEAD8A300B)", - "port": "mgmt0" - }, - { - "host": "nxos04(TBEA22BA00B)", - "port": "mgmt0" - }, - { - "host": "nxos02(TBEA761700B)", - "port": "mgmt0" - } + {"host": "nxos01(TBEA9D9000B)", "port": "mgmt0"}, + {"host": "nxos03(TBEAD8A300B)", "port": "mgmt0"}, + {"host": "nxos04(TBEA22BA00B)", "port": "mgmt0"}, + {"host": "nxos02(TBEA761700B)", "port": "mgmt0"}, ], "GigabitEthernet0/2": [ - { - "host": "rtr-4.josh-v.com", - "port": "GigabitEthernet0/0" - } - ] + {"host": "rtr-4.josh-v.com", "port": "GigabitEthernet0/0"} + ], }, "net_python_version": "3.7.7", "net_serialnum": "9GRLJCPTN0VYA3VWS0V15", "net_system": "ios", "net_version": "15.6(1)T", - "network_resources": {} + "network_resources": {}, } expected_result = [ {"interface": "GigabitEthernet0/0", "address": "192.168.0.167/24"}, {"interface": "GigabitEthernet0/1", "address": "172.31.1.1/24"}, {"interface": "GigabitEthernet0/2", "address": "10.100.1.1/24"}, - {"interface": "Loopback0", "address": "10.50.50.1/32"} + {"interface": "Loopback0", "address": "10.50.50.1/32"}, ] - nxos_result = [ - {"interface": "mgmt0", "address": "172.31.1.101/24"} - ] + nxos_result = [{"interface": "mgmt0", "address": "172.31.1.101/24"}] assert FilterModule.build_ipv4_from_facts(test_data) == expected_result assert FilterModule.build_ipv4_from_facts(nxos_data) == nxos_result diff --git a/tests/test_get_ciscoios_serial_list.py b/tests/test_get_ciscoios_serial_list.py index 66bf642..0f338d3 100644 --- a/tests/test_get_ciscoios_serial_list.py +++ b/tests/test_get_ciscoios_serial_list.py @@ -1,11 +1,18 @@ from plugins.filter.filter import FilterModule ANSIBLE_FACTS_SINGLE = { - "net_all_ipv4_addresses": ["192.168.0.164", "172.31.1.1", "172.31.0.1", "10.50.50.1",], + "net_all_ipv4_addresses": [ + "192.168.0.164", + "172.31.1.1", + "172.31.0.1", + "10.50.50.1", + ], "net_all_ipv6_addresses": [], "net_api": "cliconf", "net_filesystems": ["flash0:"], - "net_filesystems_info": {"flash0:": {"spacefree_kb": 1948176.0, "spacetotal_kb": 2092496.0}}, + "net_filesystems_info": { + "flash0:": {"spacefree_kb": 1948176.0, "spacetotal_kb": 2092496.0} + }, "net_gather_network_resources": [], "net_gather_subset": ["hardware", "default", "interfaces"], "net_hostname": "BORDER", @@ -76,7 +83,9 @@ "net_memfree_mb": 253431.28125, "net_memtotal_mb": 315455.65625, "net_model": "IOSv", - "net_neighbors": {"GigabitEthernet0/2": [{"host": "wanrtr01.josh-v.com", "port": "Gi1"}]}, + "net_neighbors": { + "GigabitEthernet0/2": [{"host": "wanrtr01.josh-v.com", "port": "Gi1"}] + }, "net_python_version": "3.8.1", "net_serialnum": "98TM4IDVPLTBHYGPX4Q21", "net_system": "ios", @@ -85,11 +94,18 @@ } ANSIBLE_FACTS_THREE = { - "net_all_ipv4_addresses": ["192.168.0.164", "172.31.1.1", "172.31.0.1", "10.50.50.1",], + "net_all_ipv4_addresses": [ + "192.168.0.164", + "172.31.1.1", + "172.31.0.1", + "10.50.50.1", + ], "net_all_ipv6_addresses": [], "net_api": "cliconf", "net_filesystems": ["flash0:"], - "net_filesystems_info": {"flash0:": {"spacefree_kb": 1948176.0, "spacetotal_kb": 2092496.0}}, + "net_filesystems_info": { + "flash0:": {"spacefree_kb": 1948176.0, "spacetotal_kb": 2092496.0} + }, "net_gather_network_resources": [], "net_gather_subset": ["hardware", "default", "interfaces"], "net_hostname": "BORDER", @@ -160,7 +176,9 @@ "net_memfree_mb": 253431.28125, "net_memtotal_mb": 315455.65625, "net_model": "IOSv", - "net_neighbors": {"GigabitEthernet0/2": [{"host": "wanrtr01.josh-v.com", "port": "Gi1"}]}, + "net_neighbors": { + "GigabitEthernet0/2": [{"host": "wanrtr01.josh-v.com", "port": "Gi1"}] + }, "net_python_version": "3.8.1", "net_stacked_serialnums": ["98TM4IDVPLTBHYGPX4Q21", "NTCMSP1", "NTCDFW2"], "net_system": "ios", @@ -173,7 +191,9 @@ def test_get_ciscoios_serial_list_single_device(): """ Functional test of get_ciscoios_serial_list """ - assert FilterModule.get_ciscoios_serial_list(ANSIBLE_FACTS_SINGLE) == ["98TM4IDVPLTBHYGPX4Q21"] + assert FilterModule.get_ciscoios_serial_list(ANSIBLE_FACTS_SINGLE) == [ + "98TM4IDVPLTBHYGPX4Q21" + ] def test_get_ciscoios_serial_list_three_devices(): diff --git a/tests/test_get_role_from_hostname.py b/tests/test_get_role_from_hostname.py index 03cb407..4815b85 100644 --- a/tests/test_get_role_from_hostname.py +++ b/tests/test_get_role_from_hostname.py @@ -13,7 +13,7 @@ def test_get_role_from_hostname(): "rtr": "Router", "fw": "Firewall", "nxos": "Switch", - "veos": "Switch" + "veos": "Switch", } for text_in_name, device_role in device_test_mapping.items(): assert FilterModule.get_role_from_hostname(text_in_name) == device_role # nosec @@ -23,7 +23,7 @@ def test_get_role_from_hostname(): "rtr-1": "Router", "14-fw1": "Firewall", "dc01-nxos-02": "Switch", - "dc04-veos-14": "Switch" + "dc04-veos-14": "Switch", } for text_in_name, device_role in device_name_mapping.items():