handle HP RAID physical disk

This commit is contained in:
Solvik Blum 2019-08-21 17:22:22 +02:00
parent b30591b382
commit 4c3864b94e
No known key found for this signature in database
GPG key ID: CC12B3DC262B6C47
2 changed files with 26 additions and 0 deletions

View file

@ -12,6 +12,9 @@ class RaidController():
def get_firmware_version(self):
raise NotImplementedError
def get_physical_disks(self):
raise NotImplementedError
class Raid():
def get_controllers(self):

View file

@ -106,6 +106,29 @@ class HPRaidController(RaidController):
def get_firmware_version(self):
return self.data['Firmware Version']
def get_physical_disks(self):
ret = []
output = subprocess.getoutput(
'ssacli ctrl slot={slot} pd all show detail'.format(slot=self.data['Slot'])
)
lines = output.split('\n')
lines = list(filter(None, lines))
j = -1
while j < len(lines):
info_dict, j = _get_dict(lines, j + 1, 0)
key = next(iter(info_dict))
for array, physical_disk in info_dict[key].items():
for _, pd_attr in physical_disk.items():
ret.append({
'Model': pd_attr.get('Model', '').strip(),
'SN': pd_attr.get('Serial Number', '').strip(),
'Size': pd_attr.get('Size', '').strip(),
'Type': 'SSD' if pd_attr.get('Interface Type') == 'Solid State SATA'
else 'HDD',
})
return ret
class HPRaid(Raid):
def __init__(self):