Skip to content

Commit

Permalink
[DellEMC] Ensure concrete platform API classes call base class initia…
Browse files Browse the repository at this point in the history
…lizer (#6853)

In preparation for the merging of sonic-net/sonic-platform-common#173, which properly defines class and instance members in the Platform API base classes.

It is proper object-oriented methodology to call the base class initializer, even if it is only the default initializer. This also future-proofs the potential addition of custom initializers in the base classes down the road.
  • Loading branch information
jleveque authored Feb 25, 2021
1 parent 516ff8b commit ac15a42
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Component(ComponentBase):
]

def __init__(self, component_index = 0):
ComponentBase.__init__(self)
self.index = component_index
self.name = self.CHASSIS_COMPONENTS[self.index][0]
self.description = self.CHASSIS_COMPONENTS[self.index][1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Fan(FanBase):

def __init__(self, fantray_index=1, fan_index=1, psu_fan=False,
dependency=None):
FanBase.__init__(self)
self.is_psu_fan = psu_fan
if not self.is_psu_fan:
# API index is starting from 0, DellEMC platform index is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Watchdog(WatchdogBase):
CLOCK_MONOTONIC = 1

def __init__(self):
WatchdogBase.__init__(self)
self._librt = ctypes.CDLL('librt.so.1', use_errno=True)
self._clock_gettime = self._librt.clock_gettime
self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Component(ComponentBase):
]

def __init__(self, component_index):
ComponentBase.__init__(self)
self.index = component_index
self.name = self.CHASSIS_COMPONENTS[self.index][0]
self.description = self.CHASSIS_COMPONENTS[self.index][1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Fan(FanBase):

def __init__(self, fantray_index=1, fan_index=1,
psu_index=1, psu_fan=False, dependency=None):
FanBase.__init__(self)
self.is_psu_fan = psu_fan
self.is_driver_initialized = True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Thermal(ThermalBase):

def __init__(self, thermal_index,
psu_index=1, psu_thermal=False, dependency=None):
ThermalBase.__init__(self)
self.is_psu_thermal = psu_thermal
self.dependency = dependency
self.is_driver_initialized = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Component(ComponentBase):
def __init__(self, component_index=0,
is_module=False, iom_index=0, i2c_line=0, dependency=None):

ComponentBase.__init__(self)
self.is_module_component = is_module
self.dependency = dependency

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Fan(FanBase):
MAILBOX_DIR = HWMON_DIR + HWMON_NODE

def __init__(self, fantray_index=1, psu_index=1, psu_fan=False, dependency=None):
FanBase.__init__(self)
self.is_psu_fan = psu_fan
if not self.is_psu_fan:
self.fantrayindex = fantray_index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Thermal(ThermalBase):
)

def __init__(self, thermal_index):
ThermalBase.__init__(self)
self.is_cpu_thermal = False
self.index = thermal_index + 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Watchdog(WatchdogBase):
CLOCK_MONOTONIC = 1

def __init__(self):
WatchdogBase.__init__(self)
self._librt = ctypes.CDLL('librt.so.1', use_errno=True)
self._clock_gettime = self._librt.clock_gettime
self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Component(ComponentBase):
]

def __init__(self, component_index=0):
ComponentBase.__init__(self)
self.index = component_index
self.name = self.CHASSIS_COMPONENTS[self.index][0]
self.description = self.CHASSIS_COMPONENTS[self.index][1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Fan(FanBase):
MAILBOX_DIR = HWMON_DIR + HWMON_NODE

def __init__(self, fantray_index=1, fan_index=1, psu_fan=False):
FanBase.__init__(self)
self.is_psu_fan = psu_fan
if not self.is_psu_fan:
# API index is starting from 0, DellEMC platform index is starting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Psu(PsuBase):
MAILBOX_DIR = HWMON_DIR + HWMON_NODE

def __init__(self, psu_index):
PsuBase.__init__(self)
# PSU is 1-based in DellEMC platforms
self.index = psu_index + 1
self.psu_presence_reg = "psu{}_presence".format(self.index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Thermal(ThermalBase):
)

def __init__(self, thermal_index):
ThermalBase.__init__(self)
self.is_cpu_thermal = False
self.index = thermal_index + 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Component(ComponentBase):
]

def __init__(self, component_index=0):
ComponentBase.__init__(self)
self.index = component_index
self.name = self.CHASSIS_COMPONENTS[self.index][0]
self.description = self.CHASSIS_COMPONENTS[self.index][1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Fan(FanBase):

def __init__(self, fantray_index=1, fan_index=1, psu_fan=False,
dependency=None):
FanBase.__init__(self)
self.is_psu_fan = psu_fan
if not self.is_psu_fan:
# API index is starting from 0, DellEMC platform index is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Watchdog(WatchdogBase):
CLOCK_MONOTONIC = 1

def __init__(self):
WatchdogBase.__init__(self)
self._librt = ctypes.CDLL('librt.so.1', use_errno=True)
self._clock_gettime = self._librt.clock_gettime
self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Component(ComponentBase):
]

def __init__(self, component_index = 0):
ComponentBase.__init__(self)
self.index = component_index
self.name = self.CHASSIS_COMPONENTS[self.index][0]
self.description = self.CHASSIS_COMPONENTS[self.index][1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Fan(FanBase):
PSU_FRU_MAPPING = { 1: 3, 2: 4 }

def __init__(self, fantray_index=1, fan_index=1, psu_fan=False, dependency=None):
FanBase.__init__(self)
self.is_psu_fan = psu_fan
if not self.is_psu_fan:
# API index is starting from 0, DellEMC platform index is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Watchdog(WatchdogBase):
CLOCK_MONOTONIC = 1

def __init__(self):
WatchdogBase.__init__(self)
self._librt = ctypes.CDLL('librt.so.1', use_errno=True)
self._clock_gettime = self._librt.clock_gettime
self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)]
Expand Down

0 comments on commit ac15a42

Please sign in to comment.