Island: Add instance ID to AWSCommandResults

Instance id tells us where the command was launched
This commit is contained in:
vakarisz 2022-05-11 14:32:39 +03:00
parent 0b5a507f38
commit b8006a6274
3 changed files with 8 additions and 2 deletions

View File

@ -67,7 +67,11 @@ class RemoteRun(flask_restful.Resource):
for result in results: for result in results:
results_copy.append( results_copy.append(
AWSCommandResults( AWSCommandResults(
result.response_code, result.stdout, result.stderr, result.status.name.lower() result.instance_id,
result.response_code,
result.stdout,
result.stderr,
result.status.name.lower(),
) )
) )
return results_copy return results_copy

View File

@ -23,6 +23,7 @@ class AWSCommandStatus(Enum):
@dataclass(frozen=True) @dataclass(frozen=True)
class AWSCommandResults: class AWSCommandResults:
instance_id: str
response_code: int response_code: int
stdout: str stdout: str
stderr: str stderr: str
@ -137,6 +138,7 @@ def _fetch_command_results(
aws_command_result_status = AWSCommandStatus.ERROR aws_command_result_status = AWSCommandStatus.ERROR
return AWSCommandResults( return AWSCommandResults(
target_instance_id,
command_results["ResponseCode"], command_results["ResponseCode"],
command_results["StandardOutputContent"], command_results["StandardOutputContent"],
command_results["StandardErrorContent"], command_results["StandardErrorContent"],

View File

@ -228,5 +228,5 @@ def test_failed_command(send_command_response, error_response):
], ],
) )
def test_command_resuls_status(status, success): def test_command_resuls_status(status, success):
results = AWSCommandResults(0, "", "", status) results = AWSCommandResults(INSTANCE_ID, 0, "", "", status)
assert results.success == success assert results.success == success