| 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_MEMORY_DETAILS_URI = "/redfish/v1/Systems/System.Embedded.1/Memory" |
| 29 |
NA = "Not Available" |
| 30 |
MAPPING_DICT_FOR_RANK = { |
| 31 |
0: "Unknown", |
| 32 |
1: "Single Rank", |
| 33 |
2: "Double Rank", |
| 34 |
4: "Quad Rank" |
| 35 |
} |
| 36 |
MAPPING_MEMORY_TYPE_DICT = { |
| 37 |
"Other": "1", |
| 38 |
"Unknown": "2", |
| 39 |
"DRAM": "3", |
| 40 |
"EDRAM": "4", |
| 41 |
"VRAM": "5", |
| 42 |
"SRAM": "6", |
| 43 |
"RAM": "7", |
| 44 |
"ROM": "8", |
| 45 |
"Flash": "9", |
| 46 |
"EEPROM": "10", |
| 47 |
"FEPROM": "11", |
| 48 |
"EPROM": "12", |
| 49 |
"CDRAM": "13", |
| 50 |
"3DRAM": "14", |
| 51 |
"SDRAM": "15", |
| 52 |
"SGRAM": "16", |
| 53 |
"RDRAM": "17", |
| 54 |
"DDR": "18", |
| 55 |
"DDR-2": "19", |
| 56 |
"DDR-2-FB-DIMM": "20", |
| 57 |
"DDR-3": "24", |
| 58 |
"FBD2": "25" |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
class IDRACMemoryInfo(object): |
| 63 |
def __init__(self, idrac): |
| 64 |
self.idrac = idrac |
| 65 |
|
| 66 |
def get_memory_links(self): |
| 67 |
response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_MEMORY_DETAILS_URI) |
| 68 |
memory_links_list = [] |
| 69 |
if response.status_code == 200: |
| 70 |
members = response.json_data.get("Members") |
| 71 |
for each in members: |
| 72 |
memory_links_list.append(each.get("@odata.id")) |
| 73 |
return memory_links_list |
| 74 |
|
| 75 |
def get_parameters_with_units(self, response, output): |
| 76 |
if output["CurrentOperatingSpeed"] is not None: |
| 77 |
output["CurrentOperatingSpeed"] = \ |
| 78 |
str(float(response.json_data.get("OperatingSpeedMhz"))) \ |
| 79 |
+ " MHz" |
| 80 |
else: |
| 81 |
output["CurrentOperatingSpeed"] = NA |
| 82 |
if output["Speed"]: |
| 83 |
output["Speed"] = \ |
| 84 |
str(response.json_data.get("AllowedSpeedsMHz")[0] / 1000)\ |
| 85 |
+ " GHz" |
| 86 |
else: |
| 87 |
output["Speed"] = NA |
| 88 |
if output["Size"] is not None: |
| 89 |
output["Size"] = \ |
| 90 |
str(response.json_data.get("CapacityMiB") / 1024) + " GB" |
| 91 |
else: |
| 92 |
output["Size"] = NA |
| 93 |
return output |
| 94 |
|
| 95 |
def get_memory_details(self, memory_link): |
| 96 |
response = self.idrac.invoke_request(method='GET', uri=memory_link) |
| 97 |
output = {} |
| 98 |
if response.status_code == 200: |
| 99 |
output["BankLabel"] = response.json_data.get("Oem", {})\ |
| 100 |
.get("Dell", {}).get("DellMemory", {}).get("BankLabel", NA) |
| 101 |
output["CurrentOperatingSpeed"] = \ |
| 102 |
response.json_data.get("OperatingSpeedMhz") |
| 103 |
output["DeviceDescription"] = \ |
| 104 |
response.json_data.get("Description", NA) |
| 105 |
output["FQDD"] = response.json_data.get("Id", NA) |
| 106 |
output["Key"] = response.json_data.get("Id", NA) |
| 107 |
output["ManufactureDate"] = response.json_data.get("Oem", {})\ |
| 108 |
.get("Dell", {}).get("DellMemory", {}).\ |
| 109 |
get("ManufactureDate", NA) |
| 110 |
output["Manufacturer"] = response.json_data.\ |
| 111 |
get("Manufacturer", NA) |
| 112 |
output["MemoryType"] = \ |
| 113 |
MAPPING_MEMORY_TYPE_DICT.get( |
| 114 |
response.json_data.get("MemoryDeviceType"), |
| 115 |
NA) |
| 116 |
output["MemoryType_API"] = response.json_data.\ |
| 117 |
get("MemoryDeviceType", NA) |
| 118 |
output["Model"] = response.json_data.get("Oem", {})\ |
| 119 |
.get("Dell", {}).get("DellMemory", {}).\ |
| 120 |
get("Model", NA) |
| 121 |
output["PartNumber"] = response.json_data.get("PartNumber", NA) |
| 122 |
output["PrimaryStatus"] = \ |
| 123 |
response.json_data.get("Status", {}).get("Health", NA) |
| 124 |
output["Rank"] = \ |
| 125 |
MAPPING_DICT_FOR_RANK.get(response.json_data.get("RankCount"), |
| 126 |
NA) |
| 127 |
output["SerialNumber"] = response.json_data.\ |
| 128 |
get("SerialNumber", NA) |
| 129 |
output["Size"] = response.json_data.get("CapacityMiB") |
| 130 |
output["Speed"] = response.json_data.get("AllowedSpeedsMHz") |
| 131 |
output["memoryDeviceStateSettings"] = \ |
| 132 |
response.json_data.get("Status", {}).get("State", NA) |
| 133 |
if response.json_data.get("Status", {}).get("Health") == "OK": |
| 134 |
output["PrimaryStatus"] = "Healthy" |
| 135 |
else: |
| 136 |
output["PrimaryStatus"] = response.json_data.\ |
| 137 |
get("Status", {}).get("Health", NA) |
| 138 |
self.get_parameters_with_units(response, output) |
| 139 |
return output |
| 140 |
|
| 141 |
def get_memory_info(self): |
| 142 |
memory_output = [] |
| 143 |
memory_links_list = self.get_memory_links() |
| 144 |
for each_link in memory_links_list: |
| 145 |
memory_output.append(self.get_memory_details(each_link)) |
| 146 |
return memory_output |