[sonic-utilities] Update submodule; Build and install as a Python 3 wheel (#5926)
Submodule updates include the following commits: * src/sonic-utilities 9dc58ea...f9eb739 (18): > Remove unnecessary calls to str.encode() now that the package is Python 3; Fix deprecation warning (#1260) > [generate_dump] Ignoring file/directory not found Errors (#1201) > Fixed porstat rate and util issues (#1140) > fix error: interface counters is mismatch after warm-reboot (#1099) > Remove unnecessary calls to str.decode() now that the package is Python 3 (#1255) > [acl-loader] Make list sorting compliant with Python 3 (#1257) > Replace hard-coded fast-reboot with variable. And some typo corrections (#1254) > [configlet][portconfig] Remove calls to dict.has_key() which is not available in Python 3 (#1247) > Remove unnecessary conversions to list() and calls to dict.keys() (#1243) > Clean up LGTM alerts (#1239) > Add 'requests' as install dependency in setup.py (#1240) > Convert to Python 3 (#1128) > Fix mock SonicV2Connector in python3: use decode_responses mode so caller code will be the same as python2 (#1238) > [tests] Do not trim from PATH if we did not append to it; Clean up/fix shebangs in scripts (#1233) > Updates to bgp config and show commands with BGP_INTERNAL_NEIGHBOR table (#1224) > [cli]: NAT show commands newline issue after migrated to Python3 (#1204) > [doc]: Update Command-Reference.md (#1231) > Added 'import sys' in feature.py file (#1232) * src/sonic-py-swsssdk 9d9f0c6...1664be9 (2): > Fix: no need to decode() after redis client scan, so it will work for both python2 and python3 (#96) > FieldValueMap `contains`(`in`) will also work when migrated to libswsscommon(C++ with SWIG wrapper) (#94) - Also fix Python 3-related issues: - Use integer (floor) division in config_samples.py (sonic-config-engine) - Replace print statement with print function in eeprom.py plugin for x86_64-kvm_x86_64-r0 platform - Update all platform plugins to be compatible with both Python 2 and Python 3 - Remove shebangs from plugins files which are not intended to be executable - Replace tabs with spaces in Python plugin files and fix alignment, because Python 3 is more strict - Remove trailing whitespace from plugins files
This commit is contained in:
Родитель
fad481edc1
Коммит
7f4ab8fbd8
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,11 +8,13 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -15,6 +15,7 @@ except ImportError as e:
|
|||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
|
@ -49,7 +50,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -70,13 +71,13 @@ class SfpUtil(SfpUtilBase):
|
|||
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
||||
self.__port_to_is_present = present_path
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(self.__port_to_is_present)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -108,7 +109,7 @@ class SfpUtil(SfpUtilBase):
|
|||
return False
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -138,7 +139,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -156,18 +157,19 @@ class SfpUtil(SfpUtilBase):
|
|||
bits.append(str(int(self.get_presence(x))))
|
||||
|
||||
rev = "".join(bits[::-1])
|
||||
return int(rev,2)
|
||||
return int(rev, 2)
|
||||
|
||||
data = {'present': 0}
|
||||
|
||||
data = {'present':0}
|
||||
def get_transceiver_change_event(self, timeout=0):
|
||||
port_dict = {}
|
||||
|
||||
if timeout == 0:
|
||||
cd_ms = sys.maxint
|
||||
cd_ms = sys.maxsize
|
||||
else:
|
||||
cd_ms = timeout
|
||||
|
||||
#poll per second
|
||||
# poll per second
|
||||
while cd_ms > 0:
|
||||
reg_value = self._get_presence_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
|
@ -177,7 +179,7 @@ class SfpUtil(SfpUtilBase):
|
|||
cd_ms = cd_ms - 1000
|
||||
|
||||
if changed_ports != 0:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - self.port_start))
|
||||
if changed_ports & mask:
|
||||
|
@ -192,4 +194,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -12,7 +12,7 @@ except ImportError as e:
|
|||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
@ -32,7 +32,7 @@ class SfpUtil(SfpUtilBase):
|
|||
BASE_CPLD3_PATH = "/sys/bus/i2c/devices/{0}-0062/"
|
||||
I2C_BUS_ORDER = -1
|
||||
|
||||
#The sidebands of QSFP is different.
|
||||
# The sidebands of QSFP is different.
|
||||
qsfp_sb_map = [0, 2, 4, 1, 3, 5]
|
||||
|
||||
_port_to_is_present = {}
|
||||
|
@ -88,12 +88,12 @@ class SfpUtil(SfpUtilBase):
|
|||
46: [46, 47],
|
||||
47: [47, 48],
|
||||
48: [48, 49],
|
||||
49: [49, 50],#QSFP49
|
||||
49: [49, 50], # QSFP49
|
||||
50: [51, 52],
|
||||
51: [53, 54],
|
||||
52: [50, 51],
|
||||
53: [52, 53],
|
||||
54: [54, 55],#QSFP54
|
||||
54: [54, 55], # QSFP54
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -114,13 +114,13 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
return self._port_to_eeprom_mapping
|
||||
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
def update_i2c_order(self):
|
||||
if self.I2C_BUS_ORDER < 0:
|
||||
eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
|
@ -144,13 +144,13 @@ class SfpUtil(SfpUtilBase):
|
|||
present_path = present_path + "module_present_" + str(port_num)
|
||||
self.__port_to_is_present = present_path
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(self.__port_to_is_present)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -174,13 +174,13 @@ class SfpUtil(SfpUtilBase):
|
|||
q = self.qsfp_sb_remap(port_num)
|
||||
lp_mode_path = lp_mode_path + str(q)
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(lp_mode_path)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -210,7 +210,7 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return False # High Power Mode if "Power set" bit is 0
|
||||
except IOError as err:
|
||||
print "Error: unable to open file: %s" % str(err)
|
||||
print("Error: unable to open file: %s" % str(err))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -238,7 +238,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as err:
|
||||
print "Error: unable to open file: %s" % str(err)
|
||||
print("Error: unable to open file: %s" % str(err))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -257,10 +257,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(mod_rst_path, 'r+', buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('0')
|
||||
time.sleep(1)
|
||||
|
@ -285,17 +285,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -305,14 +305,13 @@ class SfpUtil(SfpUtilBase):
|
|||
timeout = 1000
|
||||
timeout = (timeout) / float(1000) # Convert to secs
|
||||
|
||||
|
||||
if now < (self.data['last'] + timeout) and self.data['valid']:
|
||||
return True, {}
|
||||
|
||||
reg_value = self._get_presence_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
fp_port = self._port_to_i2c_mapping[port][0]
|
||||
mask = (1 << (fp_port - 1))
|
||||
|
@ -333,7 +332,6 @@ class SfpUtil(SfpUtilBase):
|
|||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
||||
def __init__(self):
|
||||
eeprom_path = self.BASE_OOM_PATH + "eeprom"
|
||||
|
||||
|
@ -343,7 +341,3 @@ class SfpUtil(SfpUtilBase):
|
|||
)
|
||||
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -10,7 +10,7 @@ try:
|
|||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
@ -29,9 +29,9 @@ class SfpUtil(SfpUtilBase):
|
|||
BASE_CPLD_PATH = "/sys/bus/i2c/devices/{0}-0060/"
|
||||
I2C_BUS_ORDER = -1
|
||||
|
||||
#The sidebands of QSFP is different.
|
||||
#present is in-order.
|
||||
#But lp_mode and reset are not.
|
||||
# The sidebands of QSFP is different.
|
||||
# present is in-order.
|
||||
# But lp_mode and reset are not.
|
||||
qsfp_sb_map = [0, 2, 4, 1, 3, 5]
|
||||
|
||||
_port_to_is_present = {}
|
||||
|
@ -39,12 +39,12 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
_port_to_eeprom_mapping = {}
|
||||
_port_to_i2c_mapping = {
|
||||
49: [1,4],#QSFP_start
|
||||
50: [2,6],
|
||||
51: [3,3],
|
||||
52: [4,5],
|
||||
53: [5,7],
|
||||
54: [6,2],
|
||||
49: [1, 4], # QSFP_start
|
||||
50: [2, 6],
|
||||
51: [3, 3],
|
||||
52: [4, 5],
|
||||
53: [5, 7],
|
||||
54: [6, 2],
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -65,7 +65,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -80,7 +80,7 @@ class SfpUtil(SfpUtilBase):
|
|||
)
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
def update_i2c_order(self):
|
||||
if self.I2C_BUS_ORDER < 0:
|
||||
eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
|
@ -101,13 +101,13 @@ class SfpUtil(SfpUtilBase):
|
|||
present_path = present_path + "module_present_" + str(port_num)
|
||||
self.__port_to_is_present = present_path
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(self.__port_to_is_present)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -124,13 +124,13 @@ class SfpUtil(SfpUtilBase):
|
|||
lp_mode_path = lp_mode_path + "module_lp_mode_"
|
||||
lp_mode_path = lp_mode_path + str(port_num)
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(lp_mode_path)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -159,7 +159,7 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return False # High Power Mode if "Power set" bit is 0
|
||||
except IOError as err:
|
||||
print "Error: unable to open file: %s" % str(err)
|
||||
print("Error: unable to open file: %s" % str(err))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -187,7 +187,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as err:
|
||||
print "Error: unable to open file: %s" % str(err)
|
||||
print("Error: unable to open file: %s" % str(err))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -207,10 +207,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(mod_rst_path, 'r+', buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
time.sleep(1)
|
||||
|
@ -233,27 +233,27 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'present': 0}
|
||||
|
||||
data = {'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
port_dict = {}
|
||||
port = 0
|
||||
|
||||
if timeout == 0:
|
||||
cd_ms = sys.maxint
|
||||
cd_ms = sys.maxsize
|
||||
else:
|
||||
cd_ms = timeout
|
||||
|
||||
#poll per second
|
||||
# poll per second
|
||||
while cd_ms > 0:
|
||||
reg_value = self._get_presence_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
|
@ -263,7 +263,7 @@ class SfpUtil(SfpUtilBase):
|
|||
cd_ms = cd_ms - 1000
|
||||
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
fp_port = self._port_to_i2c_mapping[port][0]
|
||||
mask = (1 << (fp_port - 1))
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -10,7 +10,7 @@ try:
|
|||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
@ -30,9 +30,9 @@ class SfpUtil(SfpUtilBase):
|
|||
BASE_CPLD3_PATH = "/sys/bus/i2c/devices/{0}-0062/"
|
||||
I2C_BUS_ORDER = -1
|
||||
|
||||
#The sidebands of QSFP is different.
|
||||
#present is in-order.
|
||||
#But lp_mode and reset are not.
|
||||
# The sidebands of QSFP is different.
|
||||
# present is in-order.
|
||||
# But lp_mode and reset are not.
|
||||
qsfp_sb_map = [0, 2, 4, 1, 3, 5]
|
||||
|
||||
_port_to_is_present = {}
|
||||
|
@ -49,51 +49,51 @@ class SfpUtil(SfpUtilBase):
|
|||
7: [7, 8],
|
||||
8: [8, 9],
|
||||
9: [9, 10],
|
||||
10: [10,11],
|
||||
11: [11,12],
|
||||
12: [12,13],
|
||||
13: [13,14],
|
||||
14: [14,15],
|
||||
15: [15,16],
|
||||
16: [16,17],
|
||||
17: [17,18],
|
||||
18: [18,19],
|
||||
19: [19,20],
|
||||
20: [20,21],
|
||||
21: [21,22],
|
||||
22: [22,23],
|
||||
23: [23,24],
|
||||
24: [24,25],
|
||||
25: [25,26],
|
||||
26: [26,27],
|
||||
27: [27,28],
|
||||
28: [28,29],
|
||||
29: [29,30],
|
||||
30: [30,31],
|
||||
31: [31,32],
|
||||
32: [32,33],
|
||||
33: [33,34],
|
||||
34: [34,35],
|
||||
35: [35,36],
|
||||
36: [36,37],
|
||||
37: [37,38],
|
||||
38: [38,39],
|
||||
39: [39,40],
|
||||
40: [40,41],
|
||||
41: [41,42],
|
||||
42: [42,43],
|
||||
43: [43,44],
|
||||
44: [44,45],
|
||||
45: [45,46],
|
||||
46: [46,47],
|
||||
47: [47,48],
|
||||
48: [48,49],
|
||||
49: [49,50],#QSFP_start
|
||||
50: [51,52],
|
||||
51: [53,54],
|
||||
52: [50,51],
|
||||
53: [52,53],
|
||||
54: [54,55],
|
||||
10: [10, 11],
|
||||
11: [11, 12],
|
||||
12: [12, 13],
|
||||
13: [13, 14],
|
||||
14: [14, 15],
|
||||
15: [15, 16],
|
||||
16: [16, 17],
|
||||
17: [17, 18],
|
||||
18: [18, 19],
|
||||
19: [19, 20],
|
||||
20: [20, 21],
|
||||
21: [21, 22],
|
||||
22: [22, 23],
|
||||
23: [23, 24],
|
||||
24: [24, 25],
|
||||
25: [25, 26],
|
||||
26: [26, 27],
|
||||
27: [27, 28],
|
||||
28: [28, 29],
|
||||
29: [29, 30],
|
||||
30: [30, 31],
|
||||
31: [31, 32],
|
||||
32: [32, 33],
|
||||
33: [33, 34],
|
||||
34: [34, 35],
|
||||
35: [35, 36],
|
||||
36: [36, 37],
|
||||
37: [37, 38],
|
||||
38: [38, 39],
|
||||
39: [39, 40],
|
||||
40: [40, 41],
|
||||
41: [41, 42],
|
||||
42: [42, 43],
|
||||
43: [43, 44],
|
||||
44: [44, 45],
|
||||
45: [45, 46],
|
||||
46: [46, 47],
|
||||
47: [47, 48],
|
||||
48: [48, 49],
|
||||
49: [49, 50], # QSFP_start
|
||||
50: [51, 52],
|
||||
51: [53, 54],
|
||||
52: [50, 51],
|
||||
53: [52, 53],
|
||||
54: [54, 55],
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -114,7 +114,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -129,7 +129,7 @@ class SfpUtil(SfpUtilBase):
|
|||
)
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
def update_i2c_order(self):
|
||||
if self.I2C_BUS_ORDER < 0:
|
||||
eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
|
@ -154,13 +154,13 @@ class SfpUtil(SfpUtilBase):
|
|||
present_path = present_path + "module_present_" + str(port_num)
|
||||
self.__port_to_is_present = present_path
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(self.__port_to_is_present)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -190,7 +190,7 @@ class SfpUtil(SfpUtilBase):
|
|||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -220,7 +220,7 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return False # High Power Mode if "Power set" bit is 0
|
||||
except IOError as err:
|
||||
print "Error: unable to open file: %s" % str(err)
|
||||
print("Error: unable to open file: %s" % str(err))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -248,7 +248,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as err:
|
||||
print "Error: unable to open file: %s" % str(err)
|
||||
print("Error: unable to open file: %s" % str(err))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -268,10 +268,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(mod_rst_path, 'r+', buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('0')
|
||||
time.sleep(1)
|
||||
|
@ -296,17 +296,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -316,14 +316,13 @@ class SfpUtil(SfpUtilBase):
|
|||
timeout = 1000
|
||||
timeout = (timeout) / float(1000) # Convert to secs
|
||||
|
||||
|
||||
if now < (self.data['last'] + timeout) and self.data['valid']:
|
||||
return True, {}
|
||||
|
||||
reg_value = self._get_presence_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
fp_port = self._port_to_i2c_mapping[port][0]
|
||||
mask = (1 << (fp_port - 1))
|
||||
|
@ -343,4 +342,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -14,6 +14,7 @@ except ImportError as e:
|
|||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
|
@ -23,27 +24,27 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
_port_to_eeprom_mapping = {}
|
||||
_port_to_i2c_mapping = {
|
||||
49: 28, #QSFP49
|
||||
49: 28, # QSFP49
|
||||
50: 28,
|
||||
51: 28,
|
||||
52: 28,
|
||||
53: 29, #QSFP50
|
||||
53: 29, # QSFP50
|
||||
54: 29,
|
||||
55: 29,
|
||||
56: 29,
|
||||
57: 26, #QSFP51
|
||||
57: 26, # QSFP51
|
||||
58: 26,
|
||||
59: 26,
|
||||
60: 26,
|
||||
61: 30, #QSFP52
|
||||
61: 30, # QSFP52
|
||||
62: 30,
|
||||
63: 30,
|
||||
64: 30,
|
||||
65: 31, #QSFP53
|
||||
65: 31, # QSFP53
|
||||
66: 31,
|
||||
67: 31,
|
||||
68: 31,
|
||||
69: 27, #QSFP54
|
||||
69: 27, # QSFP54
|
||||
70: 27,
|
||||
71: 27,
|
||||
72: 27,
|
||||
|
@ -67,7 +68,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -81,8 +82,8 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
|
||||
# For port 49~54 are QSFP, here presumed they're all split to 4 lanes.
|
||||
|
||||
def get_cage_num(self, port_num):
|
||||
cage_num = port_num
|
||||
if (port_num >= self.PORT_START):
|
||||
|
@ -100,13 +101,13 @@ class SfpUtil(SfpUtilBase):
|
|||
path = "/sys/bus/i2c/devices/3-0062/module_present_{0}"
|
||||
port_ps = path.format(cage_num)
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(port_ps)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -125,7 +126,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
val_file = open(lp_mode_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
|
@ -158,7 +159,7 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return False # High Power Mode if "Power set" bit is 0
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -186,7 +187,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -203,10 +204,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, mode="w", buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('0')
|
||||
time.sleep(1)
|
||||
|
@ -223,7 +224,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open("/sys/bus/i2c/devices/3-0062/module_present_all")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
@ -235,19 +236,20 @@ class SfpUtil(SfpUtilBase):
|
|||
tmp = rev.pop()
|
||||
|
||||
# Insert port 1-48
|
||||
for i in range (0, 6):
|
||||
for i in range(0, 6):
|
||||
rev.append(hex(0)[2:])
|
||||
rev[i] = rev[i].zfill(2)
|
||||
|
||||
# Expand port 49-54
|
||||
for i in range (0, 6):
|
||||
val = (int(tmp,16) >> i) & 0x1
|
||||
for i in range(0, 6):
|
||||
val = (int(tmp, 16) >> i) & 0x1
|
||||
rev.append(hex(val)[2:])
|
||||
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=0):
|
||||
|
||||
start_time = time.time()
|
||||
|
@ -260,13 +262,13 @@ class SfpUtil(SfpUtilBase):
|
|||
elif timeout > 0:
|
||||
timeout = timeout / float(1000) # Convert to secs
|
||||
else:
|
||||
print "get_transceiver_change_event:Invalid timeout value", timeout
|
||||
print("get_transceiver_change_event:Invalid timeout value", timeout)
|
||||
return False, {}
|
||||
|
||||
end_time = start_time + timeout
|
||||
if start_time > end_time:
|
||||
print 'get_transceiver_change_event:' \
|
||||
'time wrap / invalid timeout value', timeout
|
||||
print('get_transceiver_change_event:'
|
||||
'time wrap / invalid timeout value', timeout)
|
||||
|
||||
return False, {} # Time wrap or possibly incorrect timeout
|
||||
|
||||
|
@ -276,7 +278,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = self._get_presence_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - 1))
|
||||
if changed_ports & mask:
|
||||
|
@ -301,5 +303,5 @@ class SfpUtil(SfpUtilBase):
|
|||
if timeout > 0:
|
||||
time.sleep(timeout)
|
||||
return True, {}
|
||||
print "get_transceiver_change_event: Should not reach here."
|
||||
print("get_transceiver_change_event: Should not reach here.")
|
||||
return False, {}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -14,6 +14,7 @@ except ImportError as e:
|
|||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
|
@ -83,27 +84,27 @@ class SfpUtil(SfpUtilBase):
|
|||
46: 87,
|
||||
47: 88,
|
||||
48: 89,
|
||||
49: 28, #QSFP49
|
||||
49: 28, # QSFP49
|
||||
50: 28,
|
||||
51: 28,
|
||||
52: 28,
|
||||
53: 29, #QSFP50
|
||||
53: 29, # QSFP50
|
||||
54: 29,
|
||||
55: 29,
|
||||
56: 29,
|
||||
57: 26, #QSFP51
|
||||
57: 26, # QSFP51
|
||||
58: 26,
|
||||
59: 26,
|
||||
60: 26,
|
||||
61: 30, #QSFP52
|
||||
61: 30, # QSFP52
|
||||
62: 30,
|
||||
63: 30,
|
||||
64: 30,
|
||||
65: 31, #QSFP53
|
||||
65: 31, # QSFP53
|
||||
66: 31,
|
||||
67: 31,
|
||||
68: 31,
|
||||
69: 27, #QSFP54
|
||||
69: 27, # QSFP54
|
||||
70: 27,
|
||||
71: 27,
|
||||
72: 27,
|
||||
|
@ -127,7 +128,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -141,8 +142,8 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
|
||||
# For port 49~54 are QSFP, here presumed they're all split to 4 lanes.
|
||||
|
||||
def get_cage_num(self, port_num):
|
||||
cage_num = port_num
|
||||
if (port_num >= self.QSFP_PORT_START):
|
||||
|
@ -173,7 +174,7 @@ class SfpUtil(SfpUtilBase):
|
|||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -195,7 +196,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
val_file = open(lp_mode_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
|
@ -228,7 +229,7 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return False # High Power Mode if "Power set" bit is 0
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -256,7 +257,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -275,10 +276,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, mode='w', buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('0')
|
||||
time.sleep(1)
|
||||
|
@ -300,7 +301,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
@ -309,22 +310,23 @@ class SfpUtil(SfpUtilBase):
|
|||
rev.pop() # Remove the last useless character
|
||||
|
||||
# Convert bitmap into continuously port order
|
||||
rev[4] = hex((int(rev[4],16) | ((int(rev[5],16) & 0x3) << 6)))[2:] # Port 33-40
|
||||
rev[5] = hex((int(rev[5],16) >> 2) | ((int(rev[6],16) & 0x3) << 6))[2:] # Port 41-48
|
||||
rev[4] = hex((int(rev[4], 16) | ((int(rev[5], 16) & 0x3) << 6)))[2:] # Port 33-40
|
||||
rev[5] = hex((int(rev[5], 16) >> 2) | ((int(rev[6], 16) & 0x3) << 6))[2:] # Port 41-48
|
||||
|
||||
# Expand port 49-54
|
||||
tmp = rev.pop()
|
||||
for i in range (2, 8):
|
||||
val = (int(tmp,16) >> i) & 0x1
|
||||
for i in range(2, 8):
|
||||
val = (int(tmp, 16) >> i) & 0x1
|
||||
rev.append(hex(val)[2:])
|
||||
|
||||
for i in range (0,6):
|
||||
for i in range(0, 6):
|
||||
rev[i] = rev[i].zfill(2)
|
||||
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=0):
|
||||
|
||||
start_time = time.time()
|
||||
|
@ -337,13 +339,13 @@ class SfpUtil(SfpUtilBase):
|
|||
elif timeout > 0:
|
||||
timeout = timeout / float(1000) # Convert to secs
|
||||
else:
|
||||
print "get_transceiver_change_event:Invalid timeout value", timeout
|
||||
print("get_transceiver_change_event:Invalid timeout value", timeout)
|
||||
return False, {}
|
||||
|
||||
end_time = start_time + timeout
|
||||
if start_time > end_time:
|
||||
print 'get_transceiver_change_event:' \
|
||||
'time wrap / invalid timeout value', timeout
|
||||
print('get_transceiver_change_event:'
|
||||
'time wrap / invalid timeout value', timeout)
|
||||
|
||||
return False, {} # Time wrap or possibly incorrect timeout
|
||||
|
||||
|
@ -353,7 +355,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = self._get_presence_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - 1))
|
||||
if changed_ports & mask:
|
||||
|
@ -378,7 +380,5 @@ class SfpUtil(SfpUtilBase):
|
|||
if timeout > 0:
|
||||
time.sleep(timeout)
|
||||
return True, {}
|
||||
print "get_transceiver_change_event: Should not reach here."
|
||||
print("get_transceiver_change_event: Should not reach here.")
|
||||
return False, {}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -10,15 +7,16 @@ try:
|
|||
import sys
|
||||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -12,7 +12,7 @@ try:
|
|||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
@ -88,7 +88,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -109,7 +109,7 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
cpld_num = 1
|
||||
|
||||
#cpld can be at either bus 0 or bus 1.
|
||||
# cpld can be at either bus 0 or bus 1.
|
||||
cpld_path = self.I2C_DEV_PATH + str(0) + self.CPLD_ADDRESS[cpld_num]
|
||||
if not os.path.exists(cpld_path):
|
||||
cpld_path = self.I2C_DEV_PATH + str(1) + self.CPLD_ADDRESS[cpld_num]
|
||||
|
@ -120,20 +120,19 @@ class SfpUtil(SfpUtilBase):
|
|||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
|
||||
cpld_path = self.get_cpld_dev_path(port_num)
|
||||
present_path = cpld_path + "/module_present_"
|
||||
present_path += str(self._port_to_i2c_mapping[port_num][0])
|
||||
|
||||
self.__port_to_is_present = present_path
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(self.__port_to_is_present)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -149,13 +148,13 @@ class SfpUtil(SfpUtilBase):
|
|||
_path = cpld_path + "/module_lp_mode_"
|
||||
_path += str(self._port_to_i2c_mapping[port_num][0])
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
reg_file = open(_path)
|
||||
content = reg_file.readline().rstrip()
|
||||
reg_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -185,7 +184,7 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return False # High Power Mode if "Power set" bit is 0
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -213,7 +212,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -231,7 +230,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(_path, 'w')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
reg_file.seek(0)
|
||||
|
@ -258,17 +257,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -278,14 +277,13 @@ class SfpUtil(SfpUtilBase):
|
|||
timeout = 1000
|
||||
timeout = (timeout) / float(1000) # Convert to secs
|
||||
|
||||
|
||||
if now < (self.data['last'] + timeout) and self.data['valid']:
|
||||
return True, {}
|
||||
|
||||
reg_value = self.get_transceiver_status
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
fp_port = self._port_to_i2c_mapping[port][0]
|
||||
mask = (1 << (fp_port - 1))
|
||||
|
@ -305,5 +303,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,11 +8,13 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -21,8 +21,8 @@ class PsuUtil(PsuBase):
|
|||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
|
||||
# Get sysfs attribute
|
||||
|
||||
def get_attr_value(self, attr_path):
|
||||
|
||||
retval = 'ERR'
|
||||
|
@ -56,7 +56,7 @@ class PsuUtil(PsuBase):
|
|||
"""
|
||||
status = 0
|
||||
attr_file = 'psu_power_good'
|
||||
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file
|
||||
attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file
|
||||
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
|
||||
|
@ -77,8 +77,8 @@ class PsuUtil(PsuBase):
|
|||
"""
|
||||
status = 0
|
||||
psu_absent = 0
|
||||
attr_file ='psu_present'
|
||||
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file
|
||||
attr_file = 'psu_present'
|
||||
attr_path = self.SYSFS_PSU_DIR[index-1] + '/' + attr_file
|
||||
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
|
||||
|
@ -89,4 +89,3 @@ class PsuUtil(PsuBase):
|
|||
status = 1
|
||||
|
||||
return status
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform specific SfpUtill class"""
|
||||
|
||||
|
@ -19,63 +18,63 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
_port_to_eeprom_mapping = {}
|
||||
_port_to_i2c_mapping = {
|
||||
0 : 37,
|
||||
1 : 38,
|
||||
2 : 39,
|
||||
3 : 40,
|
||||
4 : 41,
|
||||
5 : 42,
|
||||
6 : 43,
|
||||
7 : 44,
|
||||
8 : 45,
|
||||
9 : 46,
|
||||
10 : 47,
|
||||
11 : 48,
|
||||
12 : 49,
|
||||
13 : 50,
|
||||
14 : 51,
|
||||
15 : 52,
|
||||
16 : 53,
|
||||
17 : 54,
|
||||
18 : 55,
|
||||
19 : 56,
|
||||
20 : 57,
|
||||
21 : 58,
|
||||
22 : 59,
|
||||
23 : 60,
|
||||
24 : 61,
|
||||
25 : 62,
|
||||
26 : 63,
|
||||
27 : 64,
|
||||
28 : 65,
|
||||
29 : 66,
|
||||
30 : 67,
|
||||
31 : 68,
|
||||
32 : 69,
|
||||
33 : 70,
|
||||
34 : 71,
|
||||
35 : 72,
|
||||
36 : 73,
|
||||
37 : 74,
|
||||
38 : 75,
|
||||
39 : 76,
|
||||
40 : 77,
|
||||
41 : 78,
|
||||
42 : 79,
|
||||
43 : 80,
|
||||
44 : 81,
|
||||
45 : 82,
|
||||
46 : 83,
|
||||
47 : 84,
|
||||
48 : 21,
|
||||
49 : 22,
|
||||
50 : 23,
|
||||
51 : 24,
|
||||
52 : 25,
|
||||
53 : 26,
|
||||
0: 37,
|
||||
1: 38,
|
||||
2: 39,
|
||||
3: 40,
|
||||
4: 41,
|
||||
5: 42,
|
||||
6: 43,
|
||||
7: 44,
|
||||
8: 45,
|
||||
9: 46,
|
||||
10: 47,
|
||||
11: 48,
|
||||
12: 49,
|
||||
13: 50,
|
||||
14: 51,
|
||||
15: 52,
|
||||
16: 53,
|
||||
17: 54,
|
||||
18: 55,
|
||||
19: 56,
|
||||
20: 57,
|
||||
21: 58,
|
||||
22: 59,
|
||||
23: 60,
|
||||
24: 61,
|
||||
25: 62,
|
||||
26: 63,
|
||||
27: 64,
|
||||
28: 65,
|
||||
29: 66,
|
||||
30: 67,
|
||||
31: 68,
|
||||
32: 69,
|
||||
33: 70,
|
||||
34: 71,
|
||||
35: 72,
|
||||
36: 73,
|
||||
37: 74,
|
||||
38: 75,
|
||||
39: 76,
|
||||
40: 77,
|
||||
41: 78,
|
||||
42: 79,
|
||||
43: 80,
|
||||
44: 81,
|
||||
45: 82,
|
||||
46: 83,
|
||||
47: 84,
|
||||
48: 21,
|
||||
49: 22,
|
||||
50: 23,
|
||||
51: 24,
|
||||
52: 25,
|
||||
53: 26,
|
||||
}
|
||||
|
||||
_qsfp_ports = range(_qsfp_port_start, _ports_in_block + 1)
|
||||
_qsfp_ports = list(range(_qsfp_port_start, _ports_in_block + 1))
|
||||
|
||||
_present_status = dict()
|
||||
|
||||
|
@ -91,7 +90,7 @@ class SfpUtil(SfpUtilBase):
|
|||
def reset(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self._qsfp_port_start or port_num > self._port_end:
|
||||
print "Error: port %d is not qsfp port" % port_num
|
||||
print("Error: port %d is not qsfp port" % port_num)
|
||||
return False
|
||||
|
||||
path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset"
|
||||
|
@ -100,10 +99,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, 'w')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
time.sleep(1)
|
||||
|
@ -132,7 +131,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = reg_file.readline().rstrip()
|
||||
reg_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if reg_value == '1':
|
||||
|
@ -170,4 +169,3 @@ class SfpUtil(SfpUtilBase):
|
|||
time.sleep(2)
|
||||
|
||||
return True, ret_present
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Module contains an implementation of SONiC Platform Base API and
|
||||
|
@ -32,7 +30,7 @@ NUM_SFP = 54
|
|||
SFP_PORT_START = 0
|
||||
QSFP_PORT_START = 48
|
||||
SFP_PORT_END = 47
|
||||
QSFP_PORT_END=53
|
||||
QSFP_PORT_END = 53
|
||||
HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/"
|
||||
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/"
|
||||
REBOOT_CAUSE_FILE = "reboot-cause.txt"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Component contains an implementation of SONiC Platform Base API and
|
||||
# provides the components firmware management function
|
||||
|
@ -18,6 +16,7 @@ except ImportError as e:
|
|||
|
||||
BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version"
|
||||
|
||||
|
||||
class Component(DeviceBase):
|
||||
"""Platform-specific Component class"""
|
||||
|
||||
|
@ -31,7 +30,7 @@ class Component(DeviceBase):
|
|||
# Run bash command and print output to stdout
|
||||
try:
|
||||
process = subprocess.Popen(
|
||||
shlex.split(command), stdout=subprocess.PIPE)
|
||||
shlex.split(command), universal_newlines=True, stdout=subprocess.PIPE)
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
if output == '' and process.poll() is not None:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Platform and model specific eeprom subclass, inherits from the base class,
|
||||
# and provides the followings:
|
||||
|
@ -11,10 +9,14 @@ try:
|
|||
import glob
|
||||
import os
|
||||
import sys
|
||||
import imp
|
||||
import re
|
||||
from array import array
|
||||
|
||||
if sys.version_info.major == 3:
|
||||
from io import StringIO
|
||||
else:
|
||||
from cStringIO import StringIO
|
||||
|
||||
from sonic_platform_base.sonic_eeprom import eeprom_dts
|
||||
from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo
|
||||
except ImportError as e:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Module contains an implementation of SONiC Platform Base API and
|
||||
|
@ -21,6 +19,7 @@ FANTRAY_NAME_LIST = ["FANTRAY-1", "FANTRAY-2",
|
|||
"FANTRAY-3", "FANTRAY-4", "FANTRAY-5"]
|
||||
FAN_NAME_LIST = ["front", "rear"]
|
||||
|
||||
|
||||
class Fan(FanBase):
|
||||
"""Platform-specific Fan class"""
|
||||
|
||||
|
@ -84,7 +83,7 @@ class Fan(FanBase):
|
|||
speed = 0
|
||||
if self.get_presence():
|
||||
fan_speed_file = (FAN_PATH +
|
||||
self.fan_speed_rpm.format(self.fan_tray_index+1,FAN_NAME_LIST[self.fan_index]))
|
||||
self.fan_speed_rpm.format(self.fan_tray_index+1, FAN_NAME_LIST[self.fan_index]))
|
||||
speed = self.__read_txt_file(fan_speed_file).strip('\r\n')
|
||||
|
||||
return int(speed)
|
||||
|
@ -98,9 +97,9 @@ class Fan(FanBase):
|
|||
"""
|
||||
target = 0
|
||||
if self.get_presence():
|
||||
fan_speed_file=(FAN_PATH +
|
||||
fan_speed_file = (FAN_PATH +
|
||||
self.fan_speed_rpm.format(self.fan_tray_index+1, FAN_NAME_LIST[self.fan_index]))
|
||||
target=self.__read_txt_file(fan_speed_file).strip('\r\n')
|
||||
target = self.__read_txt_file(fan_speed_file).strip('\r\n')
|
||||
|
||||
return target
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Module contains an implementation of SONiC Platform Base API and
|
||||
# provides the platform information
|
||||
|
@ -12,6 +10,7 @@ try:
|
|||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Platform(PlatformBase):
|
||||
"""Platform-specific Platform class"""
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# psuutil.py
|
||||
# Platform-specific PSU status interface for SONiC
|
||||
|
@ -17,6 +15,7 @@ except ImportError as e:
|
|||
FAN_MAX_RPM = 9600
|
||||
PSU_NAME_LIST = ["PSU-0", "PSU-1"]
|
||||
|
||||
|
||||
class Psu(PsuBase):
|
||||
"""Platform-specific Psu class"""
|
||||
|
||||
|
@ -27,7 +26,6 @@ class Psu(PsuBase):
|
|||
self.index = psu_index
|
||||
PsuBase.__init__(self)
|
||||
|
||||
|
||||
def get_fan(self):
|
||||
"""
|
||||
Retrieves object representing the fan module contained in this PSU
|
||||
|
@ -73,8 +71,8 @@ class Psu(PsuBase):
|
|||
Returns:
|
||||
bool: True if PSU is present, False if not
|
||||
"""
|
||||
attr_file ='psu_present'
|
||||
attr_path = self.SYSFS_PSU_DIR[self.index-1] +'/' + attr_file
|
||||
attr_file = 'psu_present'
|
||||
attr_path = self.SYSFS_PSU_DIR[self.index-1] + '/' + attr_file
|
||||
status = 0
|
||||
try:
|
||||
with open(attr_path, 'r') as psu_prs:
|
||||
|
@ -91,7 +89,7 @@ class Psu(PsuBase):
|
|||
A boolean value, True if device is operating properly, False if not
|
||||
"""
|
||||
attr_file = 'psu_power_good'
|
||||
attr_path = self.SYSFS_PSU_DIR[self.index-1] +'/' + attr_file
|
||||
attr_path = self.SYSFS_PSU_DIR[self.index-1] + '/' + attr_file
|
||||
status = 0
|
||||
try:
|
||||
with open(attr_path, 'r') as power_status:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Sfp contains an implementation of SONiC Platform Base API and
|
||||
# provides the sfp device status which are available in the platform
|
||||
|
@ -105,6 +103,7 @@ qsfp_compliance_code_tup = ('10/40G Ethernet Compliance Code', 'SONET Compliance
|
|||
'Fibre Channel link length/Transmitter Technology',
|
||||
'Fibre Channel transmission media', 'Fibre Channel Speed')
|
||||
|
||||
|
||||
class Sfp(SfpBase):
|
||||
"""Platform-specific Sfp class"""
|
||||
|
||||
|
@ -168,7 +167,7 @@ class Sfp(SfpBase):
|
|||
52: 25,
|
||||
53: 26,
|
||||
}
|
||||
_sfp_port = range(48, PORT_END + 1)
|
||||
_sfp_port = list(range(48, PORT_END + 1))
|
||||
RESET_PATH = "/sys/bus/i2c/devices/{}-0050/sfp_port_reset"
|
||||
PRS_PATH = "/sys/bus/i2c/devices/{}-0050/sfp_is_present"
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class sfputil(SfpUtilBase):
|
||||
|
@ -16,41 +14,41 @@ class sfputil(SfpUtilBase):
|
|||
|
||||
port_to_eeprom_mapping = {}
|
||||
port_to_i2c_mapping = {
|
||||
9 : 18,
|
||||
10 : 19,
|
||||
11 : 20,
|
||||
12 : 21,
|
||||
1 : 22,
|
||||
2 : 23,
|
||||
3 : 24,
|
||||
4 : 25,
|
||||
6 : 26,
|
||||
5 : 27,
|
||||
8 : 28,
|
||||
7 : 29,
|
||||
13 : 30,
|
||||
14 : 31,
|
||||
15 : 32,
|
||||
16 : 33,
|
||||
17 : 34,
|
||||
18 : 35,
|
||||
19 : 36,
|
||||
20 : 37,
|
||||
25 : 38,
|
||||
26 : 39,
|
||||
27 : 40,
|
||||
28 : 41,
|
||||
29 : 42,
|
||||
30 : 43,
|
||||
31 : 44,
|
||||
32 : 45,
|
||||
21 : 46,
|
||||
22 : 47,
|
||||
23 : 48,
|
||||
24 : 49,
|
||||
9: 18,
|
||||
10: 19,
|
||||
11: 20,
|
||||
12: 21,
|
||||
1: 22,
|
||||
2: 23,
|
||||
3: 24,
|
||||
4: 25,
|
||||
6: 26,
|
||||
5: 27,
|
||||
8: 28,
|
||||
7: 29,
|
||||
13: 30,
|
||||
14: 31,
|
||||
15: 32,
|
||||
16: 33,
|
||||
17: 34,
|
||||
18: 35,
|
||||
19: 36,
|
||||
20: 37,
|
||||
25: 38,
|
||||
26: 39,
|
||||
27: 40,
|
||||
28: 41,
|
||||
29: 42,
|
||||
30: 43,
|
||||
31: 44,
|
||||
32: 45,
|
||||
21: 46,
|
||||
22: 47,
|
||||
23: 48,
|
||||
24: 49,
|
||||
}
|
||||
|
||||
_qsfp_ports = range(0, ports_in_block + 1)
|
||||
_qsfp_ports = list(range(0, ports_in_block + 1))
|
||||
|
||||
def __init__(self):
|
||||
# Override port_to_eeprom_mapping for class initialization
|
||||
|
@ -71,10 +69,10 @@ class sfputil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, 'w')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
time.sleep(1)
|
||||
|
@ -103,7 +101,7 @@ class sfputil(SfpUtilBase):
|
|||
reg_value = reg_file.readline().rstrip()
|
||||
reg_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if reg_value == '1':
|
||||
|
@ -121,7 +119,7 @@ class sfputil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(0, self.ports_in_block + 1)
|
||||
return list(range(0, self.ports_in_block + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -81,12 +81,12 @@ class SfpUtil(SfpUtilBase):
|
|||
46: 63,
|
||||
47: 64,
|
||||
48: 65,
|
||||
49: 66, #QSFP49
|
||||
49: 66, # QSFP49
|
||||
50: 67,
|
||||
51: 68,
|
||||
52: 69,
|
||||
53: 70,
|
||||
54: 71, #QSFP54
|
||||
54: 71, # QSFP54
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -107,7 +107,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -148,7 +148,7 @@ class SfpUtil(SfpUtilBase):
|
|||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -174,11 +174,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -207,7 +208,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -225,7 +226,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, 'w')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
reg_value = '0'
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -81,12 +81,12 @@ class SfpUtil(SfpUtilBase):
|
|||
46: 63,
|
||||
47: 64,
|
||||
48: 65,
|
||||
49: 66, #QSFP49
|
||||
49: 66, # QSFP49
|
||||
50: 67,
|
||||
51: 68,
|
||||
52: 69,
|
||||
53: 70,
|
||||
54: 71, #QSFP54
|
||||
54: 71, # QSFP54
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -107,7 +107,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -148,7 +148,7 @@ class SfpUtil(SfpUtilBase):
|
|||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
# content is a string, either "0" or "1"
|
||||
|
@ -175,11 +175,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -208,7 +209,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -226,7 +227,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, 'w')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
reg_value = '0'
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,11 +8,13 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/4-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -12,10 +12,11 @@ try:
|
|||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
|
@ -31,7 +32,7 @@ class SfpUtil(SfpUtilBase):
|
|||
_port_to_lp_mode = {}
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
_cpld_mapping = [ "8-0063", "7-0064"]
|
||||
_cpld_mapping = ["8-0063", "7-0064"]
|
||||
|
||||
_port_to_i2c_mapping = {
|
||||
1: 26,
|
||||
|
@ -58,7 +59,7 @@ class SfpUtil(SfpUtilBase):
|
|||
22: 47,
|
||||
23: 48,
|
||||
24: 49,
|
||||
25: 21, #QSFP
|
||||
25: 21, # QSFP
|
||||
26: 22,
|
||||
27: 23,
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -111,7 +112,7 @@ class SfpUtil(SfpUtilBase):
|
|||
cpld_i = self.get_cpld_num(port_num)
|
||||
cpld_ps = self._cpld_mapping[cpld_i]
|
||||
path = "/sys/bus/i2c/devices/{0}/present_{1}"
|
||||
index = ((port_num-1)%24) +1
|
||||
index = ((port_num-1) % 24) + 1
|
||||
port_ps = path.format(cpld_ps, index)
|
||||
|
||||
content = "0"
|
||||
|
@ -120,7 +121,7 @@ class SfpUtil(SfpUtilBase):
|
|||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -146,11 +147,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -179,7 +181,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -192,7 +194,7 @@ class SfpUtil(SfpUtilBase):
|
|||
@property
|
||||
def _get_present_bitmap(self):
|
||||
nodes = []
|
||||
port_num = [24,3]
|
||||
port_num = [24, 3]
|
||||
|
||||
path = "/sys/bus/i2c/devices/{0}/"
|
||||
cpld_path = path.format(self._cpld_mapping[0])
|
||||
|
@ -206,16 +208,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node[0])
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
cpld_bm = reg_file.readline().rstrip().zfill(node[1]/4)
|
||||
bitmap.append(cpld_bm)
|
||||
reg_file.close()
|
||||
|
||||
rev = "".join(bitmap[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -231,7 +234,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = self._get_present_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - 1))
|
||||
if changed_ports & mask:
|
||||
|
@ -249,5 +252,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,11 +8,13 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -11,10 +11,11 @@ try:
|
|||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
|
@ -85,14 +86,14 @@ class SfpUtil(SfpUtilBase):
|
|||
46: 87,
|
||||
47: 88,
|
||||
48: 86,
|
||||
49: 25,#QSFP49
|
||||
49: 25, # QSFP49
|
||||
50: 26,
|
||||
51: 27,
|
||||
52: 28,
|
||||
53: 29,
|
||||
54: 30,
|
||||
55: 31,
|
||||
56: 32,#QSFP56
|
||||
56: 32, # QSFP56
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -113,7 +114,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -145,13 +146,13 @@ class SfpUtil(SfpUtilBase):
|
|||
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
|
||||
port_ps = path.format(cpld_ps, port_num)
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(port_ps)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -177,12 +178,13 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -211,7 +213,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -231,10 +233,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(self.__port_to_mod_rst, 'r+', buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
time.sleep(1)
|
||||
|
@ -243,11 +245,12 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file.close()
|
||||
|
||||
return True
|
||||
|
||||
@property
|
||||
def _get_present_bitmap(self):
|
||||
nodes = []
|
||||
rev = []
|
||||
port_num = [30,26]
|
||||
port_num = [30, 26]
|
||||
|
||||
path = "/sys/bus/i2c/devices/{0}/module_present_all"
|
||||
cpld_i = self.get_cpld_num(self.port_start)
|
||||
|
@ -262,7 +265,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(node[0])
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap = reg_file.readline().rstrip()
|
||||
bitmap = bin(int(bitmap, 16))[2:].zfill(node[1])
|
||||
|
@ -273,7 +276,8 @@ class SfpUtil(SfpUtilBase):
|
|||
bitmaps = hex(int(bitmaps, 2))
|
||||
return int(bitmaps, 0)
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -289,7 +293,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = self._get_present_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - 1))
|
||||
if changed_ports & mask:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Cavium
|
||||
#
|
||||
|
@ -10,7 +8,6 @@
|
|||
#############################################################################
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -20,8 +17,9 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ try:
|
|||
import string
|
||||
from ctypes import create_string_buffer
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
|
@ -16,10 +16,9 @@ class SfpUtil(SfpUtilBase):
|
|||
_port_end = 31
|
||||
ports_in_block = 32
|
||||
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
|
||||
_qsfp_ports = range(0, ports_in_block + 1)
|
||||
_qsfp_ports = list(range(0, ports_in_block + 1))
|
||||
|
||||
def __init__(self):
|
||||
# Override port_to_eeprom_mapping for class initialization
|
||||
|
@ -45,7 +44,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = reg_file.readline().rstrip()
|
||||
reg_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if reg_value == '1':
|
||||
|
@ -63,7 +62,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(0, self.ports_in_block + 1)
|
||||
return list(range(0, self.ports_in_block + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -95,11 +94,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -128,7 +128,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
import string
|
||||
from ctypes import create_string_buffer
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
@ -22,41 +20,41 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
_port_to_eeprom_mapping = {}
|
||||
port_to_i2c_mapping = {
|
||||
9 : 18,
|
||||
10 : 19,
|
||||
11 : 20,
|
||||
12 : 21,
|
||||
1 : 22,
|
||||
2 : 23,
|
||||
3 : 24,
|
||||
4 : 25,
|
||||
6 : 26,
|
||||
5 : 27,
|
||||
8 : 28,
|
||||
7 : 29,
|
||||
13 : 30,
|
||||
14 : 31,
|
||||
15 : 32,
|
||||
16 : 33,
|
||||
17 : 34,
|
||||
18 : 35,
|
||||
19 : 36,
|
||||
20 : 37,
|
||||
25 : 38,
|
||||
26 : 39,
|
||||
27 : 40,
|
||||
28 : 41,
|
||||
29 : 42,
|
||||
30 : 43,
|
||||
31 : 44,
|
||||
32 : 45,
|
||||
21 : 46,
|
||||
22 : 47,
|
||||
23 : 48,
|
||||
24 : 49,
|
||||
9: 18,
|
||||
10: 19,
|
||||
11: 20,
|
||||
12: 21,
|
||||
1: 22,
|
||||
2: 23,
|
||||
3: 24,
|
||||
4: 25,
|
||||
6: 26,
|
||||
5: 27,
|
||||
8: 28,
|
||||
7: 29,
|
||||
13: 30,
|
||||
14: 31,
|
||||
15: 32,
|
||||
16: 33,
|
||||
17: 34,
|
||||
18: 35,
|
||||
19: 36,
|
||||
20: 37,
|
||||
25: 38,
|
||||
26: 39,
|
||||
27: 40,
|
||||
28: 41,
|
||||
29: 42,
|
||||
30: 43,
|
||||
31: 44,
|
||||
32: 45,
|
||||
21: 46,
|
||||
22: 47,
|
||||
23: 48,
|
||||
24: 49,
|
||||
}
|
||||
|
||||
_qsfp_ports = range(0, ports_in_block + 1)
|
||||
_qsfp_ports = list(range(0, ports_in_block + 1))
|
||||
|
||||
def __init__(self):
|
||||
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom'
|
||||
|
@ -76,10 +74,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, 'w', buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
time.sleep(1)
|
||||
|
@ -102,7 +100,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = reg_file.readline().rstrip()
|
||||
reg_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if reg_value == '1':
|
||||
|
@ -120,7 +118,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.port_start, self.ports_in_block + 1)
|
||||
return list(range(self.port_start, self.ports_in_block + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -144,11 +142,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -177,7 +176,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -197,16 +196,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -222,7 +222,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = self._get_all_presence
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - 1))
|
||||
if changed_ports & mask:
|
||||
|
@ -239,4 +239,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0056/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -10,7 +10,7 @@ try:
|
|||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
|
||||
|
@ -74,7 +74,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -103,7 +103,7 @@ class SfpUtil(SfpUtilBase):
|
|||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -129,11 +129,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -162,7 +163,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -178,7 +179,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(self.__port_to_mod_rst, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
reg_value = '1'
|
||||
|
@ -199,16 +200,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -224,7 +226,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = self._get_present_bitmap
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - 1))
|
||||
if changed_ports & mask:
|
||||
|
@ -241,4 +243,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
try:
|
||||
import time
|
||||
import os
|
||||
import sys, getopt
|
||||
import commands
|
||||
import sys
|
||||
import subprocess
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
@ -73,7 +73,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -93,7 +93,7 @@ class SfpUtil(SfpUtilBase):
|
|||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -109,17 +109,15 @@ class SfpUtil(SfpUtilBase):
|
|||
self._port_to_i2c_mapping[x][1]
|
||||
)
|
||||
if(x < 9):
|
||||
if(self.get_presence(x)==1):
|
||||
self.port_to_eeprom_mapping[x] = self.BASE_I2C_PATH + "0-000" +str(x+1) + "/eeprom"
|
||||
if(self.get_presence(x) == 1):
|
||||
self.port_to_eeprom_mapping[x] = self.BASE_I2C_PATH + "0-000" + str(x+1) + "/eeprom"
|
||||
|
||||
else:
|
||||
if(self.get_presence(x)==1):
|
||||
self.port_to_eeprom_mapping[x] = self.BASE_I2C_PATH + "0-00" +str(x+1)+ "/eeprom"
|
||||
if(self.get_presence(x) == 1):
|
||||
self.port_to_eeprom_mapping[x] = self.BASE_I2C_PATH + "0-00" + str(x+1) + "/eeprom"
|
||||
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
raise NotImplementedError
|
||||
|
||||
|
@ -131,7 +129,7 @@ class SfpUtil(SfpUtilBase):
|
|||
return False
|
||||
|
||||
mod_rst_cmd = "ipmitool raw 0x34 0x11 " + str(port_num+1) + " 0x11 0x1"
|
||||
(status, output) = commands.getstatusoutput (mod_rst_cmd)
|
||||
subprocess.check_output(mod_rst_cmd, universal_newlines=True)
|
||||
return True
|
||||
|
||||
def get_transceiver_change_event(self):
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -11,7 +11,7 @@ try:
|
|||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
@ -20,7 +20,7 @@ class SfpUtil(SfpUtilBase):
|
|||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
PORT_START = 1
|
||||
PORT_END = 32 #34 cages actually, but last 2 are not at port_config.ini.
|
||||
PORT_END = 32 # 34 cages actually, but last 2 are not at port_config.ini.
|
||||
PORTS_IN_BLOCK = 32
|
||||
|
||||
BASE_OOM_PATH = "/sys/bus/i2c/devices/{0}-0050/"
|
||||
|
@ -77,7 +77,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -100,13 +100,13 @@ class SfpUtil(SfpUtilBase):
|
|||
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
|
||||
self.__port_to_is_present = present_path
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(self.__port_to_is_present)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -132,11 +132,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -165,7 +166,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -182,10 +183,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(self.__port_to_mod_rst, 'r+', buffering=0)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#toggle reset
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
time.sleep(1)
|
||||
|
@ -208,16 +209,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -227,14 +229,13 @@ class SfpUtil(SfpUtilBase):
|
|||
timeout = 1000
|
||||
timeout = (timeout) / float(1000) # Convert to secs
|
||||
|
||||
|
||||
if now < (self.data['last'] + timeout) and self.data['valid']:
|
||||
return True, {}
|
||||
|
||||
reg_value = self.get_transceiver_status
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
fp_port = port
|
||||
mask = (1 << (fp_port - 1))
|
||||
|
@ -253,4 +254,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,11 +8,13 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
import string
|
||||
from ctypes import create_string_buffer
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
#from xcvrd
|
||||
# from xcvrd
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
SFP_STATUS_REMOVED = '0'
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform specific SfpUtill class"""
|
||||
|
||||
|
@ -21,72 +20,72 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
_port_to_eeprom_mapping = {}
|
||||
port_to_i2c_mapping = {
|
||||
61 : 25,
|
||||
62 : 26,
|
||||
63 : 27,
|
||||
64 : 28,
|
||||
55 : 29,
|
||||
56 : 30,
|
||||
53 : 31,
|
||||
54 : 32,
|
||||
9 : 33,
|
||||
10 : 34,
|
||||
11 : 35,
|
||||
12 : 36,
|
||||
1 : 37,
|
||||
2 : 38,
|
||||
3 : 39,
|
||||
4 : 40,
|
||||
6 : 41,
|
||||
5 : 42,
|
||||
8 : 43,
|
||||
7 : 44,
|
||||
13 : 45,
|
||||
14 : 46,
|
||||
15 : 47,
|
||||
16 : 48,
|
||||
17 : 49,
|
||||
18 : 50,
|
||||
19 : 51,
|
||||
20 : 52,
|
||||
25 : 53,
|
||||
26 : 54,
|
||||
27 : 55,
|
||||
28 : 56,
|
||||
29 : 57,
|
||||
30 : 58,
|
||||
31 : 59,
|
||||
32 : 60,
|
||||
21 : 61,
|
||||
22 : 62,
|
||||
23 : 63,
|
||||
24 : 64,
|
||||
41 : 65,
|
||||
42 : 66,
|
||||
43 : 67,
|
||||
44 : 68,
|
||||
33 : 69,
|
||||
34 : 70,
|
||||
35 : 71,
|
||||
36 : 72,
|
||||
45 : 73,
|
||||
46 : 74,
|
||||
47 : 75,
|
||||
48 : 76,
|
||||
37 : 77,
|
||||
38 : 78,
|
||||
39 : 79,
|
||||
40 : 80,
|
||||
57 : 81,
|
||||
58 : 82,
|
||||
59 : 83,
|
||||
60 : 84,
|
||||
49 : 85,
|
||||
50 : 86,
|
||||
51 : 87,
|
||||
52 : 88,}
|
||||
61: 25,
|
||||
62: 26,
|
||||
63: 27,
|
||||
64: 28,
|
||||
55: 29,
|
||||
56: 30,
|
||||
53: 31,
|
||||
54: 32,
|
||||
9: 33,
|
||||
10: 34,
|
||||
11: 35,
|
||||
12: 36,
|
||||
1: 37,
|
||||
2: 38,
|
||||
3: 39,
|
||||
4: 40,
|
||||
6: 41,
|
||||
5: 42,
|
||||
8: 43,
|
||||
7: 44,
|
||||
13: 45,
|
||||
14: 46,
|
||||
15: 47,
|
||||
16: 48,
|
||||
17: 49,
|
||||
18: 50,
|
||||
19: 51,
|
||||
20: 52,
|
||||
25: 53,
|
||||
26: 54,
|
||||
27: 55,
|
||||
28: 56,
|
||||
29: 57,
|
||||
30: 58,
|
||||
31: 59,
|
||||
32: 60,
|
||||
21: 61,
|
||||
22: 62,
|
||||
23: 63,
|
||||
24: 64,
|
||||
41: 65,
|
||||
42: 66,
|
||||
43: 67,
|
||||
44: 68,
|
||||
33: 69,
|
||||
34: 70,
|
||||
35: 71,
|
||||
36: 72,
|
||||
45: 73,
|
||||
46: 74,
|
||||
47: 75,
|
||||
48: 76,
|
||||
37: 77,
|
||||
38: 78,
|
||||
39: 79,
|
||||
40: 80,
|
||||
57: 81,
|
||||
58: 82,
|
||||
59: 83,
|
||||
60: 84,
|
||||
49: 85,
|
||||
50: 86,
|
||||
51: 87,
|
||||
52: 88, }
|
||||
|
||||
_qsfp_ports = range(0, ports_in_block + 1)
|
||||
_qsfp_ports = list(range(0, ports_in_block + 1))
|
||||
|
||||
def __init__(self):
|
||||
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom'
|
||||
|
@ -105,10 +104,10 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_ps, 'w')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
#HW will clear reset after set.
|
||||
# HW will clear reset after set.
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
reg_file.close()
|
||||
|
@ -128,7 +127,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = reg_file.readline().rstrip()
|
||||
reg_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if reg_value == '1':
|
||||
|
@ -146,7 +145,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(0, self.ports_in_block + 1)
|
||||
return list(range(0, self.ports_in_block + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -170,11 +169,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -203,7 +203,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -223,17 +223,17 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(node)
|
||||
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
bitmap += reg_file.readline().rstrip() + " "
|
||||
reg_file.close()
|
||||
|
||||
rev = bitmap.split(" ")
|
||||
rev = "".join(rev[::-1])
|
||||
return int(rev,16)
|
||||
return int(rev, 16)
|
||||
|
||||
data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
|
||||
data = {'valid':0, 'last':0, 'present':0}
|
||||
def get_transceiver_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
|
@ -250,7 +250,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_value = ~reg_value
|
||||
changed_ports = self.data['present'] ^ reg_value
|
||||
if changed_ports:
|
||||
for port in range (self.port_start, self.port_end+1):
|
||||
for port in range(self.port_start, self.port_end+1):
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << (port - 1))
|
||||
if changed_ports & mask:
|
||||
|
@ -267,4 +267,3 @@ class SfpUtil(SfpUtilBase):
|
|||
else:
|
||||
return True, {}
|
||||
return False, {}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,24 +8,26 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
def eeprom_check():
|
||||
filepath="/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
filepath = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
if os.path.isfile(filepath):
|
||||
return 1 #now board, 0x57
|
||||
return 1 # now board, 0x57
|
||||
else:
|
||||
return 0 #now board, 0x56
|
||||
return 0 # now board, 0x56
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
ret=eeprom_check()
|
||||
if ret==1:
|
||||
ret = eeprom_check()
|
||||
if ret == 1:
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
|
||||
else:
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
try:
|
||||
import time
|
||||
import os
|
||||
import sys, getopt
|
||||
import sys
|
||||
from ctypes import create_string_buffer
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
|
@ -75,7 +75,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -95,19 +95,19 @@ class SfpUtil(SfpUtilBase):
|
|||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
if port_num < 16 :
|
||||
if port_num < 16:
|
||||
present_path = self.BASE_CPLD1_PATH + "module_present_" + str(port_num+1)
|
||||
else:
|
||||
present_path = self.BASE_CPLD2_PATH + "module_present_" + str(port_num+1)
|
||||
self.__port_to_is_present = present_path
|
||||
|
||||
content="0"
|
||||
content = "0"
|
||||
try:
|
||||
val_file = open(self.__port_to_is_present)
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
print "Error: unable to access file: %s" % str(e)
|
||||
print("Error: unable to access file: %s" % str(e))
|
||||
return False
|
||||
|
||||
if content == "1":
|
||||
|
@ -133,11 +133,12 @@ class SfpUtil(SfpUtilBase):
|
|||
if ((lpmode & 0x3) == 0x3):
|
||||
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
else:
|
||||
return False # High Power Mode if one of the following conditions is matched:
|
||||
# High Power Mode if one of the following conditions is matched:
|
||||
# 1. "Power override" bit is 0
|
||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||
return False
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -169,7 +170,7 @@ class SfpUtil(SfpUtilBase):
|
|||
eeprom.write(buffer[0])
|
||||
return True
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
finally:
|
||||
if eeprom is not None:
|
||||
|
@ -180,7 +181,7 @@ class SfpUtil(SfpUtilBase):
|
|||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
if port_num < 16 :
|
||||
if port_num < 16:
|
||||
mod_rst_path = self.BASE_CPLD1_PATH + "module_reset_" + str(port_num+1)
|
||||
else:
|
||||
mod_rst_path = self.BASE_CPLD2_PATH + "module_reset_" + str(port_num+1)
|
||||
|
@ -189,7 +190,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(self.__port_to_mod_rst, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
reg_value = '1'
|
||||
|
@ -200,45 +201,45 @@ class SfpUtil(SfpUtilBase):
|
|||
return True
|
||||
|
||||
def get_cpld_interrupt(self):
|
||||
port_dict={}
|
||||
for i in range(0,4):
|
||||
if i==0 or i==1:
|
||||
port_dict = {}
|
||||
for i in range(0, 4):
|
||||
if i == 0 or i == 1:
|
||||
cpld_i2c_path = self.BASE_CPLD1_PATH + "cpld_intr_" + str(i+1)
|
||||
else:
|
||||
cpld_i2c_path = self.BASE_CPLD2_PATH + "cpld_intr_" +str(i+1)
|
||||
cpld_i2c_path = self.BASE_CPLD2_PATH + "cpld_intr_" + str(i+1)
|
||||
|
||||
start_i=(i*8)
|
||||
end_i=(i*8+8)
|
||||
start_i = (i*8)
|
||||
end_i = (i*8+8)
|
||||
try:
|
||||
val_file = open(cpld_i2c_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
|
||||
for k in range (start_i, end_i):
|
||||
port_dict[k]=0
|
||||
for k in range(start_i, end_i):
|
||||
port_dict[k] = 0
|
||||
return port_dict
|
||||
|
||||
status = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
status=status.strip()
|
||||
status= int(status, 16)
|
||||
status = status.strip()
|
||||
status = int(status, 16)
|
||||
|
||||
interrupt_status = ~(status & 0xff)
|
||||
if interrupt_status:
|
||||
port_shift=0
|
||||
for k in range (start_i, end_i):
|
||||
if interrupt_status & (0x1<<port_shift):
|
||||
port_dict[k]=1
|
||||
port_shift = 0
|
||||
for k in range(start_i, end_i):
|
||||
if interrupt_status & (0x1 << port_shift):
|
||||
port_dict[k] = 1
|
||||
else:
|
||||
port_dict[k]=0
|
||||
port_shift=port_shift+1
|
||||
port_dict[k] = 0
|
||||
port_shift = port_shift+1
|
||||
|
||||
return port_dict
|
||||
|
||||
def get_transceiver_change_event(self, timeout=0):
|
||||
start_time = time.time()
|
||||
port_dict = {}
|
||||
ori_present ={}
|
||||
ori_present = {}
|
||||
forever = False
|
||||
|
||||
if timeout == 0:
|
||||
|
@ -246,32 +247,32 @@ class SfpUtil(SfpUtilBase):
|
|||
elif timeout > 0:
|
||||
timeout = timeout / float(1000) # Convert to secs
|
||||
else:
|
||||
print "get_transceiver_change_event:Invalid timeout value", timeout
|
||||
print("get_transceiver_change_event:Invalid timeout value", timeout)
|
||||
return False, {}
|
||||
|
||||
end_time = start_time + timeout
|
||||
if start_time > end_time:
|
||||
print 'get_transceiver_change_event:' \
|
||||
'time wrap / invalid timeout value', timeout
|
||||
print('get_transceiver_change_event:'
|
||||
'time wrap / invalid timeout value', timeout)
|
||||
|
||||
return False, {} # Time wrap or possibly incorrect timeout
|
||||
|
||||
#for i in range(self.port_start, self.port_end+1):
|
||||
# for i in range(self.port_start, self.port_end+1):
|
||||
# ori_present[i]=self.get_presence(i)
|
||||
|
||||
while timeout >= 0:
|
||||
change_status=0
|
||||
change_status = 0
|
||||
|
||||
port_dict = self.get_cpld_interrupt()
|
||||
present=0
|
||||
for key, value in port_dict.iteritems():
|
||||
if value==1:
|
||||
present=self.get_presence(key)
|
||||
change_status=1
|
||||
present = 0
|
||||
for key, value in port_dict.items():
|
||||
if value == 1:
|
||||
present = self.get_presence(key)
|
||||
change_status = 1
|
||||
if present:
|
||||
port_dict[key]='1'
|
||||
port_dict[key] = '1'
|
||||
else:
|
||||
port_dict[key]='0'
|
||||
port_dict[key] = '0'
|
||||
|
||||
if change_status:
|
||||
return True, port_dict
|
||||
|
@ -285,5 +286,5 @@ class SfpUtil(SfpUtilBase):
|
|||
if timeout > 0:
|
||||
time.sleep(timeout)
|
||||
return True, {}
|
||||
print "get_evt_change_event: Should not reach here."
|
||||
print("get_evt_change_event: Should not reach here.")
|
||||
return False, {}
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,11 +8,13 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0x200, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# led_control.py
|
||||
#
|
||||
# Platform-specific LED control functionality for SONiC
|
||||
|
@ -17,7 +15,7 @@ try:
|
|||
from socket import *
|
||||
from select import *
|
||||
from minipack.pimutil import PimUtil
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + " - required module not found")
|
||||
|
||||
|
||||
|
@ -25,9 +23,8 @@ class LedControl(LedControlBase):
|
|||
"""Platform specific LED control class"""
|
||||
SONIC_PORT_NAME_PREFIX = "Ethernet"
|
||||
|
||||
|
||||
def __init__(self):
|
||||
pim=PimUtil()
|
||||
pim = PimUtil()
|
||||
pim.init_pim_fpga()
|
||||
|
||||
def _port_name_to_index(self, port_name):
|
||||
|
@ -40,20 +37,19 @@ class LedControl(LedControlBase):
|
|||
|
||||
def _port_state_to_mode(self, port_idx, state):
|
||||
if state == "up":
|
||||
return 1, 4 #port linkup, led is green
|
||||
return 1, 4 # port linkup, led is green
|
||||
else:
|
||||
return 0, 0 #port linkdown, led is off
|
||||
return 0, 0 # port linkdown, led is off
|
||||
|
||||
def port_link_state_change(self, portname, state):
|
||||
pim=PimUtil()
|
||||
pim = PimUtil()
|
||||
port_idx = self._port_name_to_index(portname)
|
||||
new_control, led_mode = self._port_state_to_mode(port_idx, state)
|
||||
color, control=pim.get_port_led(port_idx)
|
||||
color, control = pim.get_port_led(port_idx)
|
||||
|
||||
if color==led_mode:
|
||||
if control==new_control:
|
||||
if color == led_mode:
|
||||
if control == new_control:
|
||||
return
|
||||
|
||||
pim.set_port_led(port_idx, led_mode, new_control)#port linkup, led is green
|
||||
#port linkdown, led is off
|
||||
|
||||
pim.set_port_led(port_idx, led_mode, new_control) # port linkup, led is green
|
||||
# port linkdown, led is off
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Accton
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -7,7 +7,7 @@ try:
|
|||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
import os
|
||||
import sys, getopt
|
||||
import sys
|
||||
from minipack.pimutil import PimUtil
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
@ -36,7 +36,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.PORT_START, self.PORT_END + 1)
|
||||
return list(range(self.PORT_START, self.PORT_END + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -47,57 +47,56 @@ class SfpUtil(SfpUtilBase):
|
|||
base = ((port-1)/8*8) + 10
|
||||
index = (port - 1) % 8
|
||||
index = 7 - index
|
||||
if (index%2):
|
||||
index = index -1
|
||||
if (index % 2):
|
||||
index = index - 1
|
||||
else:
|
||||
index = index +1
|
||||
index = index + 1
|
||||
bus = base + index
|
||||
return bus
|
||||
|
||||
|
||||
def __init__(self):
|
||||
for x in range(0, self.port_end):
|
||||
self.port_to_eeprom_mapping[x] = self.LOCAL_OOM_PATH %x
|
||||
self.port_to_eeprom_mapping[x] = self.LOCAL_OOM_PATH % x
|
||||
|
||||
SfpUtilBase.__init__(self)
|
||||
pim=PimUtil()
|
||||
pim = PimUtil()
|
||||
pim.init_pim_fpga()
|
||||
|
||||
def __del__(self):
|
||||
self.value=0
|
||||
self.value = 0
|
||||
|
||||
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
|
||||
|
||||
pim=PimUtil()
|
||||
status=pim.get_qsfp_presence(port_num)
|
||||
pim = PimUtil()
|
||||
status = pim.get_qsfp_presence(port_num)
|
||||
return status
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
pim=PimUtil()
|
||||
pim = PimUtil()
|
||||
return pim.get_low_power_mode(port_num)
|
||||
|
||||
def set_low_power_mode(self, port_num, lpmode):
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
pim=PimUtil()
|
||||
pim = PimUtil()
|
||||
pim.set_low_power_mode(port_num, lpmode)
|
||||
return True
|
||||
|
||||
def reset(self, port_num):
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
pim=PimUtil()
|
||||
pim = PimUtil()
|
||||
pim.reset(port_num)
|
||||
return True
|
||||
|
||||
def get_transceiver_change_event(self, timeout=0):
|
||||
pim=PimUtil()
|
||||
pim = PimUtil()
|
||||
start_time = time.time()
|
||||
port_dict = {}
|
||||
forever = False
|
||||
|
@ -107,28 +106,28 @@ class SfpUtil(SfpUtilBase):
|
|||
elif timeout > 0:
|
||||
timeout = timeout / float(1000) # Convert to secs
|
||||
else:
|
||||
print "get_transceiver_change_event:Invalid timeout value", timeout
|
||||
print("get_transceiver_change_event:Invalid timeout value", timeout)
|
||||
return False, {}
|
||||
|
||||
end_time = start_time + timeout
|
||||
if start_time > end_time:
|
||||
print 'get_transceiver_change_event:' \
|
||||
'time wrap / invalid timeout value', timeout
|
||||
print('get_transceiver_change_event:'
|
||||
'time wrap / invalid timeout value', timeout)
|
||||
|
||||
return False, {} # Time wrap or possibly incorrect timeout
|
||||
|
||||
while timeout >= 0:
|
||||
change_status=0
|
||||
change_status = 0
|
||||
port_dict = pim.get_qsfp_interrupt()
|
||||
present=0
|
||||
for key, value in port_dict.iteritems():
|
||||
if value==1:
|
||||
present=self.get_presence(key)
|
||||
change_status=1
|
||||
present = 0
|
||||
for key, value in port_dict.items():
|
||||
if value == 1:
|
||||
present = self.get_presence(key)
|
||||
change_status = 1
|
||||
if present:
|
||||
port_dict[key]='1'
|
||||
port_dict[key] = '1'
|
||||
else:
|
||||
port_dict[key]='0'
|
||||
port_dict[key] = '0'
|
||||
|
||||
if change_status:
|
||||
return True, port_dict
|
||||
|
@ -142,5 +141,5 @@ class SfpUtil(SfpUtilBase):
|
|||
if timeout > 0:
|
||||
time.sleep(timeout)
|
||||
return True, {}
|
||||
print "get_evt_change_event: Should not reach here."
|
||||
print("get_evt_change_event: Should not reach here.")
|
||||
return False, {}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0056/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# led_control.py
|
||||
#
|
||||
# Platform-specific LED control functionality for SONiC
|
||||
#
|
||||
|
||||
# try:
|
||||
# from sonic_led.led_control_base import LedControlBase
|
||||
# import swsssdk
|
||||
# except ImportError, e:
|
||||
# except ImportError as e:
|
||||
# raise ImportError (str(e) + " - required module not found")
|
||||
|
||||
import time
|
||||
|
||||
class LedControlBase(object):
|
||||
# __metaclass__ = abc.ABCMeta
|
||||
|
||||
# @abc.abstractmethod
|
||||
class LedControlBase(object):
|
||||
# __metaclass__ = abc.ABCMeta
|
||||
|
||||
# @abc.abstractmethod
|
||||
def port_link_state_change(self, port, state):
|
||||
"""
|
||||
Called when port link state changes. Update port link state LED here.
|
||||
|
@ -26,6 +23,7 @@ class LedControlBase(object):
|
|||
"""
|
||||
return
|
||||
|
||||
|
||||
### Zion specified ###
|
||||
read_fan_fault = 0
|
||||
is_fan_all_OK = 0
|
||||
|
@ -35,14 +33,18 @@ is_thermal_high = 0
|
|||
is_reset_button_push = 0
|
||||
##########################
|
||||
|
||||
|
||||
def sysled_task():
|
||||
while True:
|
||||
system_led_check()
|
||||
time.sleep(5)
|
||||
|
||||
### Zion specified ###
|
||||
|
||||
|
||||
def system_led_check():
|
||||
global read_fan_fault, read_power_status, is_fan_all_OK, is_power_all_OK, is_thermal_high, is_reset_button_push
|
||||
|
||||
is_fan_all_OK = 1
|
||||
is_power_all_OK = 0
|
||||
is_thermal_high = 0
|
||||
|
@ -96,7 +98,6 @@ def system_led_check():
|
|||
else:
|
||||
f11.write("1")
|
||||
|
||||
|
||||
with open("/sys/bus/i2c/devices/1-005e/psu1_power_good", "r") as f1:
|
||||
read_power_status = f1.read()
|
||||
with open("/sys/bus/i2c/devices/9-005f/sys_pwr", "w") as f11:
|
||||
|
@ -128,7 +129,6 @@ def system_led_check():
|
|||
else:
|
||||
f11.write("4")
|
||||
|
||||
|
||||
with open("/sys/bus/i2c/devices/9-005f/swi_ctrl", "r") as f5:
|
||||
is_reset_button_push = f5.read()
|
||||
if str(is_reset_button_push) == "1\n":
|
||||
|
@ -184,14 +184,15 @@ class LedControl(LedControlBase):
|
|||
swss = swsssdk.SonicV2Connector()
|
||||
swss.connect(swss.APPL_DB)
|
||||
|
||||
lanes = swss.get(swss.APPL_DB, self.PORT_TABLE_PREFIX + port_name, 'lanes')
|
||||
lanes = swss.get(
|
||||
swss.APPL_DB, self.PORT_TABLE_PREFIX + port_name, 'lanes')
|
||||
|
||||
# SONiC port nums are 0-based and increment by 4
|
||||
# Arista QSFP indices are 1-based and increment by 1
|
||||
return (((sonic_port_num/4) + 1), sonic_port_num%4, len(lanes.split(',')))
|
||||
|
||||
return (((sonic_port_num/4) + 1), sonic_port_num % 4, len(lanes.split(',')))
|
||||
|
||||
# Concrete implementation of port_link_state_change() method
|
||||
|
||||
def port_link_state_change_bk(self, port, state):
|
||||
qsfp_index, lane_index, lanes = self._port_name_to_qsfp_index(port)
|
||||
|
||||
|
@ -203,9 +204,11 @@ class LedControl(LedControlBase):
|
|||
# whereas indices 25-32 are not breakout-capable, and only have one
|
||||
if qsfp_index <= self.QSFP_BREAKOUT_END_IDX:
|
||||
# assuming 40G, then we need to control four lanes
|
||||
led_sysfs_paths = [ self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index, i) for i in range(lane_index + 1, lane_index + 1 + lanes) ]
|
||||
led_sysfs_paths = [self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(
|
||||
qsfp_index, i) for i in range(lane_index + 1, lane_index + 1 + lanes)]
|
||||
else:
|
||||
led_sysfs_paths = [ self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index) ]
|
||||
led_sysfs_paths = [
|
||||
self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index)]
|
||||
|
||||
for led_sysfs_path in led_sysfs_paths:
|
||||
led_file = open(led_sysfs_path, "w")
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Alphanetworks
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
|
@ -16,17 +14,18 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
port_to_eeprom = {}
|
||||
port_to_i2cbus_mapping = {
|
||||
1 : 14,
|
||||
2 : 15,
|
||||
3 : 16,
|
||||
4 : 17,
|
||||
1: 14,
|
||||
2: 15,
|
||||
3: 16,
|
||||
4: 17,
|
||||
}
|
||||
|
||||
eeprom_path = "/sys/bus/i2c/devices/{0}-005f/sfp{1}_eeprom"
|
||||
port_reset_path = "/sys/bus/i2c/devices/{0}-005f/sfp{1}_port_reset"
|
||||
present_path = "/sys/bus/i2c/devices/{0}-005f/sfp{1}_is_present"
|
||||
|
||||
_qsfp_ports = range(first_port, port_num + 1)
|
||||
_qsfp_ports = list(range(first_port, port_num + 1))
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
return self.first_port
|
||||
|
@ -37,7 +36,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.first_port, self.port_num + 1)
|
||||
return list(range(self.first_port, self.port_num + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -72,7 +71,7 @@ class SfpUtil(SfpUtilBase):
|
|||
try:
|
||||
reg_file = open(port_path, 'w')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
# reset
|
||||
|
@ -101,11 +100,10 @@ class SfpUtil(SfpUtilBase):
|
|||
path = self.present_path
|
||||
port_path = path.format(self.port_to_i2cbus_mapping[i2c_index], (index + 1))
|
||||
|
||||
|
||||
try:
|
||||
reg_file = open(port_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
reg_value = reg_file.readline().rstrip()
|
||||
|
@ -113,4 +111,3 @@ class SfpUtil(SfpUtilBase):
|
|||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
|
@ -11,14 +8,16 @@ try:
|
|||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/1-0056/eeprom"
|
||||
#Two i2c buses might get flipped order, check them both.
|
||||
# Two i2c buses might get flipped order, check them both.
|
||||
if not os.path.exists(self.eeprom_path):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# led_control.py
|
||||
#
|
||||
# Platform-specific LED control functionality for SONiC
|
||||
|
@ -8,15 +6,16 @@
|
|||
# try:
|
||||
# from sonic_led.led_control_base import LedControlBase
|
||||
# import swsssdk
|
||||
# except ImportError, e:
|
||||
# except ImportError as e:
|
||||
# raise ImportError (str(e) + " - required module not found")
|
||||
|
||||
import time
|
||||
|
||||
class LedControlBase(object):
|
||||
# __metaclass__ = abc.ABCMeta
|
||||
|
||||
# @abc.abstractmethod
|
||||
class LedControlBase(object):
|
||||
# __metaclass__ = abc.ABCMeta
|
||||
|
||||
# @abc.abstractmethod
|
||||
def port_link_state_change(self, port, state):
|
||||
"""
|
||||
Called when port link state changes. Update port link state LED here.
|
||||
|
@ -26,6 +25,7 @@ class LedControlBase(object):
|
|||
"""
|
||||
return
|
||||
|
||||
|
||||
### Goreme specified ###
|
||||
read_fan_fault = 0
|
||||
is_fan_all_OK = 0
|
||||
|
@ -35,12 +35,15 @@ is_thermal_high = 0
|
|||
is_reset_button_push = 0
|
||||
##########################
|
||||
|
||||
|
||||
def sysled_task():
|
||||
while True:
|
||||
system_led_check()
|
||||
time.sleep(5)
|
||||
|
||||
########## Goreme System LED checking
|
||||
# Goreme System LED checking
|
||||
|
||||
|
||||
def system_led_check():
|
||||
global read_fan_fault, read_power_status, is_fan_all_OK, is_power_all_OK, is_thermal_high, is_reset_button_push
|
||||
is_fan_all_OK = 1
|
||||
|
@ -70,7 +73,6 @@ def system_led_check():
|
|||
else:
|
||||
f11.write("4")
|
||||
|
||||
|
||||
with open("/sys/bus/i2c/devices/0-005e/psu1_power_good", "r") as f1:
|
||||
read_power_status = f1.read()
|
||||
if str(read_power_status) != str("1\n"):
|
||||
|
@ -94,7 +96,6 @@ def system_led_check():
|
|||
else:
|
||||
f11.write("4")
|
||||
|
||||
|
||||
with open("/sys/bus/i2c/devices/8-005f/swi_ctrl", "r") as f5:
|
||||
is_reset_button_push = f5.read()
|
||||
if str(is_reset_button_push) == "1\n":
|
||||
|
@ -120,6 +121,7 @@ def system_led_check():
|
|||
return
|
||||
##########
|
||||
|
||||
|
||||
class LedControl(LedControlBase):
|
||||
"""Platform specific LED control class"""
|
||||
PORT_TABLE_PREFIX = "PORT_TABLE:"
|
||||
|
@ -149,15 +151,15 @@ class LedControl(LedControlBase):
|
|||
swss = swsssdk.SonicV2Connector()
|
||||
swss.connect(swss.APPL_DB)
|
||||
|
||||
lanes = swss.get(swss.APPL_DB, self.PORT_TABLE_PREFIX + port_name, 'lanes')
|
||||
lanes = swss.get(
|
||||
swss.APPL_DB, self.PORT_TABLE_PREFIX + port_name, 'lanes')
|
||||
|
||||
# SONiC port nums are 0-based and increment by 4
|
||||
# Arista QSFP indices are 1-based and increment by 1
|
||||
return (((sonic_port_num/4) + 1), sonic_port_num%4, len(lanes.split(',')))
|
||||
|
||||
|
||||
return (((sonic_port_num/4) + 1), sonic_port_num % 4, len(lanes.split(',')))
|
||||
|
||||
# Concrete implementation of port_link_state_change() method
|
||||
|
||||
def port_link_state_change_bk(self, port, state):
|
||||
qsfp_index, lane_index, lanes = self._port_name_to_qsfp_index(port)
|
||||
|
||||
|
@ -169,9 +171,11 @@ class LedControl(LedControlBase):
|
|||
# whereas indices 25-32 are not breakout-capable, and only have one
|
||||
if qsfp_index <= self.QSFP_BREAKOUT_END_IDX:
|
||||
# assuming 40G, then we need to control four lanes
|
||||
led_sysfs_paths = [ self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(qsfp_index, i) for i in range(lane_index + 1, lane_index + 1 + lanes) ]
|
||||
led_sysfs_paths = [self.LED_SYSFS_PATH_BREAKOUT_CAPABLE.format(
|
||||
qsfp_index, i) for i in range(lane_index + 1, lane_index + 1 + lanes)]
|
||||
else:
|
||||
led_sysfs_paths = [ self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index) ]
|
||||
led_sysfs_paths = [
|
||||
self.LED_SYSFS_PATH_NO_BREAKOUT.format(qsfp_index)]
|
||||
|
||||
for led_sysfs_path in led_sysfs_paths:
|
||||
led_file = open(led_sysfs_path, "w")
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Alphanetworks
|
||||
#
|
||||
|
@ -13,7 +11,8 @@ import os.path
|
|||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
|
@ -16,11 +14,11 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
port_to_eeprom = {}
|
||||
port_to_i2cbus_mapping = {
|
||||
1 : 13,
|
||||
2 : 14,
|
||||
3 : 15,
|
||||
4 : 16,
|
||||
5 : 23,
|
||||
1: 13,
|
||||
2: 14,
|
||||
3: 15,
|
||||
4: 16,
|
||||
5: 23,
|
||||
}
|
||||
|
||||
eeprom_path_1 = "/sys/bus/i2c/devices/{0}-0020/sfp{1}_eeprom"
|
||||
|
@ -30,7 +28,7 @@ class SfpUtil(SfpUtilBase):
|
|||
present_path_1 = "/sys/bus/i2c/devices/{0}-0020/sfp{1}_is_present"
|
||||
present_path = "/sys/bus/i2c/devices/{0}-005f/sfp{1}_is_present"
|
||||
|
||||
_qsfp_ports = range(first_port, port_num)
|
||||
_qsfp_ports = list(range(first_port, port_num))
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
|
@ -42,7 +40,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.first_port, self.port_num + 1)
|
||||
return list(range(self.first_port, self.port_num + 1))
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
|
@ -84,7 +82,7 @@ class SfpUtil(SfpUtilBase):
|
|||
reg_file = open(port_path, 'w')
|
||||
except IOError as e:
|
||||
if cpld_index < 5:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
# reset
|
||||
|
@ -116,12 +114,11 @@ class SfpUtil(SfpUtilBase):
|
|||
path = self.present_path
|
||||
port_path = path.format(self.port_to_i2cbus_mapping[cpld_index], index)
|
||||
|
||||
|
||||
try:
|
||||
reg_file = open(port_path)
|
||||
except IOError as e:
|
||||
if cpld_index < 5:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
reg_value = reg_file.readline().rstrip()
|
||||
|
@ -129,4 +126,3 @@ class SfpUtil(SfpUtilBase):
|
|||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import arista.platforms
|
||||
from arista.utils.sonic_reboot import reboot
|
||||
|
||||
|
||||
def main():
|
||||
# reboot the system
|
||||
reboot()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Arista eeprom processing for SONiC
|
||||
# Uses the arista driver library to obtain the TlvInfoDecoder
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Arista LED controls for SONiC
|
||||
#
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Arista PSU interface for SONiC
|
||||
#
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Arista SFP transceiver interface for SONiC
|
||||
#
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
|
||||
try:
|
||||
import importlib
|
||||
import time
|
||||
|
@ -23,50 +20,61 @@ try:
|
|||
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, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
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)
|
||||
"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)
|
||||
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"
|
||||
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'
|
||||
|
@ -76,6 +84,7 @@ pltfm_mgr = None
|
|||
EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom"
|
||||
EEPROM_STATUS = "/var/run/platform/eeprom/status"
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
RETRIES = 35
|
||||
|
||||
|
@ -114,8 +123,10 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|||
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_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()
|
||||
|
@ -139,7 +150,7 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|||
f.close()
|
||||
|
||||
eeprom_params = ""
|
||||
for attr, val in eeprom.__dict__.iteritems():
|
||||
for attr, val in eeprom.__dict__.items():
|
||||
if val is None:
|
||||
continue
|
||||
|
||||
|
@ -147,13 +158,14 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|||
if elem is None:
|
||||
continue
|
||||
|
||||
if isinstance(val, basestring):
|
||||
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')
|
||||
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:
|
||||
|
@ -164,9 +176,9 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|||
|
||||
orig_stdout = sys.stdout
|
||||
sys.stdout = StringIO()
|
||||
new_e = eeprom_tlvinfo.TlvInfoDecoder.set_eeprom(self, "", [eeprom_params])
|
||||
new_e = eeprom_tlvinfo.TlvInfoDecoder.set_eeprom(
|
||||
self, "", [eeprom_params])
|
||||
sys.stdout = orig_stdout
|
||||
eeprom_base.EepromDecoder.write_eeprom(self, new_e)
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -177,7 +177,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_sys_tmp_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_sys_tmp_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_sys_eeprom_get(self):
|
||||
self.send_pltfm_mgr_sys_eeprom_get()
|
||||
|
@ -205,7 +206,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_sys_eeprom_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_sys_eeprom_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_pwr_supply_present_get(self, ps_num):
|
||||
"""
|
||||
|
@ -238,7 +240,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_pwr_supply_present_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_pwr_supply_present_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_pwr_supply_info_get(self, ps_num):
|
||||
"""
|
||||
|
@ -271,7 +274,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_pwr_supply_info_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_pwr_supply_info_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_pwr_rail_info_get(self, ps_num):
|
||||
"""
|
||||
|
@ -304,7 +308,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_pwr_rail_info_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_pwr_rail_info_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_fan_speed_set(self, fan_num, percent):
|
||||
"""
|
||||
|
@ -339,7 +344,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_fan_speed_set failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_fan_speed_set failed: unknown result")
|
||||
|
||||
def pltfm_mgr_fan_info_get(self, fan_num):
|
||||
"""
|
||||
|
@ -372,7 +378,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_fan_info_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_fan_info_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_qsfp_presence_get(self, port_num):
|
||||
"""
|
||||
|
@ -405,7 +412,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_presence_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_qsfp_presence_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_qsfp_info_get(self, port_num):
|
||||
"""
|
||||
|
@ -438,7 +446,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_info_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_qsfp_info_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_qsfp_get_max_port(self):
|
||||
self.send_pltfm_mgr_qsfp_get_max_port()
|
||||
|
@ -466,7 +475,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_get_max_port failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_qsfp_get_max_port failed: unknown result")
|
||||
|
||||
def pltfm_mgr_qsfp_reset(self, port_num, reset):
|
||||
"""
|
||||
|
@ -534,7 +544,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_lpmode_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_qsfp_lpmode_get failed: unknown result")
|
||||
|
||||
def pltfm_mgr_qsfp_lpmode_set(self, port_num, lpmode):
|
||||
"""
|
||||
|
@ -569,7 +580,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_lpmode_set failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_qsfp_lpmode_set failed: unknown result")
|
||||
|
||||
def pltfm_mgr_sensor_info_get(self, options):
|
||||
"""
|
||||
|
@ -602,7 +614,8 @@ class Client(Iface):
|
|||
return result.success
|
||||
if result.ouch is not None:
|
||||
raise result.ouch
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_sensor_info_get failed: unknown result")
|
||||
raise TApplicationException(TApplicationException.MISSING_RESULT,
|
||||
"pltfm_mgr_sensor_info_get failed: unknown result")
|
||||
|
||||
|
||||
class Processor(Iface, TProcessor):
|
||||
|
@ -1020,7 +1033,7 @@ class pltfm_mgr_dummy_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1079,7 +1092,7 @@ class pltfm_mgr_dummy_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1121,7 +1134,7 @@ class pltfm_mgr_sys_tmp_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1194,7 +1207,7 @@ class pltfm_mgr_sys_tmp_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1236,7 +1249,7 @@ class pltfm_mgr_sys_eeprom_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1309,7 +1322,7 @@ class pltfm_mgr_sys_eeprom_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1369,7 +1382,7 @@ class pltfm_mgr_pwr_supply_present_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1441,7 +1454,7 @@ class pltfm_mgr_pwr_supply_present_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1501,7 +1514,7 @@ class pltfm_mgr_pwr_supply_info_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1574,7 +1587,7 @@ class pltfm_mgr_pwr_supply_info_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1634,7 +1647,7 @@ class pltfm_mgr_pwr_rail_info_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1707,7 +1720,7 @@ class pltfm_mgr_pwr_rail_info_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1779,7 +1792,7 @@ class pltfm_mgr_fan_speed_set_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1851,7 +1864,7 @@ class pltfm_mgr_fan_speed_set_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1911,7 +1924,7 @@ class pltfm_mgr_fan_info_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1984,7 +1997,7 @@ class pltfm_mgr_fan_info_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2044,7 +2057,7 @@ class pltfm_mgr_qsfp_presence_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2116,7 +2129,7 @@ class pltfm_mgr_qsfp_presence_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2176,7 +2189,7 @@ class pltfm_mgr_qsfp_info_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2213,7 +2226,8 @@ class pltfm_mgr_qsfp_info_get_result(object):
|
|||
break
|
||||
if fid == 0:
|
||||
if ftype == TType.STRING:
|
||||
self.success = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.success = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 1:
|
||||
|
@ -2248,7 +2262,7 @@ class pltfm_mgr_qsfp_info_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2290,7 +2304,7 @@ class pltfm_mgr_qsfp_get_max_port_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2362,7 +2376,7 @@ class pltfm_mgr_qsfp_get_max_port_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2434,7 +2448,7 @@ class pltfm_mgr_qsfp_reset_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2506,7 +2520,7 @@ class pltfm_mgr_qsfp_reset_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2566,7 +2580,7 @@ class pltfm_mgr_qsfp_lpmode_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2638,7 +2652,7 @@ class pltfm_mgr_qsfp_lpmode_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2710,7 +2724,7 @@ class pltfm_mgr_qsfp_lpmode_set_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2782,7 +2796,7 @@ class pltfm_mgr_qsfp_lpmode_set_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2817,7 +2831,8 @@ class pltfm_mgr_sensor_info_get_args(object):
|
|||
break
|
||||
if fid == 1:
|
||||
if ftype == TType.STRING:
|
||||
self.options = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.options = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
else:
|
||||
|
@ -2842,7 +2857,7 @@ class pltfm_mgr_sensor_info_get_args(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -2879,7 +2894,8 @@ class pltfm_mgr_sensor_info_get_result(object):
|
|||
break
|
||||
if fid == 0:
|
||||
if ftype == TType.STRING:
|
||||
self.success = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.success = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 1:
|
||||
|
@ -2914,7 +2930,7 @@ class pltfm_mgr_sensor_info_get_result(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
|
|
@ -171,7 +171,7 @@ class pltfm_mgr_sys_tmp_t(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -274,37 +274,44 @@ class pltfm_mgr_eeprom_t(object):
|
|||
iprot.skip(ftype)
|
||||
elif fid == 2:
|
||||
if ftype == TType.STRING:
|
||||
self.prod_name = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.prod_name = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 3:
|
||||
if ftype == TType.STRING:
|
||||
self.prod_part_num = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.prod_part_num = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 4:
|
||||
if ftype == TType.STRING:
|
||||
self.sys_asm_part_num = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.sys_asm_part_num = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 5:
|
||||
if ftype == TType.STRING:
|
||||
self.bfn_pcba_part_num = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.bfn_pcba_part_num = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 6:
|
||||
if ftype == TType.STRING:
|
||||
self.bfn_pcbb_part_num = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.bfn_pcbb_part_num = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 7:
|
||||
if ftype == TType.STRING:
|
||||
self.odm_pcba_part_num = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.odm_pcba_part_num = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 8:
|
||||
if ftype == TType.STRING:
|
||||
self.odm_pcba_ser_num = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.odm_pcba_ser_num = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 9:
|
||||
|
@ -324,42 +331,50 @@ class pltfm_mgr_eeprom_t(object):
|
|||
iprot.skip(ftype)
|
||||
elif fid == 12:
|
||||
if ftype == TType.STRING:
|
||||
self.prod_ser_num = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.prod_ser_num = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 13:
|
||||
if ftype == TType.STRING:
|
||||
self.prod_ast_tag = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.prod_ast_tag = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 14:
|
||||
if ftype == TType.STRING:
|
||||
self.sys_mfger = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.sys_mfger = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 15:
|
||||
if ftype == TType.STRING:
|
||||
self.sys_mfg_date = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.sys_mfg_date = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 16:
|
||||
if ftype == TType.STRING:
|
||||
self.pcb_mfger = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.pcb_mfger = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 17:
|
||||
if ftype == TType.STRING:
|
||||
self.assembled_at = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.assembled_at = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 18:
|
||||
if ftype == TType.STRING:
|
||||
self.loc_mac_addr = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.loc_mac_addr = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 19:
|
||||
if ftype == TType.STRING:
|
||||
self.ext_mac_addr = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.ext_mac_addr = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 20:
|
||||
|
@ -369,7 +384,8 @@ class pltfm_mgr_eeprom_t(object):
|
|||
iprot.skip(ftype)
|
||||
elif fid == 21:
|
||||
if ftype == TType.STRING:
|
||||
self.location = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
self.location = iprot.readString().decode(
|
||||
'utf-8') if sys.version_info[0] == 2 else iprot.readString()
|
||||
else:
|
||||
iprot.skip(ftype)
|
||||
elif fid == 22:
|
||||
|
@ -401,23 +417,28 @@ class pltfm_mgr_eeprom_t(object):
|
|||
oprot.writeFieldEnd()
|
||||
if self.sys_asm_part_num is not None:
|
||||
oprot.writeFieldBegin('sys_asm_part_num', TType.STRING, 4)
|
||||
oprot.writeString(self.sys_asm_part_num.encode('utf-8') if sys.version_info[0] == 2 else self.sys_asm_part_num)
|
||||
oprot.writeString(self.sys_asm_part_num.encode('utf-8')
|
||||
if sys.version_info[0] == 2 else self.sys_asm_part_num)
|
||||
oprot.writeFieldEnd()
|
||||
if self.bfn_pcba_part_num is not None:
|
||||
oprot.writeFieldBegin('bfn_pcba_part_num', TType.STRING, 5)
|
||||
oprot.writeString(self.bfn_pcba_part_num.encode('utf-8') if sys.version_info[0] == 2 else self.bfn_pcba_part_num)
|
||||
oprot.writeString(self.bfn_pcba_part_num.encode('utf-8')
|
||||
if sys.version_info[0] == 2 else self.bfn_pcba_part_num)
|
||||
oprot.writeFieldEnd()
|
||||
if self.bfn_pcbb_part_num is not None:
|
||||
oprot.writeFieldBegin('bfn_pcbb_part_num', TType.STRING, 6)
|
||||
oprot.writeString(self.bfn_pcbb_part_num.encode('utf-8') if sys.version_info[0] == 2 else self.bfn_pcbb_part_num)
|
||||
oprot.writeString(self.bfn_pcbb_part_num.encode('utf-8')
|
||||
if sys.version_info[0] == 2 else self.bfn_pcbb_part_num)
|
||||
oprot.writeFieldEnd()
|
||||
if self.odm_pcba_part_num is not None:
|
||||
oprot.writeFieldBegin('odm_pcba_part_num', TType.STRING, 7)
|
||||
oprot.writeString(self.odm_pcba_part_num.encode('utf-8') if sys.version_info[0] == 2 else self.odm_pcba_part_num)
|
||||
oprot.writeString(self.odm_pcba_part_num.encode('utf-8')
|
||||
if sys.version_info[0] == 2 else self.odm_pcba_part_num)
|
||||
oprot.writeFieldEnd()
|
||||
if self.odm_pcba_ser_num is not None:
|
||||
oprot.writeFieldBegin('odm_pcba_ser_num', TType.STRING, 8)
|
||||
oprot.writeString(self.odm_pcba_ser_num.encode('utf-8') if sys.version_info[0] == 2 else self.odm_pcba_ser_num)
|
||||
oprot.writeString(self.odm_pcba_ser_num.encode('utf-8')
|
||||
if sys.version_info[0] == 2 else self.odm_pcba_ser_num)
|
||||
oprot.writeFieldEnd()
|
||||
if self.prod_state is not None:
|
||||
oprot.writeFieldBegin('prod_state', TType.I16, 9)
|
||||
|
@ -483,7 +504,7 @@ class pltfm_mgr_eeprom_t(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -651,7 +672,7 @@ class pltfm_mgr_pwr_supply_info_t(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -891,7 +912,7 @@ class pltfm_mgr_pwr_rail_info_t(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -987,7 +1008,7 @@ class pltfm_mgr_fan_info_t(object):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
@ -1050,7 +1071,7 @@ class InvalidPltfmMgrOperation(TException):
|
|||
|
||||
def __repr__(self):
|
||||
L = ['%s=%r' % (key, value)
|
||||
for key, value in self.__dict__.items()]
|
||||
for key, value in list(self.__dict__.items())]
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
|
||||
|
||||
def __eq__(self, other):
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import os
|
||||
import sys
|
||||
|
@ -16,12 +14,13 @@ try:
|
|||
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
thrift_server = 'localhost'
|
||||
transport = None
|
||||
pltfm_mgr = None
|
||||
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
||||
|
@ -35,8 +34,10 @@ class PsuUtil(PsuBase):
|
|||
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_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()
|
||||
|
@ -93,4 +94,3 @@ class PsuUtil(PsuBase):
|
|||
return False
|
||||
|
||||
return status
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import os
|
||||
import sys
|
||||
|
@ -17,7 +15,7 @@ try:
|
|||
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
thrift_server = 'localhost'
|
||||
transport = None
|
||||
|
@ -25,6 +23,7 @@ pltfm_mgr = None
|
|||
|
||||
SFP_EEPROM_CACHE = "/var/run/platform/sfp/cache"
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
|
@ -51,11 +50,11 @@ class SfpUtil(SfpUtilBase):
|
|||
@property
|
||||
def qsfp_ports(self):
|
||||
self.update_port_info()
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
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"
|
||||
print("dependency on sysfs has been removed")
|
||||
raise Exception()
|
||||
|
||||
def __init__(self):
|
||||
|
@ -80,7 +79,7 @@ class SfpUtil(SfpUtilBase):
|
|||
|
||||
if self.QSFP_PORT_END == 0:
|
||||
self.thrift_setup()
|
||||
self.QSFP_PORT_END = pltfm_mgr.pltfm_mgr_qsfp_get_max_port();
|
||||
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()
|
||||
|
@ -127,8 +126,8 @@ class SfpUtil(SfpUtilBase):
|
|||
presence = pltfm_mgr.pltfm_mgr_qsfp_presence_get(port_num)
|
||||
self.thrift_teardown()
|
||||
except Exception as e:
|
||||
print e.__doc__
|
||||
print e.message
|
||||
print(e.__doc__)
|
||||
print(e.message)
|
||||
|
||||
return presence
|
||||
|
||||
|
@ -200,7 +199,7 @@ class SfpUtil(SfpUtilBase):
|
|||
elif timeout > 0:
|
||||
timeout = timeout / float(1000) # Convert to secs
|
||||
else:
|
||||
print "get_transceiver_change_event:Invalid timeout value", timeout
|
||||
print("get_transceiver_change_event:Invalid timeout value", timeout)
|
||||
return False, {}
|
||||
|
||||
while forever or timeout > 0:
|
||||
|
@ -249,4 +248,3 @@ class SfpUtil(SfpUtilBase):
|
|||
self.thrift_teardown()
|
||||
|
||||
return eeprom_path
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Broadcom XLR/GTS 'eeprom' support
|
||||
#
|
||||
|
@ -16,8 +14,8 @@ import os
|
|||
|
||||
try:
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os.path
|
||||
|
||||
try:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
import os
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica Haliburton
|
||||
#
|
||||
|
@ -11,8 +9,8 @@
|
|||
|
||||
try:
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
@ -20,4 +18,3 @@ class board(eeprom_tlvinfo.TlvInfoDecoder):
|
|||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/class/i2c-adapter/i2c-2/2-0050/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os.path
|
||||
|
||||
try:
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
import os
|
||||
|
@ -69,7 +67,7 @@ class SfpUtil(SfpUtilBase):
|
|||
52: 16
|
||||
}
|
||||
_port_to_eeprom_mapping = {}
|
||||
_sfp_port = range(49, PORT_END + 1)
|
||||
_sfp_port = list(range(49, PORT_END + 1))
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
|
@ -95,7 +93,6 @@ class SfpUtil(SfpUtilBase):
|
|||
self.port_to_eeprom_mapping[x] = port_eeprom_path
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
|
||||
def get_presence(self, port_num):
|
||||
sfp_modabs_path = '/sys/devices/platform/e1031.smc/SFP/sfp_modabs'
|
||||
|
||||
|
@ -139,7 +136,7 @@ class SfpUtil(SfpUtilBase):
|
|||
with open(modabs_interrupt_path, 'r') as port_changes:
|
||||
changes = int(port_changes.read(), 16)
|
||||
for port_num in self._sfp_port:
|
||||
change = (changes >> ( port_num - 49)) & 1
|
||||
change = (changes >> (port_num - 49)) & 1
|
||||
if change == 1:
|
||||
port_dict[str(port_num)] = str(int(self.get_presence(port_num)))
|
||||
found_flag = 1
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica
|
||||
#
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica
|
||||
#
|
||||
|
@ -43,7 +41,7 @@ class Component(ComponentBase):
|
|||
# Run bash command and print output to stdout
|
||||
try:
|
||||
process = subprocess.Popen(
|
||||
shlex.split(command), stdout=subprocess.PIPE)
|
||||
shlex.split(command), universal_newlines=True, stdout=subprocess.PIPE)
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
if output == '' and process.poll() is not None:
|
||||
|
@ -68,7 +66,7 @@ class Component(ComponentBase):
|
|||
# Retrieves the cpld register value
|
||||
cmd = "echo {1} > {0}; cat {0}".format(GETREG_PATH, register)
|
||||
p = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
raw_data, err = p.communicate()
|
||||
if err is not '':
|
||||
return None
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica Haliburton
|
||||
#
|
||||
|
@ -13,13 +11,17 @@ try:
|
|||
import glob
|
||||
import os
|
||||
import sys
|
||||
import imp
|
||||
import re
|
||||
from array import array
|
||||
|
||||
if sys.version_info.major == 3:
|
||||
from io import StringIO
|
||||
else:
|
||||
from cStringIO import StringIO
|
||||
|
||||
from sonic_platform_base.sonic_eeprom import eeprom_dts
|
||||
from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
CACHE_ROOT = '/var/cache/sonic/decode-syseeprom'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica
|
||||
#
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica
|
||||
#
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica
|
||||
#
|
||||
|
@ -84,7 +82,7 @@ class Psu(PsuBase):
|
|||
if vout_label_path:
|
||||
dir_name = os.path.dirname(vout_label_path)
|
||||
basename = os.path.basename(vout_label_path)
|
||||
in_num = filter(str.isdigit, basename)
|
||||
in_num = list(filter(str.isdigit, basename))
|
||||
vout_path = os.path.join(
|
||||
dir_name, voltage_name.format(in_num))
|
||||
vout_val = self.__read_txt_file(vout_path)
|
||||
|
@ -107,7 +105,7 @@ class Psu(PsuBase):
|
|||
if curr_label_path:
|
||||
dir_name = os.path.dirname(curr_label_path)
|
||||
basename = os.path.basename(curr_label_path)
|
||||
cur_num = filter(str.isdigit, basename)
|
||||
cur_num = list(filter(str.isdigit, basename))
|
||||
cur_path = os.path.join(
|
||||
dir_name, current_name.format(cur_num))
|
||||
cur_val = self.__read_txt_file(cur_path)
|
||||
|
@ -130,7 +128,7 @@ class Psu(PsuBase):
|
|||
if pw_label_path:
|
||||
dir_name = os.path.dirname(pw_label_path)
|
||||
basename = os.path.basename(pw_label_path)
|
||||
pw_num = filter(str.isdigit, basename)
|
||||
pw_num = list(filter(str.isdigit, basename))
|
||||
pw_path = os.path.join(
|
||||
dir_name, current_name.format(pw_num))
|
||||
pw_val = self.__read_txt_file(pw_path)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Celestica
|
||||
#
|
||||
|
@ -81,7 +79,7 @@ class Sfp(SfpBase):
|
|||
51: 17,
|
||||
52: 16
|
||||
}
|
||||
_sfp_port = range(49, PORT_END + 1)
|
||||
_sfp_port = list(range(49, PORT_END + 1))
|
||||
PRS_PATH = "/sys/devices/platform/e1031.smc/SFP/sfp_modabs"
|
||||
PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
|
||||
PMON_HWSKU_PATH = '/usr/share/sonic/hwsku'
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче