Skip to content

Commit

Permalink
updates for alerts from LGTM
Browse files Browse the repository at this point in the history
  • Loading branch information
srideepDell committed May 14, 2020
1 parent f980a7f commit c490eca
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "thermal", "psu", "fan","watchdog","hwaccess"]
from sonic_platform import *

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
try:
import os
import sys
import select
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
from sonic_platform.eeprom import Eeprom
Expand All @@ -35,8 +34,6 @@ class Chassis(ChassisBase):
DELLEMC Platform-specific Chassis class
"""

OIR_FD_PATH = "/sys/bus/pci/devices/0000:04:00.0/port_msi"

oir_fd = -1
epoll = -1

Expand Down Expand Up @@ -82,42 +79,6 @@ def __del__(self):
self.epoll.close()
self.oir_fd.close()

# not needed /delete after validation

def _get_register(self, reg_file):
retval = 'ERR'
if (not os.path.isfile(reg_file)):
print reg_file, 'not found !'
return retval

try:
with os.fdopen(os.open(reg_file, os.O_RDONLY)) as fd:
retval = fd.read()
except:
pass
retval = retval.rstrip('\r\n')
retval = retval.lstrip(" ")
return retval

# not needed /delete after validation

def _check_interrupts(self, port_dict):
retval = 0
is_port_dict_updated = False
for port_num in range(self.PORT_START, (self.PORT_END + 1)):
# sfp get uses zero-indexing, but port numbers start from 1
sfp = self.get_sfp(port_num)
presence = sfp.get_presence()
if(presence and (self._global_port_pres_dict[port_num] == '0')):
is_port_dict_updated = True
self._global_port_pres_dict[port_num] = '1'
port_dict[port_num] = '1'
elif(not presence and (self._global_port_pres_dict[port_num] == '1')):
is_port_dict_updated = True
self._global_port_pres_dict[port_num] = '0'
port_dict[port_num] = '0'
return retval, is_port_dict_updated

# check for this event change for sfp / do we need to handle timeout/sleep

def get_change_event(self, timeout=0):
Expand All @@ -129,6 +90,10 @@ def get_change_event(self, timeout=0):
port_dict = {}
change_dict = {}
change_dict['sfp'] = port_dict
elapsed_time_ms = 0
sleep_time_ms = 500
sleep_time = sleep_time_ms / 1000

while True:
for port_num in range(self.PORT_START, (self.PORT_END + 1)):
presence = self.get_sfp(port_num).get_presence()
Expand All @@ -142,10 +107,13 @@ def get_change_event(self, timeout=0):

if(len(port_dict) > 0):
return True, change_dict
if timeout != 0:
elapsed_time_ms += sleep_time_ms
if elapsed_time_ms > timeout:
break

sleep(0.5)


time.sleep(sleep_time)
return True, change_dict

def get_sfp(self, index):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
########################################################################

try:
import os
import re
import subprocess
from sonic_platform_base.component_base import ComponentBase
import sonic_platform.hwaccess as hwaccess
Expand Down Expand Up @@ -62,7 +60,7 @@ class Component(ComponentBase):
],

['BMC',
'Platform management controller for on-board temperature '
'Platform management controller for on-board temperature ',
'monitoring, in-chassis power, Fan and LED control',
get_bmc_version
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import os
import time
import struct
import sys
import getopt
import select
import mmap
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform_base.sfp_base import SfpBase
Expand Down Expand Up @@ -970,15 +967,15 @@ def reset(self):
reg_value = reg_value & ~mask

# Convert our register value back to a hex string and write back
status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)
self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)

# Sleep 1 second to allow it to settle
time.sleep(1)

reg_value = reg_value | mask

# Convert our register value back to a hex string and write back
status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)
self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)

return True

Expand Down Expand Up @@ -1010,7 +1007,7 @@ def set_lpmode(self, lpmode):
reg_value = reg_value & ~mask

# Convert our register value back to a hex string and write back
status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)
self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)

return True

Expand All @@ -1029,12 +1026,6 @@ def tx_disable_channel(self, channel, disable):
"""
return False

def tx_disable_channel(self, channel, disable):
"""
Sets the tx_disable for specified SFP channels
"""
return False

def set_power_override(self, power_override, power_set):
"""
Sets SFP power level using power_override and power_set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

try:
from sonic_platform_base.thermal_base import ThermalBase
from sonic_platform.ipmihelper import IpmiSensor, IpmiFru
from sonic_platform.ipmihelper import IpmiSensor
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
########################################################################

try:
import sys
import struct
import ctypes
import subprocess
from sonic_platform_base.watchdog_base import WatchdogBase
Expand Down Expand Up @@ -139,8 +137,6 @@ def arm(self, seconds):
self.timeout = seconds
return seconds

return -1

def disarm(self):
"""
Disarm the hardware watchdog
Expand Down

0 comments on commit c490eca

Please sign in to comment.