diff --git a/netbox_agent/power.py b/netbox_agent/power.py index a0cf0e6..a5ec922 100644 --- a/netbox_agent/power.py +++ b/netbox_agent/power.py @@ -20,7 +20,10 @@ class PowerSupply(): if 'Present' not in psu['Status']: continue - max_power = psu.get('Max Power Capacity').split()[0] + try: + max_power = int(psu.get('Max Power Capacity').split()[0]) + except ValueError: + max_power = None desc = '{} - {}'.format( psu.get('Manufacturer', 'No Manufacturer').strip(), psu.get('Name', 'No name').strip(), @@ -29,7 +32,7 @@ class PowerSupply(): 'name': psu.get('Serial Number', 'No S/N').strip(), 'description': desc, 'allocated_draw': None, - 'maximum_draw': int(max_power), + 'maximum_draw': max_power, 'device': self.device_id, }) return power_supply diff --git a/netbox_agent/vendors/dell.py b/netbox_agent/vendors/dell.py index e7838f0..3ef06ac 100644 --- a/netbox_agent/vendors/dell.py +++ b/netbox_agent/vendors/dell.py @@ -20,7 +20,7 @@ class DellHost(ServerBase): ` Location In Chassis: Slot 03` """ if self.is_blade(): - return self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis').strip() + return self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis') return None def get_chassis_name(self): @@ -30,12 +30,12 @@ class DellHost(ServerBase): def get_chassis(self): if self.is_blade(): - return self.dmi.get_by_type('Chassis')[0]['Version'].strip() + return self.dmi.get_by_type('Chassis')[0]['Version'] return self.get_product_name() def get_chassis_service_tag(self): if self.is_blade(): - return self.dmi.get_by_type('Chassis')[0]['Serial Number'].strip() + return self.dmi.get_by_type('Chassis')[0]['Serial Number'] return self.get_service_tag() def get_power_consumption(self): diff --git a/netbox_agent/vendors/qct.py b/netbox_agent/vendors/qct.py index 6051da1..7e18e96 100644 --- a/netbox_agent/vendors/qct.py +++ b/netbox_agent/vendors/qct.py @@ -12,7 +12,7 @@ class QCTHost(ServerBase): def get_blade_slot(self): if self.is_blade(): return 'Slot {}'.format( - self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis').strip() + self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis') ) return None @@ -23,10 +23,10 @@ class QCTHost(ServerBase): def get_chassis(self): if self.is_blade(): - return self.dmi.get_by_type('Chassis')[0]['Version'].strip() + return self.dmi.get_by_type('Chassis')[0]['Version'] return self.get_product_name() def get_chassis_service_tag(self): if self.is_blade(): - return self.dmi.get_by_type('Chassis')[0]['Serial Number'].strip() + return self.dmi.get_by_type('Chassis')[0]['Serial Number'] return self.get_service_tag()