working on cleaning up the logs
This commit is contained in:
@ -45,7 +45,7 @@ def operation_impl(operation_id: int):
|
||||
if authorized_as_hub(request.headers):
|
||||
request_body_json = request.json
|
||||
request_body = json.loads(request_body_json)
|
||||
current_app.logger.info(f"request.json: {request_body}")
|
||||
#current_app.logger.info(f"request.json: {request_body}")
|
||||
handlers = {
|
||||
"capacity_avaliable": handle_capacity_avaliable,
|
||||
"get": handle_get,
|
||||
@ -70,15 +70,15 @@ def operation_impl(operation_id: int):
|
||||
error_message = "'type' json property is required"
|
||||
|
||||
if error_message != "":
|
||||
current_app.logger.info(f"/hosts/operation returned 400: {error_message}")
|
||||
current_app.logger.error(f"/hosts/operation returned 400: {error_message}")
|
||||
return abort(400, f"bad request; {error_message}")
|
||||
else:
|
||||
current_app.logger.info(f"/hosts/operation returned 401: invalid hub token")
|
||||
current_app.logger.warning(f"/hosts/operation returned 401: invalid hub token")
|
||||
return abort(401, "invalid hub token")
|
||||
|
||||
def handle_capacity_avaliable(operation_id, request_body):
|
||||
if 'additional_ram_bytes' not in request_body:
|
||||
current_app.logger.info(f"/hosts/operation returned 400: additional_ram_bytes is required for capacity_avaliable")
|
||||
current_app.logger.error(f"/hosts/operation returned 400: additional_ram_bytes is required for capacity_avaliable")
|
||||
return abort(400, f"bad request; additional_ram_bytes is required for capacity_avaliable")
|
||||
|
||||
has_capacity = current_app.config['SPOKE_MODEL'].capacity_avaliable(request_body['additional_ram_bytes'])
|
||||
@ -86,7 +86,7 @@ def handle_capacity_avaliable(operation_id, request_body):
|
||||
|
||||
def handle_get(operation_id, request_body):
|
||||
if 'id' not in request_body:
|
||||
current_app.logger.info(f"/hosts/operation returned 400: id is required for get")
|
||||
current_app.logger.error(f"/hosts/operation returned 400: id is required for get")
|
||||
return abort(400, f"bad request; id is required for get")
|
||||
|
||||
vm = current_app.config['SPOKE_MODEL'].get(request_body['id'])
|
||||
@ -98,7 +98,7 @@ def handle_list_ids(operation_id, request_body):
|
||||
|
||||
def handle_create(operation_id, request_body):
|
||||
if not operation_id:
|
||||
current_app.logger.info(f"/hosts/operation returned 400: operation_id is required for create ")
|
||||
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_public_keys"]
|
||||
@ -108,7 +108,7 @@ def handle_create(operation_id, request_body):
|
||||
error_message = f"{error_message}\n{parameter} is required for create"
|
||||
|
||||
if error_message != "":
|
||||
current_app.logger.info(f"/hosts/opasdascasderation returned 400: {error_message}")
|
||||
current_app.logger.error(f"/hosts/operation returned 400: {error_message}")
|
||||
return abort(400, f"bad request; {error_message}")
|
||||
|
||||
# only one host should create the vm, so we first race to assign this create operation to ourselves.
|
||||
@ -123,7 +123,7 @@ def handle_create(operation_id, request_body):
|
||||
elif result.status_code == 409:
|
||||
assignment_status = "assigned_to_other_host"
|
||||
else:
|
||||
current_app.logger.info(f"{url} returned {result.status_code}: {result.body}")
|
||||
current_app.logger.error(f"{url} returned {result.status_code}: {result.body}")
|
||||
return abort(503, f"hub did not cleanly handle our request to claim the create operation")
|
||||
|
||||
if assignment_status == "assigned":
|
||||
@ -148,11 +148,11 @@ def handle_create(operation_id, request_body):
|
||||
|
||||
def handle_destroy(operation_id, request_body):
|
||||
if 'id' not in request_body:
|
||||
current_app.logger.info(f"/hosts/operation returned 400: id is required for destroy")
|
||||
current_app.logger.error(f"/hosts/operation returned 400: id is required for destroy")
|
||||
return abort(400, f"bad request; id is required for destroy")
|
||||
|
||||
if 'email' not in request_body:
|
||||
current_app.logger.info(f"/hosts/operation returned 400: email is required for destroy")
|
||||
current_app.logger.error(f"/hosts/operation returned 400: email is required for destroy")
|
||||
return abort(400, f"bad request; email is required for destroy")
|
||||
|
||||
try:
|
||||
|
Reference in New Issue
Block a user