Fix NoneType error when infrastructure is not filled/there's no GPU data
@@ -30,15 +30,19 @@ class GetGPUController:
'<GPU1_UUID>': {'value': 32, 'unit': '%'},
}
'''
+ if resource_data is None:
+ # No data about GPU
+ response = NoContent, 404
+ else:
if metric_type is None:
# Put all gathered metric data for each GPU
result = {uuid: gpu_data['metrics'] for uuid, gpu_data in resource_data.items()}
else:
# Put only requested metric data for each GPU
result = {uuid: gpu_data['metrics'][metric_type] for uuid, gpu_data in resource_data.items()}
+ response = result, 200
# TODO Put exception and error messages within infrastructure dict, so it can be passed to the API consumer
- response = result, 200
except KeyError:
response = NoContent, 404
finally:
