[barefoot][device] Drop platform API 1.0 (#7716)
#### Why I did it To get rid of obsolete code #### How I did it Removed plugins folder from device/barefoot Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>
This commit is contained in:
parent
1b33ebc9cd
commit
3edb4f1ebe
@ -1 +0,0 @@
|
|||||||
../x86_64-accton_wedge100bf_32x-r0/plugins/
|
|
@ -1,184 +0,0 @@
|
|||||||
try:
|
|
||||||
import importlib
|
|
||||||
import time
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
import errno
|
|
||||||
import datetime
|
|
||||||
import logging
|
|
||||||
import logging.config
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
|
||||||
import pltfm_mgr_rpc
|
|
||||||
from pltfm_mgr_rpc.ttypes import *
|
|
||||||
|
|
||||||
from thrift.transport import TSocket
|
|
||||||
from thrift.transport import TTransport
|
|
||||||
from thrift.protocol import TBinaryProtocol
|
|
||||||
from thrift.protocol import TMultiplexedProtocol
|
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
|
||||||
|
|
||||||
if sys.version_info.major == 3:
|
|
||||||
from io import StringIO
|
|
||||||
else:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
|
|
||||||
from sonic_eeprom import eeprom_base
|
|
||||||
from sonic_eeprom import eeprom_tlvinfo
|
|
||||||
except ImportError as e:
|
|
||||||
raise ImportError(str(e) + "- required module not found")
|
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info.major == 3:
|
|
||||||
STRING_TYPE = str
|
|
||||||
else:
|
|
||||||
STRING_TYPE = basestring
|
|
||||||
|
|
||||||
|
|
||||||
eeprom_default_dict = {
|
|
||||||
"prod_name": ("Product Name", "0x21", 12),
|
|
||||||
"odm_pcba_part_num": ("Part Number", "0x22", 13),
|
|
||||||
"prod_ser_num": ("Serial Number", "0x23", 12),
|
|
||||||
"ext_mac_addr": ("Extended MAC Address Base", "0x24", 12),
|
|
||||||
"sys_mfg_date": ("System Manufacturing Date", "0x25", 4),
|
|
||||||
"prod_ver": ("Product Version", "0x26", 1),
|
|
||||||
"ext_mac_addr_size": ("Extende MAC Address Size", "0x2A", 2),
|
|
||||||
"sys_mfger": ("Manufacturer", "0x2B", 8)
|
|
||||||
}
|
|
||||||
|
|
||||||
eeprom_dict = {"version": ("Version", None, 0),
|
|
||||||
"pcb_mfger": ("PCB Manufacturer", "0x01", 8),
|
|
||||||
"prod_ser_num": ("Serial Number", "0x23", 12),
|
|
||||||
"bfn_pcba_part_num": ("Switch PCBA Part Number", "0x02", 12),
|
|
||||||
"odm_pcba_part_num": ("Part Number", "0x22", 13),
|
|
||||||
"bfn_pcbb_part_num": ("Switch PCBB Part Number", "0x04", 12),
|
|
||||||
"sys_asm_part_num": ("System Assembly Part Number", "0x05", 12),
|
|
||||||
"prod_state": ("Product Production State", "0x06", 1),
|
|
||||||
"location": ("EEPROM Location of Fabric", "0x07", 8),
|
|
||||||
"ext_mac_addr_size": ("Extende MAC Address Size", "0x08", 2),
|
|
||||||
"sys_mfg_date": ("System Manufacturing Date", "0x25", 4),
|
|
||||||
"prod_name": ("Product Name", "0x21", 12),
|
|
||||||
"prod_ver": ("Product Version", "0x26", 1),
|
|
||||||
"prod_part_num": ("Product Part Number", "0x09", 8),
|
|
||||||
"sys_mfger": ("Manufacturer", "0x2B", 8),
|
|
||||||
"assembled_at": ("Assembled at", "0x08", 8),
|
|
||||||
"prod_ast_tag": ("Product Asset Tag", "0x09", 12),
|
|
||||||
"loc_mac_addr": ("Local MAC address", "0x0A", 12),
|
|
||||||
"odm_pcba_ser_num": ("ODM PBCA Serial Number", "0x0B", 12),
|
|
||||||
"ext_mac_addr": ("Extended MAC Address Base", "0x0C", 12),
|
|
||||||
"prod_sub_ver": ("Product Sub Version", "0x0D", 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
product_dict = {"Montara": "Wedge100BF-32X-O-AC-F-BF",
|
|
||||||
"Lower MAV": "Wedge100BF-65X-O-AC-F-BF",
|
|
||||||
"Upper MAV": "Wedge100BF-65X-O-AC-F-BF"
|
|
||||||
}
|
|
||||||
|
|
||||||
thrift_server = 'localhost'
|
|
||||||
transport = None
|
|
||||||
pltfm_mgr = None
|
|
||||||
|
|
||||||
EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom"
|
|
||||||
EEPROM_STATUS = "/var/run/platform/eeprom/status"
|
|
||||||
|
|
||||||
|
|
||||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|
||||||
RETRIES = 35
|
|
||||||
|
|
||||||
def __init__(self, name, path, cpld_root, ro):
|
|
||||||
|
|
||||||
with open(os.path.dirname(__file__) + "/logging.conf", 'r') as f:
|
|
||||||
config_dict = yaml.load(f, yaml.SafeLoader)
|
|
||||||
logging.config.dictConfig(config_dict)
|
|
||||||
|
|
||||||
if not os.path.exists(os.path.dirname(EEPROM_SYMLINK)):
|
|
||||||
try:
|
|
||||||
os.makedirs(os.path.dirname(EEPROM_SYMLINK))
|
|
||||||
except OSError as e:
|
|
||||||
if e.errno != errno.EEXIST:
|
|
||||||
raise
|
|
||||||
|
|
||||||
open(EEPROM_SYMLINK, 'a').close()
|
|
||||||
f = open(EEPROM_STATUS, 'w')
|
|
||||||
f.write("initializing..")
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
self.eeprom_path = EEPROM_SYMLINK
|
|
||||||
super(board, self).__init__(self.eeprom_path, 0, EEPROM_STATUS, True)
|
|
||||||
|
|
||||||
for attempt in range(self.RETRIES):
|
|
||||||
if self.eeprom_init():
|
|
||||||
break
|
|
||||||
if attempt + 1 == self.RETRIES:
|
|
||||||
raise RuntimeError("eeprom.py: Initialization failed")
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
def thrift_setup(self):
|
|
||||||
global thrift_server, transport, pltfm_mgr
|
|
||||||
transport = TSocket.TSocket(thrift_server, 9090)
|
|
||||||
|
|
||||||
transport = TTransport.TBufferedTransport(transport)
|
|
||||||
bprotocol = TBinaryProtocol.TBinaryProtocol(transport)
|
|
||||||
|
|
||||||
pltfm_mgr_client_module = importlib.import_module(
|
|
||||||
".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"]))
|
|
||||||
pltfm_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(
|
|
||||||
bprotocol, "pltfm_mgr_rpc")
|
|
||||||
pltfm_mgr = pltfm_mgr_client_module.Client(pltfm_mgr_protocol)
|
|
||||||
|
|
||||||
transport.open()
|
|
||||||
|
|
||||||
def thrift_teardown(self):
|
|
||||||
global transport
|
|
||||||
transport.close()
|
|
||||||
|
|
||||||
def eeprom_init(self):
|
|
||||||
global pltfm_mgr
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.thrift_setup()
|
|
||||||
eeprom = pltfm_mgr.pltfm_mgr_sys_eeprom_get()
|
|
||||||
self.thrift_teardown()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
f = open(EEPROM_STATUS, 'w')
|
|
||||||
f.write("ok")
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
eeprom_params = ""
|
|
||||||
for attr, val in eeprom.__dict__.items():
|
|
||||||
if val is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
elem = eeprom_default_dict.get(attr)
|
|
||||||
if elem is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if isinstance(val, STRING_TYPE):
|
|
||||||
value = val.replace('\0', '')
|
|
||||||
else:
|
|
||||||
value = str(val)
|
|
||||||
|
|
||||||
if attr == "sys_mfg_date":
|
|
||||||
value = datetime.datetime.strptime(
|
|
||||||
value, '%m-%d-%y').strftime('%m/%d/%Y 00:00:00')
|
|
||||||
|
|
||||||
product = product_dict.get(value)
|
|
||||||
if product is not None:
|
|
||||||
value = product
|
|
||||||
if len(eeprom_params) > 0:
|
|
||||||
eeprom_params += ","
|
|
||||||
eeprom_params += "{0:s}={1:s}".format(elem[1], value)
|
|
||||||
|
|
||||||
orig_stdout = sys.stdout
|
|
||||||
sys.stdout = StringIO()
|
|
||||||
new_e = eeprom_tlvinfo.TlvInfoDecoder.set_eeprom(
|
|
||||||
self, "", [eeprom_params])
|
|
||||||
sys.stdout = orig_stdout
|
|
||||||
eeprom_base.EepromDecoder.write_eeprom(self, new_e)
|
|
||||||
|
|
||||||
return True
|
|
@ -1,17 +0,0 @@
|
|||||||
version: 1
|
|
||||||
disable_existing_loggers: False
|
|
||||||
|
|
||||||
formatters:
|
|
||||||
simple:
|
|
||||||
format: '%(asctime)s %(name)-30s %(levelname)-7s %(message)s'
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
file:
|
|
||||||
class: logging.handlers.RotatingFileHandler
|
|
||||||
formatter: simple
|
|
||||||
filename: /var/log/platform.log
|
|
||||||
|
|
||||||
root:
|
|
||||||
level: ERROR
|
|
||||||
handlers:
|
|
||||||
- file
|
|
@ -1 +0,0 @@
|
|||||||
__all__ = ['ttypes', 'pltfm_mgr_rpc']
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,96 +0,0 @@
|
|||||||
try:
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import importlib
|
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
|
||||||
import pltfm_mgr_rpc
|
|
||||||
from pltfm_mgr_rpc.ttypes import *
|
|
||||||
|
|
||||||
from thrift.transport import TSocket
|
|
||||||
from thrift.transport import TTransport
|
|
||||||
from thrift.protocol import TBinaryProtocol
|
|
||||||
from thrift.protocol import TMultiplexedProtocol
|
|
||||||
|
|
||||||
from sonic_psu.psu_base import PsuBase
|
|
||||||
except ImportError as e:
|
|
||||||
raise ImportError(str(e) + "- required module not found")
|
|
||||||
|
|
||||||
thrift_server = 'localhost'
|
|
||||||
transport = None
|
|
||||||
pltfm_mgr = None
|
|
||||||
|
|
||||||
|
|
||||||
class PsuUtil(PsuBase):
|
|
||||||
"""Platform-specific PSUutil class"""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
PsuBase.__init__(self)
|
|
||||||
|
|
||||||
def thrift_setup(self):
|
|
||||||
global thrift_server, transport, pltfm_mgr
|
|
||||||
transport = TSocket.TSocket(thrift_server, 9090)
|
|
||||||
|
|
||||||
transport = TTransport.TBufferedTransport(transport)
|
|
||||||
bprotocol = TBinaryProtocol.TBinaryProtocol(transport)
|
|
||||||
|
|
||||||
pltfm_mgr_client_module = importlib.import_module(
|
|
||||||
".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"]))
|
|
||||||
pltfm_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(
|
|
||||||
bprotocol, "pltfm_mgr_rpc")
|
|
||||||
pltfm_mgr = pltfm_mgr_client_module.Client(pltfm_mgr_protocol)
|
|
||||||
|
|
||||||
transport.open()
|
|
||||||
|
|
||||||
def thrift_teardown(self):
|
|
||||||
global transport
|
|
||||||
transport.close()
|
|
||||||
|
|
||||||
def get_num_psus(self):
|
|
||||||
"""
|
|
||||||
Retrieves the number of PSUs available on the device
|
|
||||||
:return: An integer, the number of PSUs available on the device
|
|
||||||
"""
|
|
||||||
return 2
|
|
||||||
|
|
||||||
def get_psu_status(self, index):
|
|
||||||
"""
|
|
||||||
Retrieves the oprational status of power supply unit (PSU) defined
|
|
||||||
by 1-based index <index>
|
|
||||||
:param index: An integer, 1-based index of the PSU of which to query status
|
|
||||||
:return: Boolean, True if PSU is operating properly, False if PSU is faulty
|
|
||||||
"""
|
|
||||||
if index is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
global pltfm_mgr
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.thrift_setup()
|
|
||||||
psu_info = pltfm_mgr.pltfm_mgr_pwr_supply_info_get(index)
|
|
||||||
self.thrift_teardown()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return (psu_info.ffault == False)
|
|
||||||
|
|
||||||
def get_psu_presence(self, index):
|
|
||||||
"""
|
|
||||||
Retrieves the presence status of power supply unit (PSU) defined
|
|
||||||
by 1-based index <index>
|
|
||||||
:param index: An integer, 1-based index of the PSU of which to query status
|
|
||||||
:return: Boolean, True if PSU is plugged, False if not
|
|
||||||
"""
|
|
||||||
if index is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
global pltfm_mgr
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.thrift_setup()
|
|
||||||
status = pltfm_mgr.pltfm_mgr_pwr_supply_present_get(index)
|
|
||||||
self.thrift_teardown()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return status
|
|
@ -1,250 +0,0 @@
|
|||||||
try:
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import importlib
|
|
||||||
import time
|
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
|
||||||
import pltfm_mgr_rpc
|
|
||||||
from pltfm_mgr_rpc.ttypes import *
|
|
||||||
|
|
||||||
from thrift.transport import TSocket
|
|
||||||
from thrift.transport import TTransport
|
|
||||||
from thrift.protocol import TBinaryProtocol
|
|
||||||
from thrift.protocol import TMultiplexedProtocol
|
|
||||||
|
|
||||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
|
||||||
except ImportError as e:
|
|
||||||
raise ImportError(str(e) + "- required module not found")
|
|
||||||
|
|
||||||
thrift_server = 'localhost'
|
|
||||||
transport = None
|
|
||||||
pltfm_mgr = None
|
|
||||||
|
|
||||||
SFP_EEPROM_CACHE = "/var/run/platform/sfp/cache"
|
|
||||||
|
|
||||||
|
|
||||||
class SfpUtil(SfpUtilBase):
|
|
||||||
"""Platform-specific SfpUtil class"""
|
|
||||||
|
|
||||||
PORT_START = 1
|
|
||||||
PORT_END = 0
|
|
||||||
PORTS_IN_BLOCK = 0
|
|
||||||
QSFP_PORT_START = 1
|
|
||||||
QSFP_PORT_END = 0
|
|
||||||
EEPROM_OFFSET = 0
|
|
||||||
QSFP_CHECK_INTERVAL = 4
|
|
||||||
THRIFT_RETRIES = 5
|
|
||||||
THRIFT_TIMEOUT = 5
|
|
||||||
|
|
||||||
@property
|
|
||||||
def port_start(self):
|
|
||||||
self.update_port_info()
|
|
||||||
return self.PORT_START
|
|
||||||
|
|
||||||
@property
|
|
||||||
def port_end(self):
|
|
||||||
self.update_port_info()
|
|
||||||
return self.PORT_END
|
|
||||||
|
|
||||||
@property
|
|
||||||
def qsfp_ports(self):
|
|
||||||
self.update_port_info()
|
|
||||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def port_to_eeprom_mapping(self):
|
|
||||||
print("dependency on sysfs has been removed")
|
|
||||||
raise Exception()
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.ready = False
|
|
||||||
self.phy_port_dict = {'-1': 'system_not_ready'}
|
|
||||||
self.phy_port_cur_state = {}
|
|
||||||
self.qsfp_interval = self.QSFP_CHECK_INTERVAL
|
|
||||||
|
|
||||||
if not os.path.exists(os.path.dirname(SFP_EEPROM_CACHE)):
|
|
||||||
try:
|
|
||||||
os.makedirs(os.path.dirname(SFP_EEPROM_CACHE))
|
|
||||||
except OSError as e:
|
|
||||||
if e.errno != errno.EEXIST:
|
|
||||||
raise
|
|
||||||
|
|
||||||
open(SFP_EEPROM_CACHE, 'ab').close()
|
|
||||||
|
|
||||||
SfpUtilBase.__init__(self)
|
|
||||||
|
|
||||||
def update_port_info(self):
|
|
||||||
global pltfm_mgr
|
|
||||||
|
|
||||||
if self.QSFP_PORT_END == 0:
|
|
||||||
self.thrift_setup()
|
|
||||||
self.QSFP_PORT_END = pltfm_mgr.pltfm_mgr_qsfp_get_max_port()
|
|
||||||
self.PORT_END = self.QSFP_PORT_END
|
|
||||||
self.PORTS_IN_BLOCK = self.QSFP_PORT_END
|
|
||||||
self.thrift_teardown()
|
|
||||||
|
|
||||||
def thrift_setup(self):
|
|
||||||
global thrift_server, transport, pltfm_mgr
|
|
||||||
transport = TSocket.TSocket(thrift_server, 9090)
|
|
||||||
|
|
||||||
transport = TTransport.TBufferedTransport(transport)
|
|
||||||
bprotocol = TBinaryProtocol.TBinaryProtocol(transport)
|
|
||||||
|
|
||||||
pltfm_mgr_client_module = importlib.import_module(".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"]))
|
|
||||||
pltfm_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(bprotocol, "pltfm_mgr_rpc")
|
|
||||||
pltfm_mgr = pltfm_mgr_client_module.Client(pltfm_mgr_protocol)
|
|
||||||
|
|
||||||
for i in range(self.THRIFT_RETRIES):
|
|
||||||
try:
|
|
||||||
transport.open()
|
|
||||||
if i:
|
|
||||||
# The main thrift server is starded without platform api
|
|
||||||
# Platform api is added later during syncd initialization
|
|
||||||
# So we need to wait a little bit before do any platform api call
|
|
||||||
# Just in case when can't connect from the first try (warm-reboot case)
|
|
||||||
time.sleep(self.THRIFT_TIMEOUT)
|
|
||||||
break
|
|
||||||
except TTransport.TTransportException as e:
|
|
||||||
if e.type != TTransport.TTransportException.NOT_OPEN or i >= self.THRIFT_RETRIES - 1:
|
|
||||||
raise e
|
|
||||||
time.sleep(self.THRIFT_TIMEOUT)
|
|
||||||
|
|
||||||
def thrift_teardown(self):
|
|
||||||
global transport
|
|
||||||
transport.close()
|
|
||||||
|
|
||||||
def get_presence(self, port_num):
|
|
||||||
# Check for invalid port_num
|
|
||||||
if port_num < self.port_start or port_num > self.port_end:
|
|
||||||
return False
|
|
||||||
|
|
||||||
presence = False
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.thrift_setup()
|
|
||||||
presence = pltfm_mgr.pltfm_mgr_qsfp_presence_get(port_num)
|
|
||||||
self.thrift_teardown()
|
|
||||||
except Exception as e:
|
|
||||||
print(e.__doc__)
|
|
||||||
print(e.message)
|
|
||||||
|
|
||||||
return presence
|
|
||||||
|
|
||||||
def get_low_power_mode(self, port_num):
|
|
||||||
# Check for invalid port_num
|
|
||||||
if port_num < self.port_start or port_num > self.port_end:
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.thrift_setup()
|
|
||||||
lpmode = pltfm_mgr.pltfm_mgr_qsfp_lpmode_get(port_num)
|
|
||||||
self.thrift_teardown()
|
|
||||||
return lpmode
|
|
||||||
|
|
||||||
def set_low_power_mode(self, port_num, lpmode):
|
|
||||||
# Check for invalid port_num
|
|
||||||
if port_num < self.port_start or port_num > self.port_end:
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.thrift_setup()
|
|
||||||
status = pltfm_mgr.pltfm_mgr_qsfp_lpmode_set(port_num, lpmode)
|
|
||||||
self.thrift_teardown()
|
|
||||||
return (status == 0)
|
|
||||||
|
|
||||||
def reset(self, port_num):
|
|
||||||
# Check for invalid port_num
|
|
||||||
if port_num < self.port_start or port_num > self.port_end:
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.thrift_setup()
|
|
||||||
status = pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, True)
|
|
||||||
status = pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, False)
|
|
||||||
self.thrift_teardown()
|
|
||||||
return (status == 0)
|
|
||||||
|
|
||||||
def check_transceiver_change(self):
|
|
||||||
if not self.ready:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.phy_port_dict = {}
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.thrift_setup()
|
|
||||||
except:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Get presence of each SFP
|
|
||||||
for port in range(self.port_start, self.port_end + 1):
|
|
||||||
try:
|
|
||||||
sfp_resent = pltfm_mgr.pltfm_mgr_qsfp_presence_get(port)
|
|
||||||
except:
|
|
||||||
sfp_resent = False
|
|
||||||
sfp_state = '1' if sfp_resent else '0'
|
|
||||||
|
|
||||||
if port in self.phy_port_cur_state:
|
|
||||||
if self.phy_port_cur_state[port] != sfp_state:
|
|
||||||
self.phy_port_dict[port] = sfp_state
|
|
||||||
else:
|
|
||||||
self.phy_port_dict[port] = sfp_state
|
|
||||||
|
|
||||||
# Update port current state
|
|
||||||
self.phy_port_cur_state[port] = sfp_state
|
|
||||||
|
|
||||||
self.thrift_teardown()
|
|
||||||
|
|
||||||
def get_transceiver_change_event(self, timeout=0):
|
|
||||||
forever = False
|
|
||||||
if timeout == 0:
|
|
||||||
forever = True
|
|
||||||
elif timeout > 0:
|
|
||||||
timeout = timeout / float(1000) # Convert to secs
|
|
||||||
else:
|
|
||||||
print("get_transceiver_change_event:Invalid timeout value", timeout)
|
|
||||||
return False, {}
|
|
||||||
|
|
||||||
while forever or timeout > 0:
|
|
||||||
if not self.ready:
|
|
||||||
try:
|
|
||||||
self.thrift_setup()
|
|
||||||
self.thrift_teardown()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
self.ready = True
|
|
||||||
self.phy_port_dict = {}
|
|
||||||
break
|
|
||||||
elif self.qsfp_interval == 0:
|
|
||||||
self.qsfp_interval = self.QSFP_CHECK_INTERVAL
|
|
||||||
|
|
||||||
# Process transceiver plug-in/out event
|
|
||||||
self.check_transceiver_change()
|
|
||||||
|
|
||||||
# Break if tranceiver state has changed
|
|
||||||
if bool(self.phy_port_dict):
|
|
||||||
break
|
|
||||||
|
|
||||||
if timeout:
|
|
||||||
timeout -= 1
|
|
||||||
|
|
||||||
if self.qsfp_interval:
|
|
||||||
self.qsfp_interval -= 1
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
return self.ready, self.phy_port_dict
|
|
||||||
|
|
||||||
def _get_port_eeprom_path(self, port_num, devid):
|
|
||||||
eeprom_path = None
|
|
||||||
|
|
||||||
self.thrift_setup()
|
|
||||||
presence = pltfm_mgr.pltfm_mgr_qsfp_presence_get(port_num)
|
|
||||||
if presence == True:
|
|
||||||
eeprom_cache = open(SFP_EEPROM_CACHE, 'wb')
|
|
||||||
eeprom_hex = pltfm_mgr.pltfm_mgr_qsfp_info_get(port_num)
|
|
||||||
eeprom_raw = bytearray.fromhex(eeprom_hex)
|
|
||||||
eeprom_cache.write(eeprom_raw)
|
|
||||||
eeprom_cache.close()
|
|
||||||
eeprom_path = SFP_EEPROM_CACHE
|
|
||||||
self.thrift_teardown()
|
|
||||||
|
|
||||||
return eeprom_path
|
|
@ -1 +0,0 @@
|
|||||||
../x86_64-accton_wedge100bf_32x-r0/plugins/
|
|
Reference in New Issue
Block a user