1
- #
2
- # module_base.py
3
- #
4
- # Base class for implementing a platform-specific class with which
5
- # to interact with a module (as used in a modular chassis) SONiC.
6
- #
1
+ """
2
+ module_base.py
3
+
4
+ Base class for implementing a platform-specific class with which
5
+ to interact with a module (as used in a modular chassis) SONiC.
6
+ """
7
7
8
8
import sys
9
9
from . import device_base
12
12
class ModuleBase (device_base .DeviceBase ):
13
13
"""
14
14
Base class for interfacing with a module (supervisor module, line card
15
- module, etc. (applicable for a modular chassis)
15
+ module, etc. (applicable for a modular chassis)
16
16
"""
17
17
# Device type definition. Note, this is a constant.
18
18
DEVICE_TYPE = "module"
@@ -50,31 +50,25 @@ class ModuleBase(device_base.DeviceBase):
50
50
# Module reboot type to reboot FPGA complex
51
51
MODULE_REBOOT_FPGA_COMPLEX = "FPGA"
52
52
53
- # List of ComponentBase-derived objects representing all components
54
- # available on the module
55
- _component_list = None
56
-
57
- # List of FanBase-derived objects representing all fans
58
- # available on the module
59
- _fan_list = None
60
-
61
- # List of PsuBase-derived objects representing all power supply units
62
- # available on the module
63
- _psu_list = None
64
-
65
- # List of ThermalBase-derived objects representing all thermals
66
- # available on the module
67
- _thermal_list = None
68
-
69
- # List of SfpBase-derived objects representing all sfps
70
- # available on the module
71
- _sfp_list = None
72
-
73
53
def __init__ (self ):
54
+ # List of ComponentBase-derived objects representing all components
55
+ # available on the module
74
56
self ._component_list = []
57
+
58
+ # List of FanBase-derived objects representing all fans
59
+ # available on the module
75
60
self ._fan_list = []
61
+
62
+ # List of PsuBase-derived objects representing all power supply units
63
+ # available on the module
76
64
self ._psu_list = []
65
+
66
+ # List of ThermalBase-derived objects representing all thermals
67
+ # available on the module
77
68
self ._thermal_list = []
69
+
70
+ # List of SfpBase-derived objects representing all sfps
71
+ # available on the module
78
72
self ._sfp_list = []
79
73
80
74
def get_base_mac (self ):
@@ -89,15 +83,15 @@ def get_base_mac(self):
89
83
90
84
def get_system_eeprom_info (self ):
91
85
"""
92
- Retrieves the full content of system EEPROM information for the module
86
+ Retrieves the full content of system EEPROM information for the module
93
87
94
88
Returns:
95
89
A dictionary where keys are the type code defined in
96
90
OCP ONIE TlvInfo EEPROM format and values are their corresponding
97
91
values.
98
- Ex. { ‘ 0x21’:’ AG9064’, ‘ 0x22’:’ V1.0’, ‘ 0x23’:’ AG9064-0109867821’ ,
99
- ‘ 0x24’:’ 001c0f000fcd0a’, ‘ 0x25’:’ 02/03/2018 16:22:00’ ,
100
- ‘ 0x26’:’01’, ‘ 0x27’:’ REV01’, ‘ 0x28’:’ AG9064-C2358-16G’ }
92
+ Ex. { ' 0x21': ' AG9064', ' 0x22': ' V1.0', ' 0x23': ' AG9064-0109867821' ,
93
+ ' 0x24': ' 001c0f000fcd0a', ' 0x25': ' 02/03/2018 16:22:00' ,
94
+ ' 0x26': '01', ' 0x27': ' REV01', ' 0x28': ' AG9064-C2358-16G' }
101
95
"""
102
96
raise NotImplementedError
103
97
@@ -254,11 +248,11 @@ def get_num_fans(self):
254
248
255
249
def get_all_fans (self ):
256
250
"""
257
- Retrieves all fan modules available on this module
251
+ Retrieves all fan modules available on this module
258
252
259
253
Returns:
260
254
A list of objects derived from FanBase representing all fan
261
- modules available on this module
255
+ modules available on this module
262
256
"""
263
257
return self ._fan_list
264
258
@@ -290,21 +284,21 @@ def get_fan(self, index):
290
284
291
285
def get_num_psus (self ):
292
286
"""
293
- Retrieves the number of power supply units available on this module
287
+ Retrieves the number of power supply units available on this module
294
288
295
289
Returns:
296
290
An integer, the number of power supply units available on this
297
- module
291
+ module
298
292
"""
299
293
return len (self ._psu_list )
300
294
301
295
def get_all_psus (self ):
302
296
"""
303
- Retrieves all power supply units available on this module
297
+ Retrieves all power supply units available on this module
304
298
305
299
Returns:
306
300
A list of objects derived from PsuBase representing all power
307
- supply units available on this module
301
+ supply units available on this module
308
302
"""
309
303
return self ._psu_list
310
304
@@ -336,20 +330,20 @@ def get_psu(self, index):
336
330
337
331
def get_num_thermals (self ):
338
332
"""
339
- Retrieves the number of thermals available on this module
333
+ Retrieves the number of thermals available on this module
340
334
341
335
Returns:
342
- An integer, the number of thermals available on this module
336
+ An integer, the number of thermals available on this module
343
337
"""
344
338
return len (self ._thermal_list )
345
339
346
340
def get_all_thermals (self ):
347
341
"""
348
- Retrieves all thermals available on this module
342
+ Retrieves all thermals available on this module
349
343
350
344
Returns:
351
345
A list of objects derived from ThermalBase representing all thermals
352
- available on this module
346
+ available on this module
353
347
"""
354
348
return self ._thermal_list
355
349
@@ -380,20 +374,20 @@ def get_thermal(self, index):
380
374
381
375
def get_num_sfps (self ):
382
376
"""
383
- Retrieves the number of sfps available on this module
377
+ Retrieves the number of sfps available on this module
384
378
385
379
Returns:
386
- An integer, the number of sfps available on this module
380
+ An integer, the number of sfps available on this module
387
381
"""
388
382
return len (self ._sfp_list )
389
383
390
384
def get_all_sfps (self ):
391
385
"""
392
- Retrieves all sfps available on this module
386
+ Retrieves all sfps available on this module
393
387
394
388
Returns:
395
- A list of objects derived from PsuBase representing all sfps
396
- available on this module
389
+ A list of objects derived from PsuBase representing all sfps
390
+ available on this module
397
391
"""
398
392
return self ._sfp_list
399
393
@@ -431,7 +425,7 @@ def get_change_event(self, timeout=0):
431
425
- True if call successful, False if not;
432
426
- A nested dictionary where key is a device type,
433
427
value is a dictionary with key:value pairs in the format of
434
- {'device_id':'device_event'},
428
+ {'device_id':'device_event'},
435
429
where device_id is the device ID for this device and
436
430
device_event,
437
431
status='1' represents device inserted,
0 commit comments