-
Notifications
You must be signed in to change notification settings - Fork 73
/
supermicro.py
79 lines (65 loc) · 2.49 KB
/
supermicro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from netbox_agent.location import Slot
from netbox_agent.server import ServerBase
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.
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.
"""
def __init__(self, *args, **kwargs):
super(SupermicroHost, self).__init__(*args, **kwargs)
self.manufacturer = 'Supermicro'
def is_blade(self):
product_name = self.system[0]['Product Name'].strip()
# Blades
blade = product_name.startswith('SBI')
blade |= product_name.startswith('SBA')
# Twin
blade |= 'TR-' in product_name
# TwinPro
blade |= 'TP-' in product_name
# BigTwin
blade |= 'BT-' in product_name
# Microcloud
blade |= product_name.startswith('SYS-5039')
blade |= product_name.startswith('SYS-5038')
return blade
def get_blade_slot(self):
if self.is_blade():
# Some Supermicro servers don't report the slot in dmidecode
# let's use a regex
slot = Slot()
return slot.get()
# No supermicro on hands
return None
def get_service_tag(self):
if self.is_blade():
return self.baseboard[0]['Serial Number'].strip()
return self.system[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.system[0]['Product Name'].strip()
return self.get_product_name()
def get_chassis_service_tag(self):
if self.is_blade():
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())
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