fleshing out spoke API

This commit is contained in:
2021-01-03 14:44:56 -06:00
parent 0a379b74ad
commit ad082eb0f9
3 changed files with 117 additions and 5 deletions

View File

@ -241,6 +241,7 @@ class CapsulFlaskHub(HubInterface):
operation_id = op[0]
results = op[1]
number_of_assigned = 0
error_message = ""
assigned_hosts = []
for i in range(len(results)):
host = online_hosts[i]
@ -250,6 +251,8 @@ class CapsulFlaskHub(HubInterface):
if isinstance(result_body, dict) and 'assignment_status' in result_body and result_body['assignment_status'] == "assigned":
number_of_assigned += 1
assigned_hosts.append(host.id)
if isinstance(result_body, dict) and 'error_message' in result_body:
error_message = result_body['error_message']
except:
# no need to do anything here since if it cant be parsed then generic_operation will handle it.
pass
@ -257,7 +260,8 @@ class CapsulFlaskHub(HubInterface):
if number_of_assigned != 1:
assigned_hosts_string = ", ".join(assigned_hosts)
raise ValueError(f"expected create capsul operation {operation_id} to be assigned to one host, it was assigned to {number_of_assigned} ({assigned_hosts_string})")
if error_message != "":
raise ValueError(f"create capsul operation {operation_id} on {assigned_hosts_string} failed with {error_message}")
def destroy(self, email: str, id: str):