Island: Make AWSCommandStatus enum json serializable

This commit is contained in:
vakarisz 2022-05-11 11:46:13 +03:00
parent 30fb57c37f
commit 0b5a507f38
1 changed files with 12 additions and 0 deletions

View File

@ -54,8 +54,20 @@ class RemoteRun(flask_restful.Resource):
resp = {}
if body.get("type") == "aws":
result = self.run_aws_monkeys(body)
result = self._get_encodable_results(result)
resp["result"] = result
return jsonify(resp)
# default action
return make_response({"error": "Invalid action"}, 500)
@staticmethod
def _get_encodable_results(results: Sequence[AWSCommandResults]) -> str:
results_copy = []
for result in results:
results_copy.append(
AWSCommandResults(
result.response_code, result.stdout, result.stderr, result.status.name.lower()
)
)
return results_copy