Merge pull request #260 from Solvik/fix/cle/hp-inventory-fix-2

fix: prevent crash if disk fields attrs missing
This commit is contained in:
Cyril Levis 2022-12-14 09:02:16 +01:00 committed by GitHub
commit 117b39350e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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