report vendor on hp raid

This commit is contained in:
Solvik Blum 2019-09-05 14:02:48 +02:00
commit b0ead9ebb3
No known key found for this signature in database
GPG key ID: CC12B3DC262B6C47
2 changed files with 9 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import re
import subprocess import subprocess
from netbox_agent.raid.base import Raid, RaidController from netbox_agent.raid.base import Raid, RaidController
from netbox_agent.misc import get_vendor
REGEXP_CONTROLLER_HP = re.compile(r'Smart Array ([a-zA-Z0-9- ]+) in Slot ([0-9]+)') REGEXP_CONTROLLER_HP = re.compile(r'Smart Array ([a-zA-Z0-9- ]+) in Slot ([0-9]+)')
@ -120,12 +121,18 @@ class HPRaidController(RaidController):
key = next(iter(info_dict)) key = next(iter(info_dict))
for array, physical_disk in info_dict[key].items(): for array, physical_disk in info_dict[key].items():
for _, pd_attr in physical_disk.items(): for _, pd_attr in physical_disk.items():
model = pd_attr.get('Model', '').strip()
vendor = get_vendor(model)
if len(model.split()) > 1:
vendor = get_vendor(model.split()[1])
ret.append({ ret.append({
'Model': pd_attr.get('Model', '').strip(), 'Model': model,
'Vendor': vendor,
'SN': pd_attr.get('Serial Number', '').strip(), 'SN': pd_attr.get('Serial Number', '').strip(),
'Size': pd_attr.get('Size', '').strip(), 'Size': pd_attr.get('Size', '').strip(),
'Type': 'SSD' if pd_attr.get('Interface Type') == 'Solid State SATA' 'Type': 'SSD' if pd_attr.get('Interface Type') == 'Solid State SATA'
else 'HDD', else 'HDD',
'_src': self.__class__.__name__,
}) })
return ret return ret

View file

@ -46,6 +46,7 @@ class StorcliController(RaidController):
'SN': drive_attr.get('SN', '').strip(), 'SN': drive_attr.get('SN', '').strip(),
'Size': size, 'Size': size,
'Type': media_type, 'Type': media_type,
'_src': self.__class__.__name__,
}) })
return ret return ret