| 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 |
GET_IDRAC_POWER_SUPPLY_DETAILS_URI = "/redfish/v1/Chassis/System.Embedded.1/PowerSubsystem/PowerSupplies" |
| 29 |
NA = "Not Available" |
| 30 |
RED_TYPE_MAPPING = { |
| 31 |
"N+1": "2", |
| 32 |
"Sparing": "4", |
| 33 |
"Input Power Redundancy": "32768" |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
class IDRACPowerSupplyInfo(object): |
| 38 |
def __init__(self, idrac): |
| 39 |
self.idrac = idrac |
| 40 |
|
| 41 |
def get_power_supply_links(self): |
| 42 |
response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_POWER_SUPPLY_DETAILS_URI) |
| 43 |
power_supply_links_list = [] |
| 44 |
if response.status_code == 200: |
| 45 |
members = response.json_data.get("Members") |
| 46 |
for each in members: |
| 47 |
power_supply_links_list.append(each.get("@odata.id")) |
| 48 |
return power_supply_links_list |
| 49 |
|
| 50 |
def get_red_type_set(self, response, output): |
| 51 |
red_type_list = response.get("Oem", {}).\ |
| 52 |
get("Dell", {}).get("DellPowerSupplyView", {}).\ |
| 53 |
get("RedTypeOfSet") |
| 54 |
if red_type_list: |
| 55 |
mapped_red_type_list = [] |
| 56 |
for x in red_type_list: |
| 57 |
if x is not None: |
| 58 |
mapped_red_type_list.append(RED_TYPE_MAPPING.get(x, NA)) |
| 59 |
if len(mapped_red_type_list) > 0: |
| 60 |
output["RedTypeOfSet"] = ",".join(mapped_red_type_list) |
| 61 |
else: |
| 62 |
output["RedTypeOfSet"] = NA |
| 63 |
else: |
| 64 |
output["RedTypeOfSet"] = NA |
| 65 |
|
| 66 |
def get_power_supply_details(self, memory_link): |
| 67 |
response = self.idrac.invoke_request(method='GET', uri=memory_link) |
| 68 |
output = {} |
| 69 |
if response.status_code == 200: |
| 70 |
output["DetailedState"] = \ |
| 71 |
response.json_data.get("Oem", {}).get("Dell", {}).\ |
| 72 |
get("DellPowerSupplyView", {}).get("DetailedState", NA) |
| 73 |
output["DeviceDescription"] = response.json_data.get("Oem", {}).\ |
| 74 |
get("Dell", {}).get("DellPowerSupplyView", {}).\ |
| 75 |
get("DeviceDescription", NA) |
| 76 |
output["FQDD"] = response.json_data.get("Id", NA) |
| 77 |
output["Key"] = response.json_data.get("Id", NA) |
| 78 |
output["Name"] = response.json_data.get("Name", NA) |
| 79 |
output["FirmwareVersion"] = \ |
| 80 |
response.json_data.get("FirmwareVersion", NA) |
| 81 |
output["Model"] = response.json_data.get("Model", NA) |
| 82 |
output["InputVoltage"] = NA |
| 83 |
output["Manufacturer"] = \ |
| 84 |
response.json_data.get("Manufacturer", NA) |
| 85 |
output["PartNumber"] = response.json_data.get("PartNumber", NA) |
| 86 |
output["PowerSupplySensorState"] = NA |
| 87 |
if response.json_data.get("Status", {}).get("Health") == "OK": |
| 88 |
output["PrimaryStatus"] = "Healthy" |
| 89 |
else: |
| 90 |
output["PrimaryStatus"] = response.json_data.\ |
| 91 |
get("Status", {}).get("Health", NA) |
| 92 |
output["RAIDState"] = NA |
| 93 |
maxinputwatt = \ |
| 94 |
response.json_data.get("Oem", {}).get("Dell", {}).\ |
| 95 |
get("DellPowerSupplyView", {}).\ |
| 96 |
get("Range1MaxInputPowerWatts") |
| 97 |
if maxinputwatt: |
| 98 |
output["Range1MaxInputPower"] = str(maxinputwatt) + " W" |
| 99 |
else: |
| 100 |
output["Range1MaxInputPower"] = NA |
| 101 |
output["RedMinNumberNeeded"] = \ |
| 102 |
response.json_data.get("Oem", {}).get("Dell", {}).\ |
| 103 |
get("DellPowerSupplyView", {}).get("RedMinNumberNeeded", NA) |
| 104 |
output["SerialNumber"] = \ |
| 105 |
response.json_data.get("SerialNumber", NA) |
| 106 |
if response.json_data.get("PowerCapacityWatts"): |
| 107 |
output["TotalOutputPower"] = \ |
| 108 |
str(response.json_data.get("PowerCapacityWatts")) + " W" |
| 109 |
else: |
| 110 |
output["TotalOutputPower"] = NA |
| 111 |
output["Type"] = response.json_data.get("PowerSupplyType", NA) |
| 112 |
output["powerSupplyStateCapabilitiesUnique"] = \ |
| 113 |
response.json_data.get("Oem", {}).get("Dell", {}).\ |
| 114 |
get("DellPowerSupplyView", {}).\ |
| 115 |
get("powerSupplyStateCapabilitiesUnique", NA) |
| 116 |
output["Redundancy"] = response.json_data.get("Oem", {}).\ |
| 117 |
get("Dell", {}).get("DellPowerSupplyView", {}).\ |
| 118 |
get("RedundancyStatus", NA) |
| 119 |
self.get_red_type_set(response.json_data, output) |
| 120 |
return output |
| 121 |
|
| 122 |
def get_power_supply_info(self): |
| 123 |
power_supply_output = [] |
| 124 |
power_supply_links_list = self.get_power_supply_links() |
| 125 |
for each_link in power_supply_links_list: |
| 126 |
power_supply_output.append(self.get_power_supply_details(each_link)) |
| 127 |
return power_supply_output |