-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathdell.py
88 lines (71 loc) · 2.4 KB
/
dell.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
80
81
82
83
84
85
86
87
88
import logging
import subprocess
from netbox_agent.misc import is_tool
from netbox_agent.server import ServerBase
class DellHost(ServerBase):
def __init__(self, *args, **kwargs):
super(DellHost, self).__init__(*args, **kwargs)
self.manufacturer = "Dell"
def is_blade(self):
return self.get_product_name().startswith("PowerEdge M")
def get_blade_slot(self):
"""
Return blade slot
dmidecode output is:
` Location In Chassis: Slot 03`
"""
if self.is_blade():
return self.baseboard[0].get("Location In Chassis").strip()
return None
def get_chassis_name(self):
if not self.is_blade():
return None
return "Chassis {}".format(self.get_service_tag())
def get_chassis(self):
if self.is_blade():
return self.chassis[0]["Version"].strip()
return self.get_product_name()
def get_chassis_service_tag(self):
if self.is_blade():
return self.chassis[0]["Serial Number"].strip()
return self.get_service_tag()
def get_power_consumption(self):
"""
Parse omreport output like this
Amperage
PS1 Current 1 : 1.8 A
PS2 Current 2 : 1.4 A
"""
value = []
if not is_tool("omreport"):
logging.error("omreport does not seem to be installed, please debug")
return value
data = subprocess.getoutput("omreport chassis pwrmonitoring")
amperage = False
for line in data.splitlines():
if line.startswith("Amperage"):
amperage = True
continue
if amperage:
if line.startswith("PS"):
amp_value = line.split(":")[1].split()[0]
value.append(amp_value)
else:
break
return value
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
"""
raise NotImplementedError
def is_expansion_slot(self, server):
"""
Return True if its an extension slot
"""
raise NotImplementedError
def get_blade_expansion_slot(self):
"""
Expansion slot are always the compute bay number + 1
"""
raise NotImplementedError