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
|
|
|
|
|
2020-02-02 20:08:56 +01:00
|
|
|
|
2020-08-24 12:52:25 +02:00
|
|
|
class SupermicroHost(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.
|
2019-09-05 15:13:36 +02:00
|
|
|
|
2020-08-24 12:52:25 +02:00
|
|
|
There are 3 serial numbers in the system
|
2019-09-05 15:13:36 +02:00
|
|
|
|
2020-08-24 12:52:25 +02:00
|
|
|
1) System - this is used for the chassis information.
|
|
|
|
2) Baseboard - this is used for the blade.
|
|
|
|
3) Chassis - this is ignored.
|
2019-09-05 15:13:36 +02:00
|
|
|
|
2020-08-24 12:52:25 +02:00
|
|
|
"""
|
2019-08-04 00:00:22 +02:00
|
|
|
|
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):
|
2020-07-11 15:56:10 +02:00
|
|
|
product_name = self.get_product_name()
|
|
|
|
# Blades
|
|
|
|
blade = product_name.startswith('SBI')
|
|
|
|
blade |= product_name.startswith('SBA')
|
|
|
|
# Twin
|
|
|
|
blade |= 'TR-' in product_name
|
|
|
|
# BigTwin
|
|
|
|
blade |= 'BT-' in product_name
|
|
|
|
# Microcloud
|
|
|
|
blade |= product_name.startswith('SYS-5039')
|
|
|
|
blade |= product_name.startswith('SYS-5038')
|
2019-08-29 17:33:27 +02:00
|
|
|
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-09-05 15:13:36 +02:00
|
|
|
def get_service_tag(self):
|
2020-07-13 20:34:04 +02:00
|
|
|
return self.system[0]['Serial Number'].strip()
|
2019-09-05 15:13:36 +02:00
|
|
|
|
|
|
|
def get_product_name(self):
|
|
|
|
return self.system[0]['Product Name'].strip()
|
2019-08-08 14:37:02 +02:00
|
|
|
|
2019-08-02 18:39:05 +02:00
|
|
|
def get_chassis(self):
|
|
|
|
if self.is_blade():
|
2020-07-13 20:34:04 +02:00
|
|
|
return self.chassis[0]['Product Name'].strip()
|
2019-08-02 18:39:05 +02:00
|
|
|
return self.get_product_name()
|
|
|
|
|
|
|
|
def get_chassis_service_tag(self):
|
|
|
|
if self.is_blade():
|
2020-07-13 20:34:04 +02:00
|
|
|
return self.chassis[0]['Serial Number'].strip()
|
2019-08-03 15:46:21 +02:00
|
|
|
return self.get_service_tag()
|
2019-09-05 15:13:36 +02:00
|
|
|
|
|
|
|
def get_chassis_name(self):
|
|
|
|
if not self.is_blade():
|
|
|
|
return None
|
|
|
|
return 'Chassis {}'.format(self.get_chassis_service_tag())
|
2020-09-18 12:29:17 +02:00
|
|
|
|
|
|
|
def get_expansion_product(self):
|
|
|
|
"""
|
|
|
|
Get the extension slot that is on a pair slot number
|
|
|
|
next to the compute slot that is on an odd slot number
|
|
|
|
I only know on model of slot GPU extension card that.
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def is_expansion_slot(self, server):
|
|
|
|
"""
|
|
|
|
Return True if its an extension slot, based on the name
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def get_blade_expansion_slot(self):
|
|
|
|
"""
|
|
|
|
Expansion slot are always the compute bay number + 1
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def own_expansion_slot(self):
|
|
|
|
"""
|
|
|
|
Say if the device can host an extension card based
|
|
|
|
on the product name
|
|
|
|
"""
|
|
|
|
pass
|