Skip to content

Commit 533b90f

Browse files
committed
Calculate usage of network based on ipv4 subnets only
1 parent 437edb0 commit 533b90f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: osia/installer/clouds/openstack.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ def _find_fit_network(osp_connection: Connection,
100100
results = {}
101101
for net_name in networks:
102102
net_avail = osp_connection.network.get_network_ip_availability(named_networks[net_name])
103-
results[net_name] = net_avail['total_ips'] / net_avail['used_ips']
103+
subnet_usage = [(subnet['total_ips'], subnet['used_ips'])
104+
for subnet in net_avail.subnet_ip_availability if subnet['ip_version'] == 4]
105+
total_ips, used_ips = [sum(i) for i in zip(*subnet_usage)]
106+
results[net_name] = total_ips / used_ips
104107
result = _find_best_fit(results)
105108
return named_networks[result]['id'], result
106109

0 commit comments

Comments
 (0)