@@ -99,22 +99,22 @@ def get_inventory_data(ws, **kwargs):
99
99
100
100
@timeit
101
101
def get_segments_data (ws ):
102
- segments = list ()
102
+ segments = []
103
+ network_ip = ""
103
104
for row in itertools .islice (ws .iter_rows (), 1 , None ):
104
105
if not row [2 ].value :
105
106
continue
106
- segments .append (
107
- data_types .Segment (
108
- name = row [0 ].value ,
109
- description = row [1 ].value ,
110
- network = row [2 ].value ,
111
- color = [copy (row [0 ].fill ), copy (row [0 ].font )],
107
+ network_ip = row [2 ].value
108
+ network_ips = [str (ip ) for ip in netaddr .IPNetwork (network_ip )]
109
+ for ip in network_ips :
110
+ segments .append (
111
+ data_types .Segment (
112
+ name = row [0 ].value ,
113
+ description = row [1 ].value ,
114
+ network = ip ,
115
+ color = [copy (row [0 ].fill ), copy (row [0 ].font )],
116
+ )
112
117
)
113
- )
114
- all_ips = []
115
- for segment in segments :
116
- all_ips = all_ips + segment .network
117
- segments .append (all_ips )
118
118
return segments
119
119
120
120
@@ -268,7 +268,7 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
268
268
269
269
This will capture the name description and the color coding identified within the worksheet.
270
270
"""
271
- #
271
+ segment_ips = [ segment . network for segment in segments ]
272
272
if ip_to_check == str ("0.0.0.0" ):
273
273
desc_to_change = (
274
274
"Unassigned IPv4" ,
@@ -286,7 +286,7 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
286
286
f"{ 'IPV6' if netaddr .valid_ipv6 (ip_to_check ) else 'IPV4' } { '_Multicast' if netaddr .IPAddress (ip_to_check ).is_multicast () else '' } " ,
287
287
IPV6_CELL_COLOR ,
288
288
)
289
- elif ip_to_check in segments [ len ( segments ) - 1 ] :
289
+ elif ip_to_check in segment_ips :
290
290
for segment in segments [:- 1 ]:
291
291
if ip_to_check not in segment .network :
292
292
continue
0 commit comments