support HPE BL460c Gen10 and its stupid dmidecode info

This commit is contained in:
Solvik Blum 2019-08-21 15:47:54 +02:00
parent e25fe3dd07
commit d9231252dc
No known key found for this signature in database
GPG key ID: CC12B3DC262B6C47
2 changed files with 20 additions and 12 deletions

View file

@ -68,7 +68,6 @@ def parse():
_data = _parse(buffer)
return _data
def get_by_type(type_id):
"""
filter the output of dmidecode per type
@ -117,7 +116,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 +130,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 +169,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 +194,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: