nornir-collection 0.0.25__py3-none-any.whl → 0.0.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nornir_collection/cisco/configuration_management/utils.py +0 -2
- nornir_collection/netbox/inventory.py +1 -1
- nornir_collection/netbox/update_prefixes_ip_addresses.py +33 -31
- {nornir_collection-0.0.25.dist-info → nornir_collection-0.0.27.dist-info}/METADATA +1 -1
- {nornir_collection-0.0.25.dist-info → nornir_collection-0.0.27.dist-info}/RECORD +8 -8
- {nornir_collection-0.0.25.dist-info → nornir_collection-0.0.27.dist-info}/WHEEL +1 -1
- {nornir_collection-0.0.25.dist-info → nornir_collection-0.0.27.dist-info}/licenses/LICENSE +0 -0
- {nornir_collection-0.0.25.dist-info → nornir_collection-0.0.27.dist-info}/top_level.txt +0 -0
@@ -234,9 +234,7 @@ def add_interface_data(task: Task, interface: dict) -> dict:
|
|
234
234
|
"""
|
235
235
|
# If the interface is part of a Port-channel
|
236
236
|
if "lag" in interface and interface["lag"] is not None:
|
237
|
-
# Set the int_config_context of the Port-channel to the int_config_context of the interface
|
238
237
|
po_interface = [i for i in task.host["interfaces"] if i["name"] == interface["lag"]["name"]]
|
239
|
-
interface["int_config_context"] = po_interface[0]["int_config_context"]
|
240
238
|
interface["description"] = po_interface[0]["description"]
|
241
239
|
interface["portchannel_number"] = extract_interface_number(interface["lag"]["name"])
|
242
240
|
|
@@ -92,7 +92,7 @@ def _load_interface_data(task: Task, all_interfaces: List[Dict], enrich_vlan_dat
|
|
92
92
|
# fmt: off
|
93
93
|
include_keys = [
|
94
94
|
"name", "int_template", "description", "type", "lag", "mode", "untagged_vlan", "tagged_vlans",
|
95
|
-
"count_ipaddresses", "count_fhrp_groups", "int_peer_device", "
|
95
|
+
"count_ipaddresses", "count_fhrp_groups", "int_peer_device", "enabled",
|
96
96
|
]
|
97
97
|
# fmt: on
|
98
98
|
# Make some normalization to the device interfaces data with the interface_filter list and others
|
@@ -306,6 +306,24 @@ def nmap_scan_host_ip_or_subnet(hosts: str) -> list:
|
|
306
306
|
return nmap_scan_result
|
307
307
|
|
308
308
|
|
309
|
+
def nmap_double_check_ips(ip_list: dict) -> list:
|
310
|
+
"""
|
311
|
+
TBD
|
312
|
+
"""
|
313
|
+
verified_ips = []
|
314
|
+
# Nmap scan ip-addresses of the maybe_delete_ips list
|
315
|
+
for ip in ip_list:
|
316
|
+
# Scan the prefix with nmap
|
317
|
+
scan_result = nmap_scan_host_ip_or_subnet(hosts=ip["address"])
|
318
|
+
# Add the nmap scan result to the inactive_ips list with the ID of the ip-address
|
319
|
+
if scan_result:
|
320
|
+
# As a single ip-address is scanned the scan_result can have only one list item
|
321
|
+
verified_ips.append({"id": ip["id"], **scan_result[0]})
|
322
|
+
|
323
|
+
# Return the verified ip-addresses list
|
324
|
+
return verified_ips
|
325
|
+
|
326
|
+
|
309
327
|
def get_ipfabric_data_for_prefix(prefix: dict) -> tuple:
|
310
328
|
"""
|
311
329
|
TBD
|
@@ -568,18 +586,9 @@ def delete_inactive_auto_discovered_ip_addresses(
|
|
568
586
|
task_text = "Delete Auto-Discovered IP-Addresses"
|
569
587
|
|
570
588
|
# Delete the ip-addresses with the status 'auto_discovered' that are not in the datasource list
|
571
|
-
|
589
|
+
delete_ips = create_ip_list(
|
572
590
|
loop_list=prefix["discovered_ips"], check_list=prefix["datasource_ips"], is_in_both=False
|
573
591
|
)
|
574
|
-
delete_ips = []
|
575
|
-
if maybe_delete_ips:
|
576
|
-
# Nmap scan ip-addresses of the maybe_delete_ips list
|
577
|
-
for ip in maybe_delete_ips:
|
578
|
-
# Scan the prefix with nmap
|
579
|
-
scan_result = nmap_scan_host_ip_or_subnet(hosts=ip["address"])
|
580
|
-
# Add the nmal scan result to the inactive_ips list
|
581
|
-
if scan_result:
|
582
|
-
delete_ips.extend(scan_result)
|
583
592
|
|
584
593
|
# If ip-addresses have been found
|
585
594
|
if delete_ips:
|
@@ -659,14 +668,9 @@ def update_inactive_ip_addresses(nb_url: str, prefix: dict, ds: Literal["nmap",
|
|
659
668
|
maybe_active_ips = create_ip_list(
|
660
669
|
loop_list=prefix["inactive_ips"], check_list=prefix["datasource_ips"], is_in_both=False
|
661
670
|
)
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
# Scan the prefix with nmap
|
666
|
-
scan_result = nmap_scan_host_ip_or_subnet(hosts=ip["address"])
|
667
|
-
# Add the nmal scan result to the inactive_ips list
|
668
|
-
if scan_result:
|
669
|
-
active_ips.extend(scan_result)
|
671
|
+
# Nmap scan ip-addresses of the maybe_active_ips list
|
672
|
+
nmap_result = nmap_double_check_ips(ip_list=maybe_active_ips)
|
673
|
+
active_ips.extend(nmap_result)
|
670
674
|
|
671
675
|
# If ip-addresses have been found
|
672
676
|
if active_ips:
|
@@ -722,23 +726,18 @@ def update_active_ip_addresses(
|
|
722
726
|
resp=resp, nb_type="ip", data=active_ips, ds=ds, task_text=task_text, text=text
|
723
727
|
)
|
724
728
|
result.extend(sub_result)
|
725
|
-
|
729
|
+
if sub_failed:
|
730
|
+
failed = True
|
731
|
+
result.append(f"-> Payload:\n{payload}")
|
726
732
|
|
727
733
|
# Update the ip-addresses with the status 'active' that are not part of the datacenter list
|
728
734
|
maybe_inactive_ips = create_ip_list(
|
729
735
|
loop_list=prefix["active_ips"], check_list=prefix["datasource_ips"], is_in_both=False
|
730
736
|
)
|
731
|
-
|
732
|
-
|
733
|
-
# Nmap scan ip-addresses of the maybe_inactive_ips list
|
734
|
-
for ip in maybe_inactive_ips:
|
735
|
-
# Scan the prefix with nmap
|
736
|
-
scan_result = nmap_scan_host_ip_or_subnet(hosts=ip["address"])
|
737
|
-
# Add the nmal scan result to the inactive_ips list
|
738
|
-
if scan_result:
|
739
|
-
inactive_ips.extend(scan_result)
|
737
|
+
# Nmap scan ip-addresses of the maybe_inactive_ips list
|
738
|
+
nmap_result = nmap_double_check_ips(ip_list=maybe_inactive_ips)
|
740
739
|
# Create a new list to exclude the overwrite_active ip-addresses
|
741
|
-
inactive_ips = [ip for ip in
|
740
|
+
inactive_ips = [ip for ip in nmap_result if ip["address"] not in overwrite_active]
|
742
741
|
|
743
742
|
# If ip-addresses have been found
|
744
743
|
if inactive_ips:
|
@@ -756,7 +755,10 @@ def update_active_ip_addresses(
|
|
756
755
|
resp=resp, nb_type="ip", data=inactive_ips, ds=ds, task_text=task_text, text=text
|
757
756
|
)
|
758
757
|
result.extend(sub_result)
|
759
|
-
|
758
|
+
if sub_failed:
|
759
|
+
failed = True
|
760
|
+
result.append(f"-> Data for Payload:\n{inactive_ips}")
|
761
|
+
result.append(f"-> Payload:\n{payload}")
|
760
762
|
|
761
763
|
return result, failed
|
762
764
|
|
@@ -823,7 +825,7 @@ def update_netbox_prefix_ip_addresses(prefix: list, *args) -> tuple:
|
|
823
825
|
result, sub_failed = update_discovered_ip_addresses(nb_url=nb_url, prefix=prefix, ds=ds)
|
824
826
|
results, changed, failed = set_results_changed_failed(results, result, changed, sub_failed, failed)
|
825
827
|
|
826
|
-
# Delete inactive 'auto-discovered' ip-addresses
|
828
|
+
# Delete inactive 'auto-discovered' ip-addresses
|
827
829
|
result, sub_failed = delete_inactive_auto_discovered_ip_addresses(nb_url=nb_url, prefix=prefix, ds=ds)
|
828
830
|
results, changed, failed = set_results_changed_failed(results, result, changed, sub_failed, failed)
|
829
831
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nornir-collection
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.27
|
4
4
|
Summary: Nornir-Collection contains network automation functions and complete IaC workflows with Nornir and other python libraries. It contains Nornir tasks and general functions in Nornir style.
|
5
5
|
Author: Willi Kubny
|
6
6
|
Author-email: willi.kubny@gmail.ch
|
@@ -8,7 +8,7 @@ nornir_collection/cisco/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
8
8
|
nornir_collection/cisco/configuration_management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
nornir_collection/cisco/configuration_management/processor.py,sha256=KjhilyyDDiYL7wFemGEWSP16OLeM4dENmrtb20LRssY,6443
|
10
10
|
nornir_collection/cisco/configuration_management/pyats.py,sha256=j9XzG3ttURR0wtu2Se9QQEpG5o2kq9mqDkReNCdWKpk,8932
|
11
|
-
nornir_collection/cisco/configuration_management/utils.py,sha256=
|
11
|
+
nornir_collection/cisco/configuration_management/utils.py,sha256=YZE3pgaA4kKnIQkkLenUhxLoYLi1sd0sa4jNfSulC34,18452
|
12
12
|
nornir_collection/cisco/configuration_management/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
nornir_collection/cisco/configuration_management/cli/config_tasks.py,sha256=mWXysgUm6ymNLQjomB1T05QT9A-fdV1aEKFzzDrfCUw,22147
|
14
14
|
nornir_collection/cisco/configuration_management/cli/config_workflow.py,sha256=GIka5SPLZ7M2zCFv8Jadl73QC-InnGopzI8xQt36MfM,3459
|
@@ -35,13 +35,13 @@ nornir_collection/fortinet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
35
35
|
nornir_collection/fortinet/utils.py,sha256=xkvxdJy3-aD39WK_9Gc0rY9r-OxfHnPVNMspy3KZbcE,1174
|
36
36
|
nornir_collection/netbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
37
|
nornir_collection/netbox/custom_script.py,sha256=yU1lbv_25b3qAWA6GRsVYpEuh0KUPTVo47U5s_lksjo,4050
|
38
|
-
nornir_collection/netbox/inventory.py,sha256=
|
38
|
+
nornir_collection/netbox/inventory.py,sha256=4KrmvHrY29PH9prs7D_oTfraUDg1svDbXEamaAxev1M,15507
|
39
39
|
nornir_collection/netbox/set_device_status.py,sha256=vtn0KcR-91Z2aLjbEpZRef1Jip8eM9GWbKRiAJuEjLY,2437
|
40
40
|
nornir_collection/netbox/sync_datasource.py,sha256=eEsgwy_arIPbA-ObqqzTNdU9aiP80s7LCzAKA6hCXYQ,4703
|
41
41
|
nornir_collection/netbox/update_cisco_inventory_data.py,sha256=Aq4VGvAIiBhOCsSOF-wBUrpYtBXR8HwR3NCWEeM4d0g,6426
|
42
42
|
nornir_collection/netbox/update_cisco_support_plugin_data.py,sha256=H8SfqESad64LrZrsWOaICHKj122sgu96dK9RcbvtzGM,13896
|
43
43
|
nornir_collection/netbox/update_fortinet_inventory_data.py,sha256=ltwkE_bFljRUR4aeOxorChCsHdZciD1TqvoPnWTUIUg,6367
|
44
|
-
nornir_collection/netbox/update_prefixes_ip_addresses.py,sha256=
|
44
|
+
nornir_collection/netbox/update_prefixes_ip_addresses.py,sha256=agLfgxEUvNeaQyFCILTKonlgl97b4qa6kyh0bZ3Fy9Y,49559
|
45
45
|
nornir_collection/netbox/update_purestorage_inventory_data.py,sha256=cGZNMTZWJ0wu1BYdE92EVN-C-oLMJHxaKi_-1cMg0Ow,5368
|
46
46
|
nornir_collection/netbox/utils.py,sha256=mCV7QfLeR6kKurZVpMrHucIoru759RiwzE4NGEx91kI,12140
|
47
47
|
nornir_collection/netbox/verify_device_primary_ip.py,sha256=6UCdZaZxhV4v8KqpjSpE9c7jaxIAF2krrknrrRj1AvM,8690
|
@@ -52,8 +52,8 @@ nornir_collection/nornir_plugins/inventory/staggered_yaml.py,sha256=nBvUFq7U5zVT
|
|
52
52
|
nornir_collection/nornir_plugins/inventory/utils.py,sha256=mxIlKK-4PHqCnFKn7Oozu1RW_JB5z1TgEYc-ave70nE,11822
|
53
53
|
nornir_collection/purestorage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
54
|
nornir_collection/purestorage/utils.py,sha256=TqU2sKz0ENnmSDEBcSvXPnVkI1DVHOogI68D7l32g7I,1730
|
55
|
-
nornir_collection-0.0.
|
56
|
-
nornir_collection-0.0.
|
57
|
-
nornir_collection-0.0.
|
58
|
-
nornir_collection-0.0.
|
59
|
-
nornir_collection-0.0.
|
55
|
+
nornir_collection-0.0.27.dist-info/licenses/LICENSE,sha256=bOPVh1OVNwz2tCjkLaChWT6AoXdtqye3aua5l0tgYJo,1068
|
56
|
+
nornir_collection-0.0.27.dist-info/METADATA,sha256=5l8h-vtbva2ts5Ubx-YF3Mzh77lqHZKy2xW_XqrISmo,7191
|
57
|
+
nornir_collection-0.0.27.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
58
|
+
nornir_collection-0.0.27.dist-info/top_level.txt,sha256=OyCzPWABf-D0AOHm9ihrwdk5eq200BnKna6gIDspwsE,18
|
59
|
+
nornir_collection-0.0.27.dist-info/RECORD,,
|
File without changes
|
File without changes
|