Skip to content

Commit 5ad58e1

Browse files
committed
Change control-card to supervisor
Fixes for other review comments * Pass NotImplemented errors without exception * Add more decscriptive headers for APIs
1 parent 7b325a1 commit 5ad58e1

3 files changed

Lines changed: 27 additions & 13 deletions

File tree

sonic_platform_base/chassis_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def get_controlcard_slot(self):
117117
An integer, the slot identifier of the control card of the
118118
modular-chassis.
119119
"""
120-
return 0
120+
return DeviceBase.NotImplementedInt
121121

122122
def get_my_slot(self):
123123
"""
@@ -127,7 +127,7 @@ def get_my_slot(self):
127127
An integer, the slot identifier of this card of the
128128
modular-chassis.
129129
"""
130-
return 0
130+
return DeviceBase.NotImplementedInt
131131

132132
##############################################
133133
# Component methods
@@ -222,8 +222,8 @@ def get_module_index(self, module_name):
222222
Retrieves module index from the module name
223223
224224
Args:
225-
name: A string, prefixed by CONTROL-CARD, LINE-CARD or FABRIC-CARD
226-
Ex. CONTROL-CARD1, LINE-CARD1, FABRIC-CARD5
225+
name: A string, prefixed by SUPERVISOR, LINE-CARD or FABRIC-CARD
226+
Ex. SUPERVISOR0, LINE-CARD1, FABRIC-CARD5
227227
228228
Returns:
229229
An index of the ModuleBase object in the module_list

sonic_platform_base/device_base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ class DeviceBase(object):
1111
peripheral device
1212
"""
1313

14+
#Error codes for abstract APIs that are not implemented.
15+
#If APIs are to be implemented by all platforms use 'raise NotImplementedError'.
16+
#If not, use one of these return codes. Intention is to not raise an
17+
#exception to provide backward compatibility.
18+
NotImplementedInt = -1
19+
NotImplementedFloat = -1.0
20+
NotImplementedStr = "Not implemented"
21+
1422
def get_name(self):
1523
"""
1624
Retrieves the name of the device

sonic_platform_base/module_base.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,21 @@ class ModuleBase(device_base.DeviceBase):
1818
DEVICE_TYPE = "module"
1919

2020
# Possible card types
21-
MODULE_TYPE_CONTROL = "CONTROL-CARD"
21+
MODULE_TYPE_SUPERVISOR = "SUPERVISOR"
2222
MODULE_TYPE_LINE = "LINE-CARD"
2323
MODULE_TYPE_FABRIC = "FABRIC-CARD"
2424

2525
# Possible card status
26+
#Module state is Empty if no module is inserted in the slot
2627
MODULE_STATUS_EMPTY = "Empty"
28+
#Module state if Offline if powered down. This is also the admin-down state.
2729
MODULE_STATUS_OFFLINE = "Offline"
30+
#Module state is Present when it is powered up, but not fully functional.
2831
MODULE_STATUS_PRESENT = "Present"
32+
#Module state is Present when it is powered up, but entered a fault state.
33+
#Module is not able to go Online.
2934
MODULE_STATUS_FAULT = "Fault"
35+
#Module state is Online when fully operational
3036
MODULE_STATUS_ONLINE = "Online"
3137

3238
# List of ComponentBase-derived objects representing all components
@@ -82,16 +88,16 @@ def get_system_eeprom_info(self):
8288

8389
def get_name(self):
8490
"""
85-
Retrieves the name of the module prefixed by CONTROL-CARD, LINE-CARD,
91+
Retrieves the name of the module prefixed by SUPERVISOR, LINE-CARD,
8692
FABRIC-CARD
8793
8894
Returns:
8995
string: A string providing the name of the card prefixed by one of the
90-
MODULE_TYPE_CONTROL, MODULE_TYPE_LINE, MODULE_TYPE_FABRIC followed by
96+
MODULE_TYPE_SUPERVISOR, MODULE_TYPE_LINE, MODULE_TYPE_FABRIC followed by
9197
an index.
9298
Ex. A Chassis having 1 control-card, 4 line-cards and 6 fabric-cards
93-
can provide names CONTROL-CARD1, LINE-CARD1 to LINE-CARD4,
94-
FABRIC-CARD1 to FABRIC-CARD6
99+
can provide names SUPERVISOR0, LINE-CARD0 to LINE-CARD3,
100+
FABRIC-CARD0 to FABRIC-CARD5
95101
"""
96102
raise NotImplementedError
97103

@@ -110,7 +116,7 @@ def get_slot(self):
110116
Retrieves the platform vendor's slot number of the module
111117
112118
Returns:
113-
string: slot representation, usually number
119+
An integer, indicating the slot number in the chassis
114120
"""
115121
raise NotImplementedError
116122

@@ -120,7 +126,7 @@ def get_type(self):
120126
121127
Returns:
122128
string: A string providing the module-type. Supported values are
123-
MODULE_TYPE_CONTROL, MODULE_TYPE_LINE, MODULE_TYPE_FABRIC
129+
MODULE_TYPE_SUPERVISOR, MODULE_TYPE_LINE, MODULE_TYPE_FABRIC
124130
"""
125131
raise NotImplementedError
126132

@@ -135,9 +141,9 @@ def get_status(self):
135141
"""
136142
raise NotImplementedError
137143

138-
def reboot_card(self):
144+
def reboot(self):
139145
"""
140-
Request to reboot the card
146+
Request to reboot the module
141147
142148
Returns:
143149
bool: True if the request has been issued successfully, False if not

0 commit comments

Comments
 (0)