Updated how results dicts are constructed, where applicable

pull/41656/head
Jose Delarosa 6 years ago
parent c7069c6643
commit a5133d56b8

@ -223,13 +223,12 @@ class RedfishUtils(object):
logs['Description'] = data['Description'] logs['Description'] = data['Description']
# Get all log entries for each type of log found # Get all log entries for each type of log found
for logEntry in data[u'Members']: for logEntry in data[u'Members']:
entry = {}
# I only extract some fields - Are these entry names standard? # I only extract some fields - Are these entry names standard?
entry['Name'] = logEntry[u'Name'] list_of_log_entries.append(dict(
entry['Created'] = logEntry[u'Created'] Name=logEntry[u'Name'],
entry['Message'] = logEntry[u'Message'] Created=logEntry[u'Created'],
entry['Severity'] = logEntry[u'Severity'] Message=logEntry[u'Message'],
list_of_log_entries.append(entry) Severity=logEntry[u'Severity']))
log_name = log_svcs_uri.split('/')[-1] log_name = log_svcs_uri.split('/')[-1]
logs[log_name] = list_of_log_entries logs[log_name] = list_of_log_entries
list_of_logs.append(logs) list_of_logs.append(logs)
@ -297,11 +296,9 @@ class RedfishUtils(object):
if response['ret'] is False: if response['ret'] is False:
return response return response
data = response['data'] data = response['data']
controller = {} controllers_details.append(dict(
controller['Name'] = data[u'Name'] # Name of storage controller Name=data[u'Name'],
controller['Health'] = data[u'Status'][u'Health'] Health=data[u'Status'][u'Health']))
controllers_details.append(controller)
result["entries"] = controllers_details result["entries"] = controllers_details
return result return result
@ -338,15 +335,13 @@ class RedfishUtils(object):
data = response['data'] data = response['data']
for device in data[u'Devices']: for device in data[u'Devices']:
disk = {} disks_details.append(dict(
disk['Controller'] = data[u'Name'] # Name of storage controller Controller=data[u'Name'],
disk['Name'] = device[u'Name'] Name=device[u'Name'],
disk['Manufacturer'] = device[u'Manufacturer'] Manufacturer=device[u'Manufacturer'],
disk['Model'] = device[u'Model'] Model=device[u'Model'],
disk['State'] = device[u'Status'][u'State'] State=device[u'Status'][u'State'],
disk['Health'] = device[u'Status'][u'Health'] Health=device[u'Status'][u'Health']))
disks_details.append(disk)
result["entries"] = disks_details result["entries"] = disks_details
return result return result
@ -420,12 +415,11 @@ class RedfishUtils(object):
data = response['data'] data = response['data']
if not data[u'UserName'] == "": # only care if name is not empty if not data[u'UserName'] == "": # only care if name is not empty
user = {} allusers_details.append(dict(
user['Id'] = data[u'Id'] Id=data[u'Id'],
user['Name'] = data[u'Name'] Name=data[u'Name'],
user['UserName'] = data[u'UserName'] UserName=data[u'UserName'],
user['RoleId'] = data[u'RoleId'] RoleId=data[u'RoleId']))
allusers_details.append(user)
result["entries"] = allusers_details result["entries"] = allusers_details
return result return result
@ -735,13 +729,12 @@ class RedfishUtils(object):
data = response['data'] data = response['data']
for device in data[u'Fans']: for device in data[u'Fans']:
fan = {} fan_details.append(dict(
# There is more information available but this is most important # There is more information available but this is most important
fan['Name'] = device[u'FanName'] Name=device[u'FanName'],
fan['RPMs'] = device[u'Reading'] RPMs=device[u'Reading'],
fan['State'] = device[u'Status'][u'State'] State=device[u'Status'][u'State'],
fan['Health'] = device[u'Status'][u'Health'] Health=device[u'Status'][u'Health']))
fan_details.append(fan)
result["entries"] = fan_details result["entries"] = fan_details
return result return result
@ -770,22 +763,20 @@ class RedfishUtils(object):
for cpu in data[u'Members']: for cpu in data[u'Members']:
cpu_list.append(cpu[u'@odata.id']) cpu_list.append(cpu[u'@odata.id'])
for c in cpu_list: for c in cpu_list:
cpu = {}
uri = self.root_uri + c uri = self.root_uri + c
response = self.get_request(uri) response = self.get_request(uri)
if response['ret'] is False: if response['ret'] is False:
return response return response
data = response['data'] data = response['data']
cpu_details.append(dict(
cpu['Name'] = data[u'Id'] Name=data[u'Id'],
cpu['Manufacturer'] = data[u'Manufacturer'] Manufacturer=data[u'Manufacturer'],
cpu['Model'] = data[u'Model'] Model=data[u'Model'],
cpu['MaxSpeedMHz'] = data[u'MaxSpeedMHz'] MaxSpeedMHz=data[u'MaxSpeedMHz'],
cpu['TotalCores'] = data[u'TotalCores'] TotalCores=data[u'TotalCores'],
cpu['TotalThreads'] = data[u'TotalThreads'] TotalThreads=data[u'TotalThreads'],
cpu['State'] = data[u'Status'][u'State'] State=data[u'Status'][u'State'],
cpu['Health'] = data[u'Status'][u'Health'] Health=data[u'Status'][u'Health']))
cpu_details.append(cpu)
result["entries"] = cpu_details result["entries"] = cpu_details
return result return result

Loading…
Cancel
Save