13
13
raise ImportError (str (e ) + " - required module not found" )
14
14
15
15
16
+ # NOTE: This class inherits the metaclass 'abc.ABCMeta' from DeviceBase
16
17
class ChassisBase (device_base .DeviceBase ):
17
18
"""
18
19
Abstract base class for interfacing with a platform chassis
19
20
"""
20
21
21
- __metaclass__ = abc .ABCMeta
22
-
23
22
# Possible reboot causes
24
- REBOOT_CAUSE_POWER_LOSS = "power_loss"
23
+ REBOOT_CAUSE_POWER_LOSS = "power_loss"
25
24
REBOOT_CAUSE_THERMAL_OVERLOAD = "thermal_overload"
26
25
REBOOT_CAUSE_INSUFFICIENT_FAN = "insufficient_fan"
27
26
REBOOT_CAUSE_WATCHDOG = "watchdog"
28
27
REBOOT_CAUSE_SOFTWARE = "software"
29
28
30
- # List of all fans available on the chassis
31
- fan_list = []
29
+
30
+ # List of FanBase-derived objects representing all fans
31
+ # available on the chassis
32
+ _fan_list = []
33
+
34
+ # List of PsuBase-derived objects representing all power supply units
35
+ # available on the chassis
36
+ _psu_list = []
37
+
38
+ # Object derived from WatchdogBase for interacting with hardware watchdog
39
+ _watchdog = None
32
40
33
41
@abc .abstractmethod
34
42
def get_base_mac (self ):
@@ -39,7 +47,7 @@ def get_base_mac(self):
39
47
A string containing the MAC address in the format
40
48
'XX:XX:XX:XX:XX:XX'
41
49
"""
42
- return None
50
+ return None
43
51
44
52
@abc .abstractmethod
45
53
def get_reboot_cause (self ):
@@ -52,14 +60,18 @@ def get_reboot_cause(self):
52
60
"""
53
61
return REBOOT_CAUSE_SOFTWARE
54
62
63
+ ##############################################
64
+ # Fan module methods
65
+ ##############################################
66
+
55
67
def get_num_fans (self ):
56
68
"""
57
69
Retrieves the number of fan modules available on this chassis
58
70
59
71
Returns:
60
72
An integer, the number of fan modules available on this chassis
61
73
"""
62
- return len (self .fan_list )
74
+ return len (self ._fan_list )
63
75
64
76
def get_all_fans (self ):
65
77
"""
@@ -69,7 +81,7 @@ def get_all_fans(self):
69
81
A list of objects derived from FanBase representing all fan
70
82
modules available on this chassis
71
83
"""
72
- return self .fan_list
84
+ return self ._fan_list
73
85
74
86
def get_fan (self , index ):
75
87
"""
@@ -86,9 +98,65 @@ def get_fan(self, index):
86
98
fan = None
87
99
88
100
try :
89
- fan = self .fan_list [index ]
101
+ fan = self ._fan_list [index ]
90
102
except IndexError :
91
103
sys .stderr .write ("Fan index {} out of range (0-{})\n " .format (
92
- index , len (self .fan_list )- 1 ))
104
+ index , len (self ._fan_list )- 1 ))
93
105
94
106
return fan
107
+
108
+ ##############################################
109
+ # PSU module methods
110
+ ##############################################
111
+
112
+ def get_num_psus (self ):
113
+ """
114
+ Retrieves the number of power supply units available on this chassis
115
+
116
+ Returns:
117
+ An integer, the number of power supply units available on this
118
+ chassis
119
+ """
120
+ return len (self ._psu_list )
121
+
122
+ def get_all_psus (self ):
123
+ """
124
+ Retrieves all power supply units available on this chassis
125
+
126
+ Returns:
127
+ A list of objects derived from PsuBase representing all power
128
+ supply units available on this chassis
129
+ """
130
+ return self ._psu_list
131
+
132
+ def get_fan (self , index ):
133
+ """
134
+ Retrieves power supply unit represented by (1-based) index <index>
135
+
136
+ Args:
137
+ index: An integer, the index (1-based) of the power supply unit to
138
+ retrieve
139
+
140
+ Returns:
141
+ An object dervied from PsuBase representing the specified power
142
+ supply unit
143
+ """
144
+ psu = None
145
+
146
+ try :
147
+ psu = self ._psu_list [index ]
148
+ except IndexError :
149
+ sys .stderr .write ("PSU index {} out of range (0-{})\n " .format (
150
+ index , len (self ._psu_list )- 1 ))
151
+
152
+ return psu
153
+
154
+ def get_watchdog (self ):
155
+ """
156
+ Retreives hardware watchdog module on this chassis
157
+
158
+ Returns:
159
+ An object derived from WatchdogBase representing the hardware
160
+ watchdog module
161
+ """
162
+ return _watchdog
0 commit comments