fix get_all_by_host_and_network hub logic

This commit is contained in:
forest 2021-12-09 13:19:42 -06:00
parent 5f87f6ef9b
commit fd0d112834

View File

@ -177,12 +177,11 @@ class CapsulFlaskHub(VirtualizationInterface):
has_hosts = isinstance(result_body, dict) and "hosts" in result_body and isinstance(result_body["hosts"], dict)
has_current_host = has_hosts and isinstance(result_body["hosts"], dict) and host.id in result_body["hosts"] and isinstance(result_body["hosts"][host.id], dict)
has_networks = has_current_host and 'networks' in result_body["hosts"][host.id] and isinstance(result_body["hosts"][host.id]['networks'], dict)
if has_networks:
to_return[host.id] = result_body["hosts"][host.id]['networks']
if has_current_host:
to_return[host.id] = result_body["hosts"][host.id]
else:
# result_json_string = json.dumps({"error_message": "invalid response, missing 'networks' list"})
current_app.logger.error(f"""missing 'networks' list for get_all_by_host_and_network operation, host {host.id}""")
current_app.logger.error(f"""missing 'hosts' dict for get_all_by_host_and_network operation, host {host.id}""")
except:
# no need to do anything here since if it cant be parsed then generic_operation will handle it.
pass