2019-08-29 16:13:04 +02:00
|
|
|
from netbox_agent.location import Slot
|
2019-08-02 18:39:05 +02:00
|
|
|
from netbox_agent.server import ServerBase
|
|
|
|
|
2019-08-04 00:00:22 +02:00
|
|
|
|
2019-08-26 15:38:44 +02:00
|
|
|
class SupermicroHost(ServerBase):
|
2019-08-29 17:33:27 +02:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(SupermicroHost, self).__init__(*args, **kwargs)
|
|
|
|
self.manufacturer = 'Supermicro'
|
|
|
|
|
2019-08-02 18:39:05 +02:00
|
|
|
def is_blade(self):
|
2019-08-29 17:33:27 +02:00
|
|
|
blade = self.get_product_name().startswith('SBI')
|
|
|
|
blade |= self.get_product_name().startswith('SYS')
|
|
|
|
return blade
|
2019-08-02 18:39:05 +02:00
|
|
|
|
|
|
|
def get_blade_slot(self):
|
2019-08-29 16:13:04 +02:00
|
|
|
if self.is_blade():
|
|
|
|
# Some Supermicro servers don't report the slot in dmidecode
|
|
|
|
# let's use a regex
|
|
|
|
slot = Slot()
|
|
|
|
return slot.get()
|
2019-08-26 15:38:44 +02:00
|
|
|
# No supermicro on hands
|
2019-08-02 18:39:05 +02:00
|
|
|
return None
|
|
|
|
|
2019-08-08 14:37:02 +02:00
|
|
|
def get_chassis_name(self):
|
|
|
|
if not self.is_blade():
|
|
|
|
return None
|
|
|
|
return 'Chassis {}'.format(self.get_service_tag())
|
|
|
|
|
2019-08-02 18:39:05 +02:00
|
|
|
def get_chassis(self):
|
|
|
|
if self.is_blade():
|
2019-08-03 15:46:21 +02:00
|
|
|
return self.dmi.get_by_type('Chassis')[0]['Version']
|
2019-08-02 18:39:05 +02:00
|
|
|
return self.get_product_name()
|
|
|
|
|
|
|
|
def get_chassis_service_tag(self):
|
|
|
|
if self.is_blade():
|
2019-08-20 13:50:38 +02:00
|
|
|
return self.dmi.get_by_type('Chassis')[0]['Serial Number']
|
2019-08-03 15:46:21 +02:00
|
|
|
return self.get_service_tag()
|