use lshw for inventory (#58)

* Use lshw for inventory
* Add motherboard to inventory
* Handle non raid devices
* Handle nvme drives
This commit is contained in:
ThomasADavis 2019-09-05 06:13:36 -07:00 committed by Solvik
parent 7049434612
commit b7b22ae316
7 changed files with 500 additions and 157 deletions

View file

@ -1,6 +1,20 @@
from netbox_agent.location import Slot
from netbox_agent.server import ServerBase
"""
Supermicro DMI can be messed up. They depend on the vendor
to set the correct values. The endusers cannot
change them without buying a license from Supermicro.
There are 3 serial numbers in the system
1) System - this is used for the chassis information.
2) Baseboard - this is used for the blade.
3) Chassis - this is ignored.
"""
class SupermicroHost(ServerBase):
def __init__(self, *args, **kwargs):
@ -8,8 +22,8 @@ class SupermicroHost(ServerBase):
self.manufacturer = 'Supermicro'
def is_blade(self):
blade = self.get_product_name().startswith('SBI')
blade |= self.get_product_name().startswith('SYS')
blade = self.system[0]['Product Name'].startswith('SBI')
blade |= self.system[0]['Product Name'].startswith('SYS')
return blade
def get_blade_slot(self):
@ -21,17 +35,25 @@ class SupermicroHost(ServerBase):
# No supermicro on hands
return None
def get_chassis_name(self):
if not self.is_blade():
return None
return 'Chassis {}'.format(self.get_service_tag())
def get_service_tag(self):
return self.baseboard[0]['Serial Number'].strip()
def get_product_name(self):
if self.is_blade():
return self.baseboard[0]['Product Name'].strip()
return self.system[0]['Product Name'].strip()
def get_chassis(self):
if self.is_blade():
return self.dmi.get_by_type('Chassis')[0]['Version']
return self.system[0]['Product Name'].strip()
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']
return self.system[0]['Serial Number'].strip()
return self.get_service_tag()
def get_chassis_name(self):
if not self.is_blade():
return None
return 'Chassis {}'.format(self.get_chassis_service_tag())