check null on double_check_capsul_address 😬
This commit is contained in:
parent
39980d836b
commit
280bcfd584
@ -40,6 +40,7 @@ def double_check_capsul_address(id, ipv4, get_ssh_host_keys):
|
|||||||
the virtualization model threw an error in double_check_capsul_address of {id}:
|
the virtualization model threw an error in double_check_capsul_address of {id}:
|
||||||
{my_exec_info_message(sys.exc_info())}"""
|
{my_exec_info_message(sys.exc_info())}"""
|
||||||
)
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -57,7 +58,9 @@ def index():
|
|||||||
# for now we are going to check the IP according to the virt model
|
# for now we are going to check the IP according to the virt model
|
||||||
# on every request. this could be done by a background job and cached later on...
|
# on every request. this could be done by a background job and cached later on...
|
||||||
for vm in vms:
|
for vm in vms:
|
||||||
vm["ipv4"] = double_check_capsul_address(vm["id"], vm["ipv4"], False).ipv4
|
result = double_check_capsul_address(vm["id"], vm["ipv4"], False)
|
||||||
|
if result is not None:
|
||||||
|
vm["ipv4"] = result.ipv4
|
||||||
|
|
||||||
vms = list(map(
|
vms = list(map(
|
||||||
lambda x: dict(
|
lambda x: dict(
|
||||||
@ -109,7 +112,10 @@ def detail(id):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
needs_ssh_host_keys = "ssh_host_keys" not in vm or len(vm["ssh_host_keys"]) == 0
|
needs_ssh_host_keys = "ssh_host_keys" not in vm or len(vm["ssh_host_keys"]) == 0
|
||||||
|
|
||||||
vm_from_virt_model = double_check_capsul_address(vm["id"], vm["ipv4"], needs_ssh_host_keys)
|
vm_from_virt_model = double_check_capsul_address(vm["id"], vm["ipv4"], needs_ssh_host_keys)
|
||||||
|
|
||||||
|
if vm_from_virt_model is not None:
|
||||||
vm["ipv4"] = vm_from_virt_model.ipv4
|
vm["ipv4"] = vm_from_virt_model.ipv4
|
||||||
if needs_ssh_host_keys:
|
if needs_ssh_host_keys:
|
||||||
vm["ssh_host_keys"] = vm_from_virt_model.ssh_host_keys
|
vm["ssh_host_keys"] = vm_from_virt_model.ssh_host_keys
|
||||||
|
Loading…
Reference in New Issue
Block a user