in cookbooks/aws-parallelcluster-computefleet/files/compute_fleet_status/compute_fleet_status.py [0:0]
def get_status_with_last_updated_time(table_name, region):
"""Get compute fleet status and the last compute fleet status updated time."""
try:
table = boto3.resource("dynamodb", region_name=region).Table(table_name)
dynamo_db_data = get_dynamo_db_data(table)
print(
json.dumps(
{
COMPUTE_FLEET_STATUS_ATTRIBUTE: dynamo_db_data.get(COMPUTE_FLEET_STATUS_ATTRIBUTE),
COMPUTE_FLEET_LAST_UPDATED_TIME_ATTRIBUTE: to_iso_timestr(
dateutil.parser.parse(dynamo_db_data.get(COMPUTE_FLEET_LAST_UPDATED_TIME_ATTRIBUTE))
),
},
sort_keys=True,
indent=4,
)
)
except Exception as e:
raise Exception(f"Failed when retrieving fleet status from DynamoDB with error {e}.")