support HPE BL460c Gen10 and its stupid dmidecode info (#39)
This commit is contained in:
parent
e25fe3dd07
commit
5826966ea4
2 changed files with 20 additions and 11 deletions
|
@ -117,7 +117,9 @@ def get_by_type(type_id):
|
||||||
42 Management Controller Host Interface
|
42 Management Controller Host Interface
|
||||||
"""
|
"""
|
||||||
if isinstance(type_id, str):
|
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()
|
data = parse()
|
||||||
result = []
|
result = []
|
||||||
|
@ -129,7 +131,7 @@ def get_by_type(type_id):
|
||||||
|
|
||||||
|
|
||||||
def _execute_cmd():
|
def _execute_cmd():
|
||||||
return _subprocess.check_output('dmidecode', stderr=_subprocess.PIPE)
|
return _subprocess.check_output(['dmidecode', ], stderr=_subprocess.PIPE)
|
||||||
|
|
||||||
|
|
||||||
def _parse(buffer):
|
def _parse(buffer):
|
||||||
|
@ -168,14 +170,13 @@ def _parse(buffer):
|
||||||
break
|
break
|
||||||
# Check whether we are inside a \t\t block
|
# Check whether we are inside a \t\t block
|
||||||
if in_block_elemet != '':
|
if in_block_elemet != '':
|
||||||
|
in_block_data = _in_block_re.findall(record_element[i])
|
||||||
in_block_data = _in_block_re.findall(record_element[1])
|
|
||||||
|
|
||||||
if in_block_data:
|
if in_block_data:
|
||||||
if not in_block_list:
|
if not in_block_list:
|
||||||
in_block_list = in_block_data[0][0]
|
in_block_list = [in_block_data[0]]
|
||||||
else:
|
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
|
output_data[dmi_handle][in_block_elemet] = in_block_list
|
||||||
continue
|
continue
|
||||||
|
@ -194,11 +195,12 @@ def _parse(buffer):
|
||||||
# Didn't findall regular entry, maybe an array of data?
|
# Didn't findall regular entry, maybe an array of data?
|
||||||
|
|
||||||
record_data2 = _record2_re.findall(record_element[i])
|
record_data2 = _record2_re.findall(record_element[i])
|
||||||
|
|
||||||
if record_data2:
|
if record_data2:
|
||||||
# This is an array of data - let the loop know we are inside
|
# This is an array of data - let the loop know we are inside
|
||||||
# an array block
|
# an array block
|
||||||
in_block_elemet = record_data2[0][0]
|
in_block_elemet = record_data2[0]
|
||||||
|
in_block_list = ''
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not output_data:
|
if not output_data:
|
||||||
|
|
|
@ -18,9 +18,16 @@ class HPHost(ServerBase):
|
||||||
"""
|
"""
|
||||||
# FIXME: make a dmidecode function get_by_dminame() ?
|
# FIXME: make a dmidecode function get_by_dminame() ?
|
||||||
if self.is_blade():
|
if self.is_blade():
|
||||||
for key, value in self.dmi.parse().items():
|
locator = self.dmi.get_by_type(204)
|
||||||
if value['DMIName'] == 'HP ProLiant System/Rack Locator':
|
if self.get_product_name() == 'ProLiant BL460c Gen10':
|
||||||
return value
|
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):
|
def get_blade_slot(self):
|
||||||
if self.is_blade():
|
if self.is_blade():
|
||||||
|
|
Loading…
Reference in a new issue