From 9fb6d58e1a393b9b03e9a9dfa3a4325ef9f6ff13 Mon Sep 17 00:00:00 2001 From: forest Date: Mon, 4 Jan 2021 15:18:50 -0600 Subject: [PATCH] fix remnants of list_ids being an async operation --- capsulflask/console.py | 24 ++++++++++-------------- capsulflask/hub_model.py | 5 ++--- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/capsulflask/console.py b/capsulflask/console.py index b8d3b18..5630158 100644 --- a/capsulflask/console.py +++ b/capsulflask/console.py @@ -27,20 +27,16 @@ def makeCapsulId(): return f"capsul-{lettersAndNumbers}" def double_check_capsul_address(id, ipv4): - result = current_app.config["HUB_MODEL"].get(id) - if result.ipv4 != ipv4: - ipv4 = result.ipv4 - get_model().update_vm_ip(email=session["account"], id=id, ipv4=result.ipv4) - # try: - # result = current_app.config["HUB_MODEL"].get(id) - # if result.ipv4 != ipv4: - # ipv4 = result.ipv4 - # get_model().update_vm_ip(email=session["account"], id=id, ipv4=result.ipv4) - # except: - # current_app.logger.error(f""" - # the virtualization model threw an error in double_check_capsul_address of {id}: - # {my_exec_info_message(sys.exc_info())}""" - # ) + try: + result = current_app.config["HUB_MODEL"].get(id) + if result.ipv4 != ipv4: + ipv4 = result.ipv4 + get_model().update_vm_ip(email=session["account"], id=id, ipv4=result.ipv4) + except: + current_app.logger.error(f""" + the virtualization model threw an error in double_check_capsul_address of {id}: + {my_exec_info_message(sys.exc_info())}""" + ) return ipv4 diff --git a/capsulflask/hub_model.py b/capsulflask/hub_model.py index 48a6a6c..c40cea4 100644 --- a/capsulflask/hub_model.py +++ b/capsulflask/hub_model.py @@ -156,11 +156,10 @@ class CapsulFlaskHub(VirtualizationInterface): all_valid = False if not all_valid: result_json_string = json.dumps({"error_message": "invalid capsul id returned"}) - current_app.logger.error(f"""error reading ids for list_ids operation {operation_id}, host {host.id}""") + current_app.logger.error(f"""error reading ids for list_ids operation, host {host.id}""") else: result_json_string = json.dumps({"error_message": "invalid response, missing 'ids' list"}) - get_model().update_host_operation(host.id, operation_id, "invalid_response_from_host", result_json_string) - current_app.logger.error(f"""missing 'ids' list for list_ids operation {operation_id}, host {host.id}""") + current_app.logger.error(f"""missing 'ids' list for list_ids operation, host {host.id}""") except: # no need to do anything here since if it cant be parsed then generic_operation will handle it. pass