Skip to content

Commit

Permalink
[sonic_platform_base] Reallocate empty lists in the constructor of th…
Browse files Browse the repository at this point in the history
…e base class (sonic-net#65)

Signed-off-by: Dante (Kuo-Jung) Su <[email protected]>
  • Loading branch information
ds952811 authored and jleveque committed Nov 13, 2019
1 parent bea68f4 commit 9bae794
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
20 changes: 14 additions & 6 deletions sonic_platform_base/chassis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,42 @@ class ChassisBase(device_base.DeviceBase):

# List of ComponentBase-derived objects representing all components
# available on the chassis
_component_list = []
_component_list = None

# List of ModuleBase-derived objects representing all modules
# available on the chassis (for use with modular chassis)
_module_list = []
_module_list = None

# List of FanBase-derived objects representing all fans
# available on the chassis
_fan_list = []
_fan_list = None

# List of PsuBase-derived objects representing all power supply units
# available on the chassis
_psu_list = []
_psu_list = None

# List of ThermalBase-derived objects representing all thermals
# available on the chassis
_thermal_list = []
_thermal_list = None

# List of SfpBase-derived objects representing all sfps
# available on the chassis
_sfp_list = []
_sfp_list = None

# Object derived from WatchdogBase for interacting with hardware watchdog
_watchdog = None

# Object derived from eeprom_tlvinfo.TlvInfoDecoder indicating the eeprom on the chassis
_eeprom = None

def __init__(self):
self._component_list = []
self._module_list = []
self._fan_list = []
self._psu_list = []
self._thermal_list = []
self._sfp_list = []

def get_base_mac(self):
"""
Retrieves the base MAC address for the chassis
Expand Down
17 changes: 12 additions & 5 deletions sonic_platform_base/module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,30 @@ class ModuleBase(device_base.DeviceBase):

# List of ComponentBase-derived objects representing all components
# available on the module
_component_list = []
_component_list = None

# List of FanBase-derived objects representing all fans
# available on the module
_fan_list = []
_fan_list = None

# List of PsuBase-derived objects representing all power supply units
# available on the module
_psu_list = []
_psu_list = None

# List of ThermalBase-derived objects representing all thermals
# available on the module
_thermal_list = []
_thermal_list = None

# List of SfpBase-derived objects representing all sfps
# available on the module
_sfp_list = []
_sfp_list = None

def __init__(self):
self._component_list = []
self._fan_list = []
self._psu_list = []
self._thermal_list = []
self._sfp_list = []

def get_base_mac(self):
"""
Expand Down
5 changes: 4 additions & 1 deletion sonic_platform_base/psu_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class PsuBase(device_base.DeviceBase):

# List of FanBase-derived objects representing all fans
# available on the PSU
_fan_list = []
_fan_list = None

def __init__(self):
self._fan_list = []

def get_num_fans(self):
"""
Expand Down

0 comments on commit 9bae794

Please sign in to comment.