fix exception on vms missing IP addresses

This commit is contained in:
forest 2022-03-03 12:57:52 -06:00
parent 6c57e45cdd
commit aa03c00fb1
1 changed files with 3 additions and 0 deletions

View File

@ -163,6 +163,9 @@ def index():
host_network_key = f"{host_id}_{network['network_name']}"
if host_network_key in db_vms_by_host_network:
for vm in db_vms_by_host_network[host_network_key]:
if 'public_ipv4' not in vm or vm['public_ipv4'] is None:
continue
ip_address_int = int(ipaddress.ip_address(vm['public_ipv4']))
if network_start_int <= ip_address_int and ip_address_int <= network_end_int:
allocation = f"{host_id}_{network['network_name']}_{len(network['allocations'])}"