-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AS9726-32D] support system-health check
Signed-off-by: Sean Wu <sean_wu@edge-core.com>
- Loading branch information
Showing
12 changed files
with
556 additions
and
60 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
device/accton/x86_64-accton_as9726_32d-r0/sonic_platform/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
__all__ = ['chassis', 'eeprom', 'platform', 'psu', 'sfp', 'thermal', 'fan'] | ||
__all__ = [ "platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer" ] | ||
from . import platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
device/accton/x86_64-accton_as9726_32d-r0/sonic_platform/event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
try: | ||
import time | ||
from .helper import APIHelper | ||
from sonic_py_common.logger import Logger | ||
except ImportError as e: | ||
raise ImportError(repr(e) + " - required module not found") | ||
|
||
|
||
class SfpEvent: | ||
''' Listen to insert/remove sfp events ''' | ||
|
||
def __init__(self, sfp_list): | ||
self._api_helper = APIHelper() | ||
self._sfp_list = sfp_list | ||
self._logger = Logger() | ||
|
||
sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0} | ||
def get_sfp_event(self, timeout=2000): | ||
now = time.time() | ||
port_dict = {} | ||
change_dict = {} | ||
change_dict['sfp'] = port_dict | ||
|
||
if timeout < 1000: | ||
timeout = 1000 | ||
timeout = timeout / float(1000) # Convert to secs | ||
|
||
if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']: | ||
return True, change_dict | ||
|
||
bitmap = 0 | ||
for sfp in self._sfp_list: | ||
modpres = sfp.get_presence() | ||
i=sfp.port_num-1 | ||
if modpres: | ||
bitmap = bitmap | (1 << i) | ||
|
||
changed_ports = self.sfp_change_event_data['present'] ^ bitmap | ||
if changed_ports: | ||
for sfp in self._sfp_list: | ||
i=sfp.port_num-1 | ||
if (changed_ports & (1 << i)): | ||
if (bitmap & (1 << i)) == 0: | ||
port_dict[i+1] = '0' | ||
else: | ||
port_dict[i+1] = '1' | ||
|
||
|
||
# Update the cache dict | ||
self.sfp_change_event_data['present'] = bitmap | ||
self.sfp_change_event_data['last'] = now | ||
self.sfp_change_event_data['valid'] = 1 | ||
return True, change_dict | ||
else: | ||
return True, change_dict |
Oops, something went wrong.