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

View File

@ -163,6 +163,9 @@ def index():
host_network_key = f"{host_id}_{network['network_name']}" host_network_key = f"{host_id}_{network['network_name']}"
if host_network_key in db_vms_by_host_network: if host_network_key in db_vms_by_host_network:
for vm in db_vms_by_host_network[host_network_key]: 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'])) ip_address_int = int(ipaddress.ip_address(vm['public_ipv4']))
if network_start_int <= ip_address_int and ip_address_int <= network_end_int: if network_start_int <= ip_address_int and ip_address_int <= network_end_int:
allocation = f"{host_id}_{network['network_name']}_{len(network['allocations'])}" allocation = f"{host_id}_{network['network_name']}_{len(network['allocations'])}"