forked from 3wordchant/capsul-flask
fixing capsul creation after I broke it with the pre-allocated IP
address changes
This commit is contained in:
@ -104,7 +104,7 @@ def handle_create(operation_id, request_body):
|
||||
current_app.logger.error(f"/hosts/operation returned 400: operation_id is required for create ")
|
||||
return abort(400, f"bad request; operation_id is required. try POST /spoke/operation/<id>")
|
||||
|
||||
parameters = ["email", "id", "template_image_file_name", "vcpus", "memory_mb", "ssh_authorized_keys"]
|
||||
parameters = ["email", "id", "os", "size", "template_image_file_name", "vcpus", "memory_mb", "ssh_authorized_keys"]
|
||||
error_message = ""
|
||||
for parameter in parameters:
|
||||
if parameter not in request_body:
|
||||
@ -128,16 +128,15 @@ def handle_create(operation_id, request_body):
|
||||
return abort(503, f"hub at '{url}' returned 200, but did not return assignment_info json object")
|
||||
if 'network_name' not in assignment_info:
|
||||
return abort(503, f"hub at '{url}' returned 200, but the returned assignment_info object did not include network_name")
|
||||
if 'public_ipv4_address' not in assignment_info:
|
||||
return abort(503, f"hub at '{url}' returned 200, but the returned assignment_info object did not include public_ipv4_address")
|
||||
if 'public_ipv4' not in assignment_info:
|
||||
return abort(503, f"hub at '{url}' returned 200, but the returned assignment_info object did not include public_ipv4")
|
||||
|
||||
assignment_status = "assigned"
|
||||
request_body['network_name'] = assignment_info['network_name']
|
||||
request_body['public_ipv4_address'] = assignment_info['public_ipv4_address']
|
||||
request_body['public_ipv4'] = assignment_info['public_ipv4']
|
||||
except:
|
||||
return abort(503, f"hub at '{url}' returned 200, but did not return valid json")
|
||||
|
||||
assignment_status = "assigned"
|
||||
|
||||
elif result.status_code == 409:
|
||||
assignment_status = "assigned_to_other_host"
|
||||
else:
|
||||
@ -152,9 +151,9 @@ def handle_create(operation_id, request_body):
|
||||
template_image_file_name=request_body['template_image_file_name'],
|
||||
vcpus=request_body['vcpus'],
|
||||
memory_mb=request_body['memory_mb'],
|
||||
ssh_authorized_keys=request_body['ssh_authorized_keys'],
|
||||
ssh_authorized_keys=list(map(lambda x: x['content'], request_body['ssh_authorized_keys'])),
|
||||
network_name=request_body['network_name'],
|
||||
public_ipv4_address=request_body['public_ipv4_address'],
|
||||
public_ipv4=request_body['public_ipv4'],
|
||||
)
|
||||
except:
|
||||
error_message = my_exec_info_message(sys.exc_info())
|
||||
@ -165,7 +164,7 @@ def handle_create(operation_id, request_body):
|
||||
params= f"{params} memory_mb='{request_body['memory_mb'] if 'memory_mb' in request_body else 'KeyError'}', "
|
||||
params= f"{params} ssh_authorized_keys='{request_body['ssh_authorized_keys'] if 'ssh_authorized_keys' in request_body else 'KeyError'}', "
|
||||
params= f"{params} network_name='{request_body['network_name'] if 'network_name' in request_body else 'KeyError'}', "
|
||||
params= f"{params} public_ipv4_address='{request_body['public_ipv4_address'] if 'public_ipv4_address' in request_body else 'KeyError'}', "
|
||||
params= f"{params} public_ipv4='{request_body['public_ipv4'] if 'public_ipv4' in request_body else 'KeyError'}', "
|
||||
|
||||
current_app.logger.error(f"spoke_model.create({params}) failed: {error_message}")
|
||||
|
||||
|
Reference in New Issue
Block a user