fix: prevent crash if disk fields attrs missing #260

Merged
cyrinux merged 1 commit from fix/cle/hp-inventory-fix-2 into master 2022-12-14 09:02:16 +01:00
Showing only changes of commit 4cf054278f - Show all commits

View file

@ -174,9 +174,9 @@ class HPRaidController(RaidController):
'_src': self.__class__.__name__, '_src': self.__class__.__name__,
'custom_fields': { 'custom_fields': {
'pd_identifier': name, 'pd_identifier': name,
'mount_point': attrs['Mount Points'], 'mount_point': attrs.get('Mount Points', '').strip(),
'vd_device': attrs['Disk Name'], 'vd_device': attrs.get('Disk Name', '').strip(),
'vd_size': attrs['Size'], 'vd_size': attrs.get('Size', '').strip(),
} }
} }
return ret return ret
@ -189,11 +189,11 @@ class HPRaidController(RaidController):
for array, attrs in ldrives.items(): for array, attrs in ldrives.items():
ret[array] = { ret[array] = {
'vd_array': array, 'vd_array': array,
'vd_size': attrs['Size'], 'vd_size': attrs.get('Size', '').strip(),
'vd_consistency': attrs['Status'], 'vd_consistency': attrs.get('Status', '').strip(),
'vd_raid_type': 'RAID {}'.format(attrs['Fault Tolerance']), 'vd_raid_type': 'RAID {}'.format(attrs.get('Fault Tolerance', 'N/A').strip()),
'vd_device': attrs['LogicalDrive'], 'vd_device': attrs.get('LogicalDrive', '').strip(),
'mount_point': attrs['Mount Points'] 'mount_point': attrs.get('Mount Points', '').strip()
} }
return ret return ret