5
5
# to interact with a fan module in SONiC
6
6
#
7
7
8
- try :
9
- import abc
10
- from . import device_base
11
- except ImportError as e :
12
- raise ImportError (str (e ) + " - required module not found" )
8
+ from . import device_base
13
9
14
10
15
- # NOTE: This class inherits the metaclass 'abc.ABCMeta' from DeviceBase
16
11
class FanBase (device_base .DeviceBase ):
17
12
"""
18
13
Abstract base class for interfacing with a fan module
19
14
"""
20
15
21
- # Possible fan directions
16
+ # Possible fan directions (relative to port-side of device)
22
17
FAN_DIRECTION_INTAKE = "intake"
23
18
FAN_DIRECTION_EXHAUST = "exhaust"
24
19
@@ -27,7 +22,6 @@ class FanBase(device_base.DeviceBase):
27
22
STATUS_LED_COLOR_RED = "red"
28
23
STATUS_LED_COLOR_OFF = "off"
29
24
30
- @abc .abstractmethod
31
25
def get_direction (self ):
32
26
"""
33
27
Retrieves the direction of fan
@@ -36,9 +30,8 @@ def get_direction(self):
36
30
A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST
37
31
depending on fan direction
38
32
"""
39
- return None
33
+ raise NotImplementedError
40
34
41
- @abc .abstractmethod
42
35
def get_speed (self ):
43
36
"""
44
37
Retrieves the speed of fan as a percentage of full speed
@@ -47,9 +40,8 @@ def get_speed(self):
47
40
An integer, the percentage of full fan speed, in the range 0 (off)
48
41
to 100 (full speed)
49
42
"""
50
- return 0
43
+ raise NotImplementedError
51
44
52
- @abc .abstractmethod
53
45
def get_target_speed (self ):
54
46
"""
55
47
Retrieves the target (expected) speed of the fan
@@ -58,9 +50,8 @@ def get_target_speed(self):
58
50
An integer, the percentage of full fan speed, in the range 0 (off)
59
51
to 100 (full speed)
60
52
"""
61
- return 0
53
+ raise NotImplementedError
62
54
63
- @abc .abstractmethod
64
55
def get_speed_tolerance (self ):
65
56
"""
66
57
Retrieves the speed tolerance of the fan
@@ -69,9 +60,8 @@ def get_speed_tolerance(self):
69
60
An integer, the percentage of variance from target speed which is
70
61
considered tolerable
71
62
"""
72
- return 0
63
+ raise NotImplementedError
73
64
74
- @abc .abstractmethod
75
65
def set_speed (self , speed ):
76
66
"""
77
67
Sets the fan speed
@@ -83,9 +73,8 @@ def set_speed(self, speed):
83
73
Returns:
84
74
A boolean, True if speed is set successfully, False if not
85
75
"""
86
- return False
76
+ raise NotImplementedError
87
77
88
- @abc .abstractmethod
89
78
def set_status_led (self , color ):
90
79
"""
91
80
Sets the state of the fan module status LED
@@ -97,4 +86,4 @@ def set_status_led(self, color):
97
86
Returns:
98
87
bool: True if status LED state is set successfully, False if not
99
88
"""
100
- return False
89
+ raise NotImplementedError
0 commit comments