nornir-collection 0.0.15__py3-none-any.whl → 0.0.17__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/netbox/update_prefixes_ip_addresses.py +32 -16
- {nornir_collection-0.0.15.dist-info → nornir_collection-0.0.17.dist-info}/METADATA +1 -1
- {nornir_collection-0.0.15.dist-info → nornir_collection-0.0.17.dist-info}/RECORD +6 -6
- {nornir_collection-0.0.15.dist-info → nornir_collection-0.0.17.dist-info}/LICENSE +0 -0
- {nornir_collection-0.0.15.dist-info → nornir_collection-0.0.17.dist-info}/WHEEL +0 -0
- {nornir_collection-0.0.15.dist-info → nornir_collection-0.0.17.dist-info}/top_level.txt +0 -0
@@ -304,32 +304,40 @@ def nmap_scan_prefix(prefix: dict, result: list) -> tuple:
|
|
304
304
|
return result, prefix
|
305
305
|
|
306
306
|
|
307
|
-
def get_ipfabric_data_for_prefix(prefix: dict, result: list) -> tuple:
|
307
|
+
def get_ipfabric_data_for_prefix(ipf: IPFClient, prefix: dict, result: list) -> tuple:
|
308
308
|
"""
|
309
309
|
TBD
|
310
310
|
"""
|
311
|
-
# Connect to IP-Fabric
|
312
|
-
ipf = IPFClient(
|
313
|
-
base_url=os.environ["IPF_URL"], auth=os.environ["IPF_TOKEN"], snapshot_id="$last", verify=False
|
314
|
-
)
|
315
|
-
|
316
311
|
# Get the prefix length from the prefix
|
317
312
|
prefixlen = ipaddress.ip_network(prefix["prefix"]).prefixlen
|
318
313
|
# Get all ip-addresses of the prefix from the IP-Fabric technology arp table
|
319
314
|
# Remove duplicate ip-addresses as the arp table can contain multiple entries for the same ip-address
|
320
315
|
filters = {"ip": ["cidr", prefix["prefix"]]}
|
321
|
-
|
316
|
+
arp_ip_list = list(set([x["ip"] for x in ipf.technology.addressing.arp_table.all(filters=filters)]))
|
317
|
+
# Get all ip-addresses of the prefix from the IP-Fabric inventory managed ipv4 table
|
318
|
+
managed_ipv4_ip_list = list(
|
319
|
+
set([x["ip"] for x in ipf.technology.addressing.managed_ip_ipv4.all(filters=filters, columns=["ip"])])
|
320
|
+
)
|
321
|
+
# Get all ip-addresses of the prefix from the IP-Fabric inventory interface table
|
322
|
+
filters = {"loginIp": ["cidr", prefix["prefix"]]}
|
323
|
+
interface_ip_list = list(
|
324
|
+
set([x["loginIp"] for x in ipf.inventory.interfaces.all(filters=filters, columns=["loginIp"])])
|
325
|
+
)
|
322
326
|
# Get all ip-addresses of the prefix from the IP-Fabric inventory hosts table
|
323
327
|
# Set the ip-address as key to access the dict easier later
|
328
|
+
filters = {"ip": ["cidr", prefix["prefix"]]}
|
324
329
|
columns = ["ip", "dnsName"]
|
325
|
-
|
330
|
+
host_ip_dict = {
|
326
331
|
x["ip"]: x["dnsName"] or "" for x in ipf.inventory.hosts.all(filters=filters, columns=columns)
|
327
332
|
}
|
333
|
+
host_ip_list = list(host_ip_dict.keys())
|
334
|
+
# Combine all ip-addresses lists and remove duplicates
|
335
|
+
all_ips = list(set(arp_ip_list + managed_ipv4_ip_list + interface_ip_list + host_ip_list))
|
328
336
|
# Add a list of all ip-addresses and other details to prefix
|
329
337
|
prefix["datasource_ips"] = [
|
330
338
|
{
|
331
339
|
"address": f"{ip}/{prefixlen}",
|
332
|
-
"dns_name":
|
340
|
+
"dns_name": host_ip_dict[ip] if ip in host_ip_dict.keys() else "",
|
333
341
|
"ports": {},
|
334
342
|
}
|
335
343
|
for ip in all_ips
|
@@ -368,8 +376,12 @@ def get_nb_ips_and_external_datasource(nb_url: str, prefix: dict, ds: Literal["n
|
|
368
376
|
# Scan the prefix with nmap
|
369
377
|
result, prefix = nmap_scan_prefix(prefix=prefix, result=result)
|
370
378
|
elif ds == "ip-fabric":
|
379
|
+
# Connect to IP-Fabric
|
380
|
+
ipf = IPFClient(
|
381
|
+
base_url=os.environ["IPF_URL"], auth=os.environ["IPF_TOKEN"], snapshot_id="$last", verify=False
|
382
|
+
)
|
371
383
|
# Get the ip-addresses from the IP-Fabric
|
372
|
-
result, prefix = get_ipfabric_data_for_prefix(prefix=prefix, result=result)
|
384
|
+
result, prefix = get_ipfabric_data_for_prefix(ipf=ipf, prefix=prefix, result=result)
|
373
385
|
else:
|
374
386
|
# Invalid datasource
|
375
387
|
failed = True
|
@@ -1026,9 +1038,13 @@ def main(nr_config: str, nmap_scan: bool = False, overwrite_active: list[str] =
|
|
1026
1038
|
# Load Active and Inventory NetBox Prefixes from all Tenants (except marked utilized)
|
1027
1039
|
# These prefixes will be updated with input from IP-Fabric
|
1028
1040
|
nb_active_inventory_t3_t4_prefixes = load_netbox_data(
|
1029
|
-
task_text="Load Active
|
1041
|
+
task_text="Load Active OOB/T1/T2/T3/T4 NetBox Prefixes",
|
1030
1042
|
nb_api_url=f"{nb_url}/api/ipam/prefixes/",
|
1031
|
-
query={
|
1043
|
+
query={
|
1044
|
+
"status": "active",
|
1045
|
+
"tenant": ["none", "oob", "tier-1", "tier-2", "tier-3", "tier-4"],
|
1046
|
+
"mark_utilized": "false",
|
1047
|
+
},
|
1032
1048
|
)
|
1033
1049
|
|
1034
1050
|
# Load NetBox Non-Container Prefixes
|
@@ -1068,7 +1084,7 @@ def main(nr_config: str, nmap_scan: bool = False, overwrite_active: list[str] =
|
|
1068
1084
|
#### IP-Fabric Update Active & Inventory NetBox Prefixes IP-Addresses ###################################
|
1069
1085
|
|
1070
1086
|
# Set the task title
|
1071
|
-
title = "IP-Fabric Update Active
|
1087
|
+
title = "IP-Fabric Update Active OOB/T1/T2/T3/T4 NetBox Prefixes IP-Addresses"
|
1072
1088
|
|
1073
1089
|
# Run the thread pool to update all NetBox IP-Addresses Status and DNS-Name
|
1074
1090
|
# 1. arg is the input type ('nmap' or 'ip-fabric')
|
@@ -1077,7 +1093,7 @@ def main(nr_config: str, nmap_scan: bool = False, overwrite_active: list[str] =
|
|
1077
1093
|
title=title,
|
1078
1094
|
task=update_netbox_prefix_ip_addresses,
|
1079
1095
|
thread_list=nb_active_inventory_t3_t4_prefixes,
|
1080
|
-
max_workers=
|
1096
|
+
max_workers=5,
|
1081
1097
|
args=("ip-fabric", overwrite_active),
|
1082
1098
|
)
|
1083
1099
|
# Print the thread pool results and exit the script if any task has failed
|
@@ -1092,7 +1108,7 @@ def main(nr_config: str, nmap_scan: bool = False, overwrite_active: list[str] =
|
|
1092
1108
|
thread_result = run_thread_pool(
|
1093
1109
|
title=title,
|
1094
1110
|
task=update_all_netbox_ip_addresses,
|
1095
|
-
max_workers=
|
1111
|
+
max_workers=50,
|
1096
1112
|
thread_list=nb_subnet_prefixes,
|
1097
1113
|
)
|
1098
1114
|
# Print the thread pool results and exit the script if any task has failed
|
@@ -1107,7 +1123,7 @@ def main(nr_config: str, nmap_scan: bool = False, overwrite_active: list[str] =
|
|
1107
1123
|
thread_result = run_thread_pool(
|
1108
1124
|
title=title,
|
1109
1125
|
task=update_all_netbox_vlans,
|
1110
|
-
max_workers=
|
1126
|
+
max_workers=50,
|
1111
1127
|
thread_list=nb_vlans,
|
1112
1128
|
)
|
1113
1129
|
# Print the thread pool results and exit the script if any task has failed
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nornir-collection
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.17
|
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
|
@@ -41,7 +41,7 @@ nornir_collection/netbox/sync_datasource.py,sha256=eEsgwy_arIPbA-ObqqzTNdU9aiP80
|
|
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=Yg4dT1yM6pGG2fJ3Jhs8NbUfx8PrP-Z1fMolMi-n0LE,47712
|
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.17.dist-info/LICENSE,sha256=bOPVh1OVNwz2tCjkLaChWT6AoXdtqye3aua5l0tgYJo,1068
|
56
|
+
nornir_collection-0.0.17.dist-info/METADATA,sha256=qEt8mAj-sTHDFo58-xL1YORM_RjS2Stn09R1NuinzF0,7169
|
57
|
+
nornir_collection-0.0.17.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
58
|
+
nornir_collection-0.0.17.dist-info/top_level.txt,sha256=OyCzPWABf-D0AOHm9ihrwdk5eq200BnKna6gIDspwsE,18
|
59
|
+
nornir_collection-0.0.17.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|