Skip to content

Commit

Permalink
Align method names according to PEP8.
Browse files Browse the repository at this point in the history
Signed-off-by: Nazarii Hnydyn <nazariig@mellanox.com>
  • Loading branch information
nazariig committed Mar 26, 2019
1 parent bbbc878 commit a1c18a6
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/sonic_ax_impl/mibs/vendor/cisco/ciscoEntityFruControlMIB.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self):
self.statedb = SonicV2Connector()
self.statedb.connect(self.statedb.STATE_DB)

def _getPsuNum(self):
def _get_psu_num(self):
"""
Get PSU number
:return: the number of supported PSU
Expand All @@ -66,7 +66,7 @@ def _getPsuNum(self):

return int(psu_num[0])

def _getPsuPresence(self, psu_index):
def _get_psu_presence(self, psu_index):
"""
Get PSU presence
:return: the presence of particular PSU
Expand All @@ -77,7 +77,7 @@ def _getPsuPresence(self, psu_index):

return presence == PSU_PRESENCE_OK

def _getPsuStatus(self, psu_index):
def _get_psu_status(self, psu_index):
"""
Get PSU status
:return: the status of particular PSU
Expand All @@ -88,7 +88,7 @@ def _getPsuStatus(self, psu_index):

return status == PSU_STATUS_OK

def _getPsuIndex(self, sub_id):
def _get_psu_index(self, sub_id):
"""
Get the PSU index from sub_id
:return: the index of supported PSU
Expand All @@ -99,10 +99,10 @@ def _getPsuIndex(self, sub_id):
psu_index = int(sub_id[0])

try:
psu_num = self._getPsuNum()
psu_num = self._get_psu_num()
except Exception:
# Any unexpected exception or error, log it and keep running
mibs.logger.exception("PowerStatusHandler._getPsuIndex() caught an unexpected exception during _getPsuNum()")
mibs.logger.exception("PowerStatusHandler._get_psu_index() caught an unexpected exception during _get_psu_num()")
return None

if psu_index < 1 or psu_index > psu_num:
Expand All @@ -118,20 +118,20 @@ def get_next(self, sub_id):
if not sub_id:
return (1,)

psu_index = self._getPsuIndex(sub_id)
psu_index = self._get_psu_index(sub_id)
try:
psu_num = self._getPsuNum()
psu_num = self._get_psu_num()
except Exception:
# Any unexpected exception or error, log it and keep running
mibs.logger.exception("PowerStatusHandler.get_next() caught an unexpected exception during _getPsuNum()")
mibs.logger.exception("PowerStatusHandler.get_next() caught an unexpected exception during _get_psu_num()")
return None

if psu_index and psu_index + 1 <= psu_num:
return (psu_index + 1,)

return None

def getPsuStatus(self, sub_id):
def get_psu_status(self, sub_id):
"""
:param sub_id: The 1-based sub-identifier query.
:return: the status of requested PSU according to cefcModuleOperStatus ModuleOperType
Expand All @@ -140,24 +140,24 @@ def getPsuStatus(self, sub_id):
8 - the module is provisioned, but it is missing. This is a failure state.
:ref: https://www.cisco.com/c/en/us/td/docs/switches/wan/mgx/mgx_8850/software/mgx_r2-0-10/pxm/reference/guide/pxm/cscoent.html
"""
psu_index = self._getPsuIndex(sub_id)
psu_index = self._get_psu_index(sub_id)

if not psu_index:
return None

try:
psu_presence = self._getPsuPresence(psu_index)
psu_presence = self._get_psu_presence(psu_index)
except Exception:
# Any unexpected exception or error, log it and keep running
mibs.logger.exception("PowerStatusHandler.getPsuStatus() caught an unexpected exception during _getPsuPresence()")
mibs.logger.exception("PowerStatusHandler.get_psu_status() caught an unexpected exception during _get_psu_presence()")
return None

if psu_presence:
try:
psu_status = self._getPsuStatus(psu_index)
psu_status = self._get_psu_status(psu_index)
except Exception:
# Any unexpected exception or error, log it and keep running
mibs.logger.exception("PowerStatusHandler.getPsuStatus() caught an unexpected exception during _getPsuStatus()")
mibs.logger.exception("PowerStatusHandler.get_psu_status() caught an unexpected exception during _get_psu_status()")
return None

if psu_status:
Expand All @@ -177,4 +177,4 @@ class cefcFruPowerStatusTable(metaclass=MIBMeta, prefix='.1.3.6.1.4.1.9.9.117.1.
# cefcFruPowerStatusTable = '1.3.6.1.4.1.9.9.117.1.1.2'
# csqIfQosGroupStatsEntry = '1.3.6.1.4.1.9.9.117.1.1.2.1'

psu_status = SubtreeMIBEntry('1.2', power_status_handler, ValueType.INTEGER, power_status_handler.getPsuStatus)
psu_status = SubtreeMIBEntry('1.2', power_status_handler, ValueType.INTEGER, power_status_handler.get_psu_status)

0 comments on commit a1c18a6

Please sign in to comment.