| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
from .chassis_sensor_util import IDRACChassisSensors |
| 29 |
|
| 30 |
GET_SYSTEMBOARD_POWERCONSUMPTION_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Sensors/SystemBoardPwrConsumption" |
| 31 |
GET_SYSTEMBOARDINLETTEMP_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Sensors/SystemBoardInletTemp" |
| 32 |
GET_INLETTEMP_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Sensors/InletTemp" |
| 33 |
GET_POWERHEADROOM_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Sensors/PowerHeadroom" |
| 34 |
NA = "Not Available" |
| 35 |
|
| 36 |
|
| 37 |
class IDRACSystemMetricsInfo(object): |
| 38 |
def __init__(self, idrac, chassis_sensors: IDRACChassisSensors): |
| 39 |
self.chassis_sensors = chassis_sensors |
| 40 |
|
| 41 |
def _get_sensor_data(self, uri: str): |
| 42 |
response = self.chassis_sensors.get_sensor(uri) |
| 43 |
return response if response.status_code == 200 else None |
| 44 |
|
| 45 |
def get_energy_consumption_details(self): |
| 46 |
response = self.chassis_sensors.get_sensor(GET_SYSTEMBOARD_POWERCONSUMPTION_DETAILS_URI_10) |
| 47 |
if response.status_code == 200: |
| 48 |
return response.json_data.get("LifetimeReading", NA) |
| 49 |
return {} |
| 50 |
|
| 51 |
def get_temperature_details(self): |
| 52 |
|
| 53 |
response = ( |
| 54 |
self._get_sensor_data(GET_SYSTEMBOARDINLETTEMP_DETAILS_URI_10) |
| 55 |
or self._get_sensor_data(GET_INLETTEMP_DETAILS_URI_10) |
| 56 |
) |
| 57 |
if response: |
| 58 |
oem_data = response.json_data.get("Oem", {}).get("Dell", {}) |
| 59 |
inlettemp_critical = oem_data.get("DurationInCriticalThresholdPercent", NA) |
| 60 |
inlettemp_warn = oem_data.get("DurationInWarningThresholdPercent", NA) |
| 61 |
return inlettemp_critical, inlettemp_warn |
| 62 |
return {}, {} |
| 63 |
|
| 64 |
def get_power_consumption_details(self): |
| 65 |
response = self.chassis_sensors.get_sensor(GET_POWERHEADROOM_DETAILS_URI_10) |
| 66 |
if response.status_code == 200: |
| 67 |
return response.json_data.get("LowestReading", NA) |
| 68 |
return {} |
| 69 |
|
| 70 |
def get_system_metrics_info(self): |
| 71 |
output = [] |
| 72 |
energy_consump = self.get_energy_consumption_details() |
| 73 |
inlettemp_critical, inlettemp_warn = self.get_temperature_details() |
| 74 |
power_consumption = self.get_power_consumption_details() |
| 75 |
|
| 76 |
output = [{ |
| 77 |
"EnergyConsumption": energy_consump, |
| 78 |
"InletTempCriticalPerc": inlettemp_critical, |
| 79 |
"InletTempWarnPerc": inlettemp_warn, |
| 80 |
"Key": "SystemMetrics", |
| 81 |
"PowerConsumption": power_consumption, |
| 82 |
"SystemMetrics": "Not Available" |
| 83 |
}] |
| 84 |
|
| 85 |
return output |