diff --git a/netbox_agent/inventory.py b/netbox_agent/inventory.py index 3b9e305..40e73d4 100644 --- a/netbox_agent/inventory.py +++ b/netbox_agent/inventory.py @@ -371,7 +371,7 @@ class Inventory(): desc = disk.get('description') name = '{} ({})'.format(disk['Model'], disk['Size']) description = disk['Type'] - sn = getattr(disk, 'SN', 'unknown') + sn = disk.get('SN', 'unknown') parms = { 'device': self.device_id, diff --git a/netbox_agent/raid/hp.py b/netbox_agent/raid/hp.py index 2d6bcd6..ce30deb 100644 --- a/netbox_agent/raid/hp.py +++ b/netbox_agent/raid/hp.py @@ -18,20 +18,20 @@ def ssacli(sub_command): stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) - p.wait() - stdout = p.stdout.read().decode("utf-8") - if p.returncode != 0 and 'does not have any physical' not in stdout: + stdout, stderr = p.communicate() + stdout = stdout.decode("utf-8") + if p.returncode != 0: mesg = "Failed to execute command '{}':\n{}".format( " ".join(command), stdout ) raise HPRaidControllerError(mesg) + + if 'does not have any physical' in stdout: + return list() else: - if 'does not have any physical' in stdout: - return list() - else: - lines = stdout.split('\n') - lines = list(filter(None, lines)) - return lines + lines = stdout.split('\n') + lines = list(filter(None, lines)) + return lines def _test_if_valid_line(line): ignore_patterns = ['Note:', 'Error:', 'is not loaded', 'README', ' failure', ' cache'] @@ -172,7 +172,12 @@ class HPRaidController(RaidController): 'Type': 'SSD' if attrs.get('Interface Type') == 'Solid State SATA' else 'HDD', '_src': self.__class__.__name__, - 'custom_fields': {'pd_identifier': name} + 'custom_fields': { + 'pd_identifier': name, + 'mount_point': attrs['Mount Points'], + 'vd_device': attrs['Disk Name'], + 'vd_size': attrs['Size'], + } } return ret