support HPE BL460c Gen10 and its stupid dmidecode info (#39)

This commit is contained in:
Solvik 2019-08-21 16:17:01 +02:00 committed by GitHub
parent e25fe3dd07
commit 5826966ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 11 deletions

View file

@ -117,7 +117,9 @@ def get_by_type(type_id):
42 Management Controller Host Interface
"""
if isinstance(type_id, str):
type_id = _str2type[type_id]
type_id = _str2type.get(type_id)
if type_id is None:
return None
data = parse()
result = []
@ -129,7 +131,7 @@ def get_by_type(type_id):
def _execute_cmd():
return _subprocess.check_output('dmidecode', stderr=_subprocess.PIPE)
return _subprocess.check_output(['dmidecode', ], stderr=_subprocess.PIPE)
def _parse(buffer):
@ -168,14 +170,13 @@ def _parse(buffer):
break
# Check whether we are inside a \t\t block
if in_block_elemet != '':
in_block_data = _in_block_re.findall(record_element[1])
in_block_data = _in_block_re.findall(record_element[i])
if in_block_data:
if not in_block_list:
in_block_list = in_block_data[0][0]
in_block_list = [in_block_data[0]]
else:
in_block_list = in_block_list + '\t\t' + in_block_data[0][1]
in_block_list.append(in_block_data[0])
output_data[dmi_handle][in_block_elemet] = in_block_list
continue
@ -194,11 +195,12 @@ def _parse(buffer):
# Didn't findall regular entry, maybe an array of data?
record_data2 = _record2_re.findall(record_element[i])
if record_data2:
# This is an array of data - let the loop know we are inside
# an array block
in_block_elemet = record_data2[0][0]
in_block_elemet = record_data2[0]
in_block_list = ''
continue
if not output_data:

View file

@ -18,9 +18,16 @@ class HPHost(ServerBase):
"""
# FIXME: make a dmidecode function get_by_dminame() ?
if self.is_blade():
for key, value in self.dmi.parse().items():
if value['DMIName'] == 'HP ProLiant System/Rack Locator':
return value
locator = self.dmi.get_by_type(204)
if self.get_product_name() == 'ProLiant BL460c Gen10':
locator = locator[0]['Strings']
return {
'Enclosure Model': locator[2].strip(),
'Enclosure Name': locator[0].strip(),
'Server Bay': locator[3].strip(),
'Enclosure Serial': locator[4].strip(),
}
return locator[0]
def get_blade_slot(self):
if self.is_blade():