forked from 3wordchant/capsul-flask
fleshing out spoke API
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user