[PDDF] Build and install Python 3 package (#6286)
- Make PDDF code compliant with both Python 2 and Python 3 - Align code with PEP8 standards using autopep8 - Build and install both Python 2 and Python 3 PDDF packages
This commit is contained in:
parent
0ad2098402
commit
e52581e919
@ -275,7 +275,6 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
|
||||
ntpstat \
|
||||
openssh-server \
|
||||
python \
|
||||
python-jsonschema \
|
||||
python-apt \
|
||||
traceroute \
|
||||
iputils-ping \
|
||||
|
@ -23,13 +23,13 @@ RUN apt-get update && \
|
||||
python-smbus \
|
||||
ethtool \
|
||||
dmidecode \
|
||||
i2c-tools \
|
||||
python-jsonschema
|
||||
i2c-tools
|
||||
|
||||
# TODO: Remove these lines once we no longer need Python 2
|
||||
RUN apt-get install -f -y python-dev python-pip
|
||||
RUN pip2 install --upgrade 'pip<21'
|
||||
RUN apt-get purge -y python-pip
|
||||
RUN pip2 install 'setuptools==40.8.0'
|
||||
|
||||
# On Arista devices, the sonic_platform wheel is not installed in the container.
|
||||
# Instead, the installation directory is mounted from the host OS. However, this method
|
||||
|
@ -193,19 +193,25 @@ sudo cp {{platform_common_py2_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2
|
||||
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip2 install $PLATFORM_COMMON_PY2_WHEEL_NAME
|
||||
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME
|
||||
|
||||
# Install sonic-platform-common Python 3 package
|
||||
PLATFORM_COMMON_PY3_WHEEL_NAME=$(basename {{platform_common_py3_wheel_path}})
|
||||
sudo cp {{platform_common_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||
|
||||
{% if pddf_support == "y" %}
|
||||
# Install pddf-platform-api-base Python 2 package
|
||||
PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME=$(basename {{pddf_platform_api_base_py2_wheel_path}})
|
||||
sudo cp {{pddf_platform_api_base_py2_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME
|
||||
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip2 install $PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME
|
||||
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME
|
||||
{% endif %}
|
||||
|
||||
# Install sonic-platform-common Python 3 package
|
||||
PLATFORM_COMMON_PY3_WHEEL_NAME=$(basename {{platform_common_py3_wheel_path}})
|
||||
sudo cp {{platform_common_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
|
||||
# Install pddf-platform-api-base Python 3 package
|
||||
PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME=$(basename {{pddf_platform_api_base_py3_wheel_path}})
|
||||
sudo cp {{pddf_platform_api_base_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME
|
||||
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME
|
||||
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME
|
||||
{% endif %}
|
||||
|
||||
{# Barefoot platform vendors' sonic_platform packages import the Python 'thrift' library #}
|
||||
{% if sonic_asic_platform == "barefoot" %}
|
||||
|
@ -7,3 +7,7 @@ DEP_FILES += $(shell git ls-files $(MPATH))
|
||||
$(PDDF_PLATFORM_API_BASE_PY2)_CACHE_MODE := GIT_CONTENT_SHA
|
||||
$(PDDF_PLATFORM_API_BASE_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
|
||||
$(PDDF_PLATFORM_API_BASE_PY2)_DEP_FILES := $(DEP_FILES)
|
||||
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_CACHE_MODE := GIT_CONTENT_SHA
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_DEP_FILES := $(DEP_FILES)
|
||||
|
@ -13,3 +13,16 @@ SONIC_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY2)
|
||||
|
||||
export pddf_platform_api_base_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY2))"
|
||||
export PDDF_PLATFORM_API_BASE_PY2
|
||||
|
||||
PDDF_PLATFORM_API_BASE_PY3 = sonic_platform_pddf_common-$(PDDF_PLATFORM_API_BASE_VERSION)-py3-none-any.whl
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_SRC_PATH = $(PLATFORM_PDDF_PATH)/platform-api-pddf-base
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_PYTHON_VERSION = 3
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_DEPENDS = $(SONIC_CONFIG_ENGINE)
|
||||
# Synthetic dependency to avoid building the Python 2 and 3 packages
|
||||
# simultaneously and any potential conflicts which may arise
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_DEPENDS += $(PDDF_PLATFORM_API_BASE_PY2)
|
||||
$(PDDF_PLATFORM_API_BASE_PY3)_TEST = n
|
||||
SONIC_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY3)
|
||||
|
||||
export pddf_platform_api_base_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY3))"
|
||||
export PDDF_PLATFORM_API_BASE_PY3
|
||||
|
@ -14,6 +14,9 @@ setup(
|
||||
packages=[
|
||||
'sonic_platform_pddf_base',
|
||||
],
|
||||
install_requires=[
|
||||
'jsonschema==2.6.0'
|
||||
],
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: Plugins',
|
||||
@ -24,6 +27,7 @@ setup(
|
||||
'Natural Language :: English',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Topic :: Utilities',
|
||||
],
|
||||
keywords='sonic SONiC platform PLATFORM',
|
||||
|
@ -18,6 +18,7 @@ try:
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PddfChassis(ChassisBase):
|
||||
"""
|
||||
PDDF Generic Chassis class
|
||||
@ -33,7 +34,7 @@ class PddfChassis(ChassisBase):
|
||||
self.plugin_data = pddf_plugin_data if pddf_plugin_data else None
|
||||
if not self.pddf_obj or not self.plugin_data:
|
||||
try:
|
||||
import pddfparse
|
||||
from . import pddfparse
|
||||
import json
|
||||
self.pddf_obj = pddfparse.PddfParse()
|
||||
with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd:
|
||||
@ -67,8 +68,8 @@ class PddfChassis(ChassisBase):
|
||||
thermal = Thermal(i, self.pddf_obj, self.plugin_data)
|
||||
self._thermal_list.append(thermal)
|
||||
|
||||
# SYSTEM LED Test Cases
|
||||
"""
|
||||
# SYSTEM LED Test Cases
|
||||
"""
|
||||
#comment out test cases
|
||||
sys_led_list= { "LOC":0,
|
||||
"DIAG":0,
|
||||
@ -90,8 +91,6 @@ class PddfChassis(ChassisBase):
|
||||
print "Set off: " + color
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the chassis
|
||||
@ -438,34 +437,32 @@ class PddfChassis(ChassisBase):
|
||||
# System LED methods
|
||||
##############################################
|
||||
def set_system_led(self, led_device_name, color):
|
||||
result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color);
|
||||
result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color)
|
||||
if result == False:
|
||||
print msg
|
||||
return (False)
|
||||
print(msg)
|
||||
return (False)
|
||||
|
||||
index=self.pddf_obj.data[led_device_name]['dev_attr']['index']
|
||||
device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
index = self.pddf_obj.data[led_device_name]['dev_attr']['index']
|
||||
device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path())
|
||||
self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path())
|
||||
return (True)
|
||||
|
||||
|
||||
def get_system_led(self, led_device_name):
|
||||
if (not led_device_name in self.pddf_obj.data.keys()):
|
||||
status= "[FAILED] " + led_device_name + " is not configured"
|
||||
return (status)
|
||||
if led_device_name not in self.pddf_obj.data.keys():
|
||||
status = "[FAILED] " + led_device_name + " is not configured"
|
||||
return (status)
|
||||
|
||||
index=self.pddf_obj.data[led_device_name]['dev_attr']['index']
|
||||
device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
index = self.pddf_obj.data[led_device_name]['dev_attr']['index']
|
||||
device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path())
|
||||
color=self.pddf_obj.get_led_color()
|
||||
color = self.pddf_obj.get_led_color()
|
||||
return (color)
|
||||
|
||||
|
||||
##############################################
|
||||
# Other methods
|
||||
##############################################
|
||||
@ -513,4 +510,3 @@ class PddfChassis(ChassisBase):
|
||||
has been inserted and sfp 11 has been removed.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
@ -67,47 +67,41 @@ class PddfEeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
tlv_index += ord(eeprom[tlv_index+1]) + 2
|
||||
|
||||
def serial_number_str(self):
|
||||
(is_valid, results) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_SERIAL_NUMBER)
|
||||
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_SERIAL_NUMBER)
|
||||
if not is_valid:
|
||||
return "N/A"
|
||||
return results[2]
|
||||
|
||||
def base_mac_addr(self):
|
||||
(is_valid, t) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_MAC_BASE)
|
||||
(is_valid, t) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_MAC_BASE)
|
||||
if not is_valid or t[1] != 6:
|
||||
return super(TlvInfoDecoder, self).switchaddrstr(e)
|
||||
|
||||
return ":".join([binascii.b2a_hex(T) for T in t[2]])
|
||||
|
||||
def modelstr(self):
|
||||
(is_valid, results) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_PRODUCT_NAME)
|
||||
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_PRODUCT_NAME)
|
||||
if not is_valid:
|
||||
return "N/A"
|
||||
|
||||
return results[2]
|
||||
|
||||
def part_number_str(self):
|
||||
(is_valid, results) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_PART_NUMBER)
|
||||
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_PART_NUMBER)
|
||||
if not is_valid:
|
||||
return "N/A"
|
||||
|
||||
return results[2]
|
||||
|
||||
def serial_str(self):
|
||||
(is_valid, results) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_SERVICE_TAG)
|
||||
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_SERVICE_TAG)
|
||||
if not is_valid:
|
||||
return "N/A"
|
||||
|
||||
return results[2]
|
||||
|
||||
def revision_str(self):
|
||||
(is_valid, results) = self.get_tlv_field(
|
||||
self.eeprom_data, self._TLV_CODE_DEVICE_VERSION)
|
||||
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_DEVICE_VERSION)
|
||||
if not is_valid:
|
||||
return "N/A"
|
||||
|
||||
|
@ -22,7 +22,7 @@ class PddfFan(FanBase):
|
||||
plugin_data = {}
|
||||
|
||||
def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0):
|
||||
# idx is 0-based
|
||||
# idx is 0-based
|
||||
if not pddf_data or not pddf_plugin_data:
|
||||
raise ValueError('PDDF JSON data error')
|
||||
|
||||
@ -30,12 +30,12 @@ class PddfFan(FanBase):
|
||||
self.plugin_data = pddf_plugin_data
|
||||
self.platform = self.pddf_obj.get_platform()
|
||||
|
||||
if tray_idx<0 or tray_idx>=self.platform['num_fantrays']:
|
||||
print "Invalid fantray index %d\n"%tray_idx
|
||||
if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']:
|
||||
print("Invalid fantray index %d\n" % tray_idx)
|
||||
return
|
||||
|
||||
if fan_idx<0 or fan_idx>=self.platform['num_fans_pertray']:
|
||||
print "Invalid fan index (within a tray) %d\n"%fan_idx
|
||||
|
||||
if fan_idx < 0 or fan_idx >= self.platform['num_fans_pertray']:
|
||||
print("Invalid fan index (within a tray) %d\n" % fan_idx)
|
||||
return
|
||||
|
||||
self.fantray_index = tray_idx+1
|
||||
@ -160,7 +160,7 @@ class PddfFan(FanBase):
|
||||
|
||||
if not output:
|
||||
return 0
|
||||
|
||||
|
||||
output['status'] = output['status'].rstrip()
|
||||
if output['status'].isalpha():
|
||||
return 0
|
||||
@ -185,7 +185,7 @@ class PddfFan(FanBase):
|
||||
output = self.pddf_obj.get_attr_name_output(device, attr)
|
||||
if not output:
|
||||
return 0
|
||||
|
||||
|
||||
output['status'] = output['status'].rstrip()
|
||||
if output['status'].isalpha():
|
||||
return 0
|
||||
@ -229,7 +229,7 @@ class PddfFan(FanBase):
|
||||
|
||||
if not output:
|
||||
return 0
|
||||
|
||||
|
||||
output['status'] = output['status'].rstrip()
|
||||
if output['status'].isalpha():
|
||||
return 0
|
||||
@ -250,7 +250,7 @@ class PddfFan(FanBase):
|
||||
An integer, the percentage of variance from target speed which is
|
||||
considered tolerable
|
||||
"""
|
||||
# Fix the speed vairance to 10 percent. If it changes based on platforms, overwrite
|
||||
# Fix the speed vairance to 10 percent. If it changes based on platforms, overwrite
|
||||
# this value in derived pddf fan class
|
||||
return 10
|
||||
|
||||
@ -266,28 +266,27 @@ class PddfFan(FanBase):
|
||||
A boolean, True if speed is set successfully, False if not
|
||||
"""
|
||||
if self.is_psu_fan:
|
||||
print "Setting PSU fan speed is not allowed"
|
||||
print("Setting PSU fan speed is not allowed")
|
||||
return False
|
||||
else:
|
||||
if speed<0 or speed>100:
|
||||
print "Error: Invalid speed %d. Please provide a valid speed percentage"%speed
|
||||
if speed < 0 or speed > 100:
|
||||
print("Error: Invalid speed %d. Please provide a valid speed percentage" % speed)
|
||||
return False
|
||||
|
||||
if 'duty_cycle_to_pwm' not in self.plugin_data['FAN']:
|
||||
print "Setting fan speed is not allowed !"
|
||||
print("Setting fan speed is not allowed !")
|
||||
return False
|
||||
else:
|
||||
duty_cycle_to_pwm = eval(self.plugin_data['FAN']['duty_cycle_to_pwm'])
|
||||
pwm = int(round(duty_cycle_to_pwm(speed)))
|
||||
|
||||
|
||||
status = False
|
||||
idx = (self.fantray_index-1)*self.platform['num_fans_pertray'] + self.fan_index
|
||||
attr = "fan" + str(idx) + "_pwm"
|
||||
output = self.pddf_obj.set_attr_name_output("FAN-CTRL", attr, pwm)
|
||||
if not output:
|
||||
return False
|
||||
|
||||
|
||||
status = output['status']
|
||||
|
||||
return status
|
||||
@ -296,36 +295,34 @@ class PddfFan(FanBase):
|
||||
index = str(self.fantray_index-1)
|
||||
led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED"
|
||||
|
||||
result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color);
|
||||
result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color)
|
||||
if result == False:
|
||||
print msg
|
||||
return (False)
|
||||
print(msg)
|
||||
return (False)
|
||||
|
||||
|
||||
device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path())
|
||||
self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path())
|
||||
return (True)
|
||||
|
||||
|
||||
def get_status_led(self):
|
||||
index = str(self.fantray_index-1)
|
||||
fan_led_device = "FANTRAY{}".format(self.fantray_index) + "_LED"
|
||||
|
||||
if (not fan_led_device in self.pddf_obj.data.keys()):
|
||||
if fan_led_device not in self.pddf_obj.data.keys():
|
||||
# Implement a generic status_led color scheme
|
||||
if self.get_status():
|
||||
return self.STATUS_LED_COLOR_GREEN
|
||||
else:
|
||||
return self.STATUS_LED_COLOR_OFF
|
||||
|
||||
device_name=self.pddf_obj.data[fan_led_device]['dev_info']['device_name']
|
||||
device_name = self.pddf_obj.data[fan_led_device]['dev_info']['device_name']
|
||||
self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path())
|
||||
color=self.pddf_obj.get_led_color()
|
||||
color = self.pddf_obj.get_led_color()
|
||||
return (color)
|
||||
|
||||
def dump_sysfs(self):
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
try:
|
||||
import json
|
||||
import pddfparse
|
||||
from . import pddfparse
|
||||
from sonic_platform_base.platform_base import PlatformBase
|
||||
from sonic_platform.chassis import Chassis
|
||||
except ImportError as e:
|
||||
@ -23,6 +23,7 @@ class PddfPlatform(PlatformBase):
|
||||
"""
|
||||
pddf_data = {}
|
||||
pddf_plugin_data = {}
|
||||
|
||||
def __init__(self):
|
||||
# Initialize the JSON data
|
||||
self.pddf_data = pddfparse.PddfParse()
|
||||
@ -30,7 +31,7 @@ class PddfPlatform(PlatformBase):
|
||||
self.pddf_plugin_data = json.load(pd)
|
||||
|
||||
if not self.pddf_data or not self.pddf_plugin_data:
|
||||
print "Error: PDDF JSON data is not loaded properly ... Exiting"
|
||||
print("Error: PDDF JSON data is not loaded properly ... Exiting")
|
||||
raise ValueError
|
||||
|
||||
PlatformBase.__init__(self)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# All the supported PSU SysFS aattributes are
|
||||
# All the supported PSU SysFS aattributes are
|
||||
#- psu_present
|
||||
#- psu_model_name
|
||||
#- psu_power_good
|
||||
@ -18,7 +18,7 @@ try:
|
||||
from sonic_platform_base.psu_base import PsuBase
|
||||
from sonic_platform.fan import Fan
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class PddfPsu(PsuBase):
|
||||
@ -27,7 +27,6 @@ class PddfPsu(PsuBase):
|
||||
pddf_obj = {}
|
||||
plugin_data = {}
|
||||
|
||||
|
||||
def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
|
||||
PsuBase.__init__(self)
|
||||
if not pddf_data or not pddf_plugin_data:
|
||||
@ -37,7 +36,7 @@ class PddfPsu(PsuBase):
|
||||
self.plugin_data = pddf_plugin_data
|
||||
self.platform = self.pddf_obj.get_platform()
|
||||
self.psu_index = index + 1
|
||||
|
||||
|
||||
self._fan_list = [] # _fan_list under PsuBase class is a global variable, hence we need to use _fan_list per class instatiation
|
||||
self.num_psu_fans = int(self.pddf_obj.get_num_psu_fans('PSU{}'.format(index+1)))
|
||||
for psu_fan_idx in range(self.num_psu_fans):
|
||||
@ -75,11 +74,11 @@ class PddfPsu(PsuBase):
|
||||
status = 0
|
||||
device = "PSU{}".format(self.psu_index)
|
||||
output = self.pddf_obj.get_attr_name_output(device, "psu_present")
|
||||
if not output:
|
||||
return False
|
||||
if not output:
|
||||
return False
|
||||
|
||||
mode = output['mode']
|
||||
status = output['status']
|
||||
status = output['status']
|
||||
|
||||
vmap = self.plugin_data['PSU']['psu_present'][mode]['valmap']
|
||||
|
||||
@ -98,7 +97,7 @@ class PddfPsu(PsuBase):
|
||||
device = "PSU{}".format(self.psu_index)
|
||||
output = self.pddf_obj.get_attr_name_output(device, "psu_model_name")
|
||||
if not output:
|
||||
return None
|
||||
return None
|
||||
|
||||
model = output['status']
|
||||
|
||||
@ -118,7 +117,7 @@ class PddfPsu(PsuBase):
|
||||
device = "PSU{}".format(self.psu_index)
|
||||
output = self.pddf_obj.get_attr_name_output(device, "psu_serial_num")
|
||||
if not output:
|
||||
return None
|
||||
return None
|
||||
|
||||
serial = output['status']
|
||||
|
||||
@ -138,7 +137,7 @@ class PddfPsu(PsuBase):
|
||||
return False
|
||||
|
||||
mode = output['mode']
|
||||
status = output ['status']
|
||||
status = output['status']
|
||||
|
||||
vmap = self.plugin_data['PSU']['psu_power_good'][mode]['valmap']
|
||||
|
||||
@ -157,9 +156,9 @@ class PddfPsu(PsuBase):
|
||||
device = "PSU{}".format(self.psu_index)
|
||||
output = self.pddf_obj.get_attr_name_output(device, "psu_mfr_id")
|
||||
if not output:
|
||||
return None
|
||||
return None
|
||||
|
||||
mfr = output['status']
|
||||
mfr = output['status']
|
||||
|
||||
return mfr.rstrip('\n')
|
||||
|
||||
@ -171,11 +170,11 @@ class PddfPsu(PsuBase):
|
||||
A float number, the output voltage in volts,
|
||||
e.g. 12.1
|
||||
"""
|
||||
device = "PSU{}".format(self.psu_index)
|
||||
device = "PSU{}".format(self.psu_index)
|
||||
output = self.pddf_obj.get_attr_name_output(device, "psu_v_out")
|
||||
if not output:
|
||||
return 0.0
|
||||
|
||||
|
||||
v_out = output['status']
|
||||
|
||||
return float(v_out)/1000
|
||||
@ -230,12 +229,12 @@ class PddfPsu(PsuBase):
|
||||
index = str(self.psu_index-1)
|
||||
led_device_name = "PSU{}".format(self.psu_index) + "_LED"
|
||||
|
||||
result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color);
|
||||
result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color)
|
||||
if result == False:
|
||||
print msg
|
||||
return (False)
|
||||
print(msg)
|
||||
return (False)
|
||||
|
||||
device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name']
|
||||
self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path())
|
||||
@ -245,18 +244,18 @@ class PddfPsu(PsuBase):
|
||||
def get_status_led(self):
|
||||
index = str(self.psu_index-1)
|
||||
psu_led_device = "PSU{}_LED".format(self.psu_index)
|
||||
if (not psu_led_device in self.pddf_obj.data.keys()):
|
||||
if psu_led_device not in self.pddf_obj.data.keys():
|
||||
# Implement a generic status_led color scheme
|
||||
if self.get_powergood_status():
|
||||
return self.STATUS_LED_COLOR_GREEN
|
||||
else:
|
||||
return self.STATUS_LED_COLOR_OFF
|
||||
|
||||
device_name=self.pddf_obj.data[psu_led_device]['dev_info']['device_name']
|
||||
device_name = self.pddf_obj.data[psu_led_device]['dev_info']['device_name']
|
||||
self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path())
|
||||
self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path())
|
||||
color=self.pddf_obj.get_led_color()
|
||||
color = self.pddf_obj.get_led_color()
|
||||
return (color)
|
||||
|
||||
def get_input_voltage(self):
|
||||
|
@ -10,8 +10,8 @@ try:
|
||||
from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom
|
||||
from sonic_platform_base.sonic_sfp.sff8472 import sffbase
|
||||
from sonic_platform_base.sonic_sfp.inf8628 import inf8628InterfaceId
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
# definitions of the offset and width for values in XCVR info eeprom
|
||||
XCVR_INTFACE_BULK_OFFSET = 0
|
||||
@ -58,7 +58,7 @@ OSFP_VENDOR_PN_OFFSET = 148
|
||||
OSFP_HW_REV_OFFSET = 164
|
||||
OSFP_VENDOR_SN_OFFSET = 166
|
||||
|
||||
#definitions of the offset and width for values in DOM info eeprom
|
||||
# definitions of the offset and width for values in DOM info eeprom
|
||||
QSFP_DOM_REV_OFFSET = 1
|
||||
QSFP_DOM_REV_WIDTH = 1
|
||||
QSFP_TEMPE_OFFSET = 22
|
||||
@ -107,10 +107,10 @@ sfp_cable_length_tup = ('LengthSMFkm-UnitsOfKm', 'LengthSMF(UnitsOf100m)',
|
||||
'LengthCable(UnitsOfm)', 'LengthOM3(UnitsOf10m)')
|
||||
|
||||
sfp_compliance_code_tup = ('10GEthernetComplianceCode', 'InfinibandComplianceCode',
|
||||
'ESCONComplianceCodes', 'SONETComplianceCodes',
|
||||
'EthernetComplianceCodes','FibreChannelLinkLength',
|
||||
'FibreChannelTechnology', 'SFP+CableTechnology',
|
||||
'FibreChannelTransmissionMedia','FibreChannelSpeed')
|
||||
'ESCONComplianceCodes', 'SONETComplianceCodes',
|
||||
'EthernetComplianceCodes', 'FibreChannelLinkLength',
|
||||
'FibreChannelTechnology', 'SFP+CableTechnology',
|
||||
'FibreChannelTransmissionMedia', 'FibreChannelSpeed')
|
||||
|
||||
qsfp_compliance_code_tup = ('10/40G Ethernet Compliance Code', 'SONET Compliance codes',
|
||||
'SAS/SATA compliance codes', 'Gigabit Ethernet Compliant codes',
|
||||
@ -126,6 +126,7 @@ INFO_OFFSET = 128
|
||||
DOM_OFFSET = 0
|
||||
DOM_OFFSET1 = 384
|
||||
|
||||
|
||||
class PddfSfp(SfpBase):
|
||||
"""
|
||||
PDDF generic Sfp class
|
||||
@ -154,7 +155,7 @@ class PddfSfp(SfpBase):
|
||||
for n in range(0, num_bytes):
|
||||
eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2)
|
||||
except Exception as e:
|
||||
print "Error: Unable to open eeprom_path: %s"%(str(e))
|
||||
print("Error: Unable to open eeprom_path: %s" % (str(e)))
|
||||
finally:
|
||||
if sysfsfile_eeprom:
|
||||
sysfsfile_eeprom.close()
|
||||
@ -174,29 +175,29 @@ class PddfSfp(SfpBase):
|
||||
self._port_start = 0
|
||||
self._port_end = int(self.platform['num_ports'])
|
||||
if index < self._port_start or index >= self._port_end:
|
||||
print "Invalid port index %d"%index
|
||||
return
|
||||
print("Invalid port index %d" % index)
|
||||
return
|
||||
|
||||
self.port_index = index+1
|
||||
self.device = 'PORT{}'.format(self.port_index)
|
||||
self.sfp_type = self.pddf_obj.get_device_type(self.device)
|
||||
self.is_qsfp_port = True if (self.sfp_type=='QSFP' or self.sfp_type=='QSFP28') else False
|
||||
self.is_osfp_port = True if (self.sfp_type=='OSFP' or self.sfp_type=='QSFP-DD') else False
|
||||
self.is_qsfp_port = True if (self.sfp_type == 'QSFP' or self.sfp_type == 'QSFP28') else False
|
||||
self.is_osfp_port = True if (self.sfp_type == 'OSFP' or self.sfp_type == 'QSFP-DD') else False
|
||||
self.eeprom_path = self.pddf_obj.get_path(self.device, 'eeprom')
|
||||
|
||||
self.info_dict_keys = ['type', 'hardware_rev', 'serial', 'manufacturer', 'model', 'connector', 'encoding',
|
||||
'ext_identifier', 'ext_rateselect_compliance', 'cable_type', 'cable_length', 'nominal_bit_rate',
|
||||
'specification_compliance', 'vendor_date', 'vendor_oui', 'application_advertisement']
|
||||
self.info_dict_keys = ['type', 'hardware_rev', 'serial', 'manufacturer', 'model', 'connector', 'encoding',
|
||||
'ext_identifier', 'ext_rateselect_compliance', 'cable_type', 'cable_length', 'nominal_bit_rate',
|
||||
'specification_compliance', 'vendor_date', 'vendor_oui', 'application_advertisement']
|
||||
|
||||
self.dom_dict_keys = ['rx_los', 'tx_fault', 'reset_status', 'power_lpmode', 'tx_disable', 'tx_disable_channel',
|
||||
'temperature', 'voltage', 'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias',
|
||||
'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power']
|
||||
'temperature', 'voltage', 'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias',
|
||||
'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power']
|
||||
|
||||
self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning',
|
||||
'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm',
|
||||
'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning',
|
||||
'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm',
|
||||
'txbiaslowwarning']
|
||||
self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning',
|
||||
'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm',
|
||||
'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning',
|
||||
'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm',
|
||||
'txbiaslowwarning']
|
||||
|
||||
SfpBase.__init__(self)
|
||||
|
||||
@ -226,9 +227,8 @@ class PddfSfp(SfpBase):
|
||||
========================================================================
|
||||
"""
|
||||
# check present status
|
||||
if not self.get_presence():
|
||||
return None
|
||||
|
||||
if not self.get_presence():
|
||||
return None
|
||||
|
||||
if self.is_osfp_port:
|
||||
sfpi_obj = inf8628InterfaceId()
|
||||
@ -267,7 +267,6 @@ class PddfSfp(SfpBase):
|
||||
|
||||
if sfpi_obj is None:
|
||||
return None
|
||||
|
||||
|
||||
if self.is_osfp_port:
|
||||
sfp_type_raw = self.__read_eeprom_specific_bytes((offset + type_offset), XCVR_TYPE_WIDTH)
|
||||
@ -275,19 +274,21 @@ class PddfSfp(SfpBase):
|
||||
sfp_type_data = sfpi_obj.parse_sfp_type(sfp_type_raw, 0)
|
||||
sfp_type_abbrv_name = sfpi_obj.parse_sfp_type_abbrv_name(sfp_typ_raw, 0)
|
||||
else:
|
||||
sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes((offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width)
|
||||
sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes(
|
||||
(offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width)
|
||||
if sfp_interface_bulk_raw is not None:
|
||||
sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw, 0)
|
||||
|
||||
sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes((offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH)
|
||||
sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes(
|
||||
(offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH)
|
||||
if sfp_vendor_oui_raw is not None:
|
||||
sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui(sfp_vendor_oui_raw, 0)
|
||||
|
||||
sfp_vendor_date_raw = self.__read_eeprom_specific_bytes((offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH)
|
||||
sfp_vendor_date_raw = self.__read_eeprom_specific_bytes(
|
||||
(offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH)
|
||||
if sfp_vendor_date_raw is not None:
|
||||
sfp_vendor_date_data = sfpi_obj.parse_vendor_date(sfp_vendor_date_raw, 0)
|
||||
|
||||
|
||||
sfp_vendor_name_raw = self.__read_eeprom_specific_bytes(
|
||||
(offset + vendor_name_offset), XCVR_VENDOR_NAME_WIDTH)
|
||||
sfp_vendor_name_data = sfpi_obj.parse_vendor_name(
|
||||
@ -327,7 +328,8 @@ class PddfSfp(SfpBase):
|
||||
xcvr_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A'
|
||||
xcvr_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A'
|
||||
xcvr_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A'
|
||||
xcvr_info_dict['vendor_date'] = sfp_vendor_date_data['data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A'
|
||||
xcvr_info_dict['vendor_date'] = sfp_vendor_date_data['data'][
|
||||
'VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A'
|
||||
xcvr_info_dict['cable_type'] = "Unknown"
|
||||
xcvr_info_dict['cable_length'] = "Unknown"
|
||||
|
||||
@ -342,9 +344,10 @@ class PddfSfp(SfpBase):
|
||||
compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value']
|
||||
xcvr_info_dict['specification_compliance'] = str(compliance_code_dict)
|
||||
|
||||
nkey='Nominal Bit Rate(100Mbs)'
|
||||
nkey = 'Nominal Bit Rate(100Mbs)'
|
||||
if nkey in sfp_interface_bulk_data['data']:
|
||||
xcvr_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value'])
|
||||
xcvr_info_dict['nominal_bit_rate'] = str(
|
||||
sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value'])
|
||||
else:
|
||||
xcvr_info_dict['nominal_bit_rate'] = 'N/A'
|
||||
elif sfp_type == 'OSFP':
|
||||
@ -360,7 +363,8 @@ class PddfSfp(SfpBase):
|
||||
compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value']
|
||||
xcvr_info_dict['specification_compliance'] = str(compliance_code_dict)
|
||||
|
||||
xcvr_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value'])
|
||||
xcvr_info_dict['nominal_bit_rate'] = str(
|
||||
sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value'])
|
||||
|
||||
return xcvr_info_dict
|
||||
|
||||
@ -419,19 +423,19 @@ class PddfSfp(SfpBase):
|
||||
else:
|
||||
return None
|
||||
|
||||
dom_temperature_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH)
|
||||
dom_temperature_raw = self.__read_eeprom_specific_bytes((offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH)
|
||||
if dom_temperature_raw is not None:
|
||||
dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0)
|
||||
else:
|
||||
return None
|
||||
|
||||
dom_voltage_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH)
|
||||
dom_voltage_raw = self.__read_eeprom_specific_bytes((offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH)
|
||||
if dom_voltage_raw is not None:
|
||||
dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
|
||||
else:
|
||||
return None
|
||||
|
||||
qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH)
|
||||
qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes((offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH)
|
||||
if qsfp_dom_rev_raw is not None:
|
||||
qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0)
|
||||
else:
|
||||
@ -446,7 +450,8 @@ class PddfSfp(SfpBase):
|
||||
qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value']
|
||||
qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['value']
|
||||
if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')):
|
||||
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH)
|
||||
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
|
||||
(offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH)
|
||||
if dom_channel_monitor_raw is not None:
|
||||
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
|
||||
else:
|
||||
@ -457,13 +462,14 @@ class PddfSfp(SfpBase):
|
||||
xcvr_dom_info_dict['tx3power'] = 'N/A'
|
||||
xcvr_dom_info_dict['tx4power'] = 'N/A'
|
||||
else:
|
||||
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH)
|
||||
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
|
||||
(offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH)
|
||||
if dom_channel_monitor_raw is not None:
|
||||
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0)
|
||||
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(
|
||||
dom_channel_monitor_raw, 0)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value']
|
||||
xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value']
|
||||
xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value']
|
||||
@ -489,19 +495,20 @@ class PddfSfp(SfpBase):
|
||||
if sfpd_obj is None:
|
||||
return None
|
||||
|
||||
dom_temperature_raw = self.__read_eeprom_specific_bytes( (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)
|
||||
dom_temperature_raw = self.__read_eeprom_specific_bytes((offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)
|
||||
if dom_temperature_raw is not None:
|
||||
dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0)
|
||||
else:
|
||||
return None
|
||||
|
||||
dom_voltage_raw = self.__read_eeprom_specific_bytes( (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH)
|
||||
dom_voltage_raw = self.__read_eeprom_specific_bytes((offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH)
|
||||
if dom_voltage_raw is not None:
|
||||
dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
|
||||
else:
|
||||
return None
|
||||
|
||||
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
|
||||
dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
|
||||
(offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
|
||||
if dom_channel_monitor_raw is not None:
|
||||
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
|
||||
else:
|
||||
@ -527,7 +534,6 @@ class PddfSfp(SfpBase):
|
||||
xcvr_dom_info_dict['reset_status'] = self.get_reset_status()
|
||||
xcvr_dom_info_dict['lp_mode'] = self.get_lpmode()
|
||||
|
||||
|
||||
return xcvr_dom_info_dict
|
||||
|
||||
def get_transceiver_threshold_info(self):
|
||||
@ -591,7 +597,8 @@ class PddfSfp(SfpBase):
|
||||
xcvr_dom_threshold_info_dict['vcchighwarning'] = module_threshold_data['VccHighWarning']['value']
|
||||
xcvr_dom_threshold_info_dict['vcclowwarning'] = module_threshold_data['VccLowWarning']['value']
|
||||
|
||||
dom_thres_raw = self.__read_eeprom_specific_bytes(QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH)
|
||||
dom_thres_raw = self.__read_eeprom_specific_bytes(
|
||||
QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH)
|
||||
if dom_thres_raw:
|
||||
channel_threshold_values = sfpd_obj.parse_channel_threshold_values(
|
||||
dom_thres_raw, 0)
|
||||
@ -647,8 +654,6 @@ class PddfSfp(SfpBase):
|
||||
xcvr_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value']
|
||||
xcvr_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value']
|
||||
|
||||
|
||||
|
||||
return xcvr_dom_threshold_info_dict
|
||||
|
||||
def get_reset_status(self):
|
||||
@ -668,7 +673,7 @@ class PddfSfp(SfpBase):
|
||||
|
||||
status = int(output['status'].rstrip())
|
||||
|
||||
if status==1:
|
||||
if status == 1:
|
||||
reset_status = True
|
||||
else:
|
||||
reset_status = False
|
||||
@ -715,13 +720,13 @@ class PddfSfp(SfpBase):
|
||||
else:
|
||||
status = int(output['status'].rstrip())
|
||||
|
||||
if status==1:
|
||||
if status == 1:
|
||||
rx_los = True
|
||||
else:
|
||||
rx_los = False
|
||||
|
||||
return rx_los
|
||||
|
||||
|
||||
def get_tx_fault(self):
|
||||
"""
|
||||
Retrieves the TX fault status of SFP
|
||||
@ -761,7 +766,7 @@ class PddfSfp(SfpBase):
|
||||
else:
|
||||
status = int(output['status'].rstrip())
|
||||
|
||||
if status==1:
|
||||
if status == 1:
|
||||
tx_fault = True
|
||||
else:
|
||||
tx_fault = False
|
||||
@ -821,7 +826,7 @@ class PddfSfp(SfpBase):
|
||||
else:
|
||||
status = int(output['status'].rstrip())
|
||||
|
||||
if status==1:
|
||||
if status == 1:
|
||||
tx_disable = True
|
||||
else:
|
||||
tx_disable = False
|
||||
@ -852,7 +857,7 @@ class PddfSfp(SfpBase):
|
||||
tx_disabled |= 1 << i
|
||||
return tx_disabled
|
||||
else:
|
||||
# SFP doesnt support this
|
||||
# SFP doesnt support this
|
||||
return 0
|
||||
|
||||
def get_lpmode(self):
|
||||
@ -884,13 +889,15 @@ class PddfSfp(SfpBase):
|
||||
status = ord(eeprom.read(1))
|
||||
|
||||
if ((status & 0x3) == 0x3):
|
||||
lpmode = True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
# Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
|
||||
lpmode = True
|
||||
else:
|
||||
lpmode = False # 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
|
||||
# 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
|
||||
lpmode = 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:
|
||||
@ -919,7 +926,6 @@ class PddfSfp(SfpBase):
|
||||
if not self.get_presence():
|
||||
return power_override
|
||||
|
||||
|
||||
if self.is_osfp_port:
|
||||
pass
|
||||
elif self.is_qsfp_port:
|
||||
@ -1032,7 +1038,7 @@ class PddfSfp(SfpBase):
|
||||
# TODO: Implement a wrapper set function to write the sequence
|
||||
path = self.pddf_obj.get_path(device, 'xcvr_reset')
|
||||
|
||||
# TODO: put the optic based reset logic using EEPROM
|
||||
# TODO: put the optic based reset logic using EEPROM
|
||||
if path is None:
|
||||
pass
|
||||
else:
|
||||
@ -1040,7 +1046,7 @@ class PddfSfp(SfpBase):
|
||||
f = open(path, 'r+')
|
||||
except IOError as e:
|
||||
return False
|
||||
|
||||
|
||||
try:
|
||||
f.seek(0)
|
||||
f.write('1')
|
||||
@ -1054,7 +1060,7 @@ class PddfSfp(SfpBase):
|
||||
status = False
|
||||
|
||||
return status
|
||||
|
||||
|
||||
def tx_disable(self, tx_disable):
|
||||
"""
|
||||
Disable SFP TX for all channels
|
||||
@ -1087,13 +1093,13 @@ class PddfSfp(SfpBase):
|
||||
eeprom_f.seek(QSFP_CONTROL_OFFSET)
|
||||
eeprom_f.write(buf[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_f is not None:
|
||||
eeprom_f.close()
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
status = True
|
||||
else:
|
||||
status_control_raw = self.__read_eeprom_specific_bytes(
|
||||
@ -1113,7 +1119,7 @@ class PddfSfp(SfpBase):
|
||||
eeprom_f.seek(SFP_STATUS_CONTROL_OFFSET)
|
||||
eeprom_f.write(buf[0])
|
||||
except Exception 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_f:
|
||||
@ -1168,7 +1174,7 @@ class PddfSfp(SfpBase):
|
||||
eeprom_f.seek(QSFP_CONTROL_OFFSET)
|
||||
eeprom_f.write(buf[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_f is not None:
|
||||
@ -1208,7 +1214,7 @@ class PddfSfp(SfpBase):
|
||||
return False
|
||||
|
||||
# Fill in write buffer
|
||||
regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode
|
||||
regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode
|
||||
buffer = create_string_buffer(1)
|
||||
buffer[0] = chr(regval)
|
||||
|
||||
@ -1218,7 +1224,7 @@ class PddfSfp(SfpBase):
|
||||
eeprom_f.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_f is not None:
|
||||
@ -1286,7 +1292,7 @@ class PddfSfp(SfpBase):
|
||||
eeprom_f.seek(QSFP_POWEROVERRIDE_OFFSET)
|
||||
eeprom_f.write(buffer[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_f is not None:
|
||||
@ -1298,14 +1304,13 @@ class PddfSfp(SfpBase):
|
||||
|
||||
return status
|
||||
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the device
|
||||
Returns:
|
||||
string: The name of the device
|
||||
"""
|
||||
# Name of the port/sfp ?
|
||||
# Name of the port/sfp ?
|
||||
return 'PORT{}'.format(self.port_index)
|
||||
|
||||
def get_presence(self):
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# All the supported Temperature Sensor SysFS aattributes are
|
||||
# All the supported Temperature Sensor SysFS aattributes are
|
||||
#- temp1_high_crit_threshold
|
||||
#- temp1_high_threshold
|
||||
#- temp1_input
|
||||
@ -13,7 +13,6 @@ except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
|
||||
class PddfThermal(ThermalBase):
|
||||
"""PDDF generic Thermal class"""
|
||||
pddf_obj = {}
|
||||
@ -37,24 +36,23 @@ class PddfThermal(ThermalBase):
|
||||
if 'display_name' in self.thermal_obj['dev_attr']:
|
||||
return str(self.thermal_obj['dev_attr']['display_name'])
|
||||
# In case of errors
|
||||
return (self.thermal_obj_name)
|
||||
return (self.thermal_obj_name)
|
||||
|
||||
def get_temperature(self):
|
||||
output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_input")
|
||||
if not output:
|
||||
return None
|
||||
return None
|
||||
|
||||
if output['status'].isalpha():
|
||||
attr_value = None
|
||||
else:
|
||||
attr_value = float(output['status'])
|
||||
|
||||
if output['mode']=='bmc':
|
||||
return attr_value
|
||||
|
||||
if output['mode'] == 'bmc':
|
||||
return attr_value
|
||||
else:
|
||||
return (attr_value/float(1000))
|
||||
|
||||
|
||||
def get_high_threshold(self):
|
||||
output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_high_threshold")
|
||||
if not output:
|
||||
@ -65,12 +63,11 @@ class PddfThermal(ThermalBase):
|
||||
else:
|
||||
attr_value = float(output['status'])
|
||||
|
||||
if output['mode']=='bmc':
|
||||
return attr_value
|
||||
if output['mode'] == 'bmc':
|
||||
return attr_value
|
||||
else:
|
||||
return (attr_value/float(1000))
|
||||
|
||||
|
||||
def get_low_threshold(self):
|
||||
output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_low_threshold")
|
||||
if not output:
|
||||
@ -80,31 +77,29 @@ class PddfThermal(ThermalBase):
|
||||
attr_value = None
|
||||
else:
|
||||
attr_value = float(output['status'])
|
||||
|
||||
if output['mode']=='bmc':
|
||||
return attr_value
|
||||
|
||||
if output['mode'] == 'bmc':
|
||||
return attr_value
|
||||
else:
|
||||
return (attr_value/float(1000))
|
||||
|
||||
|
||||
def set_high_threshold(self, temperature):
|
||||
node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_high_threshold")
|
||||
if node is None:
|
||||
print "ERROR %s does not exist"%node
|
||||
print("ERROR %s does not exist" % node)
|
||||
return None
|
||||
|
||||
cmd = "echo '%d' > %s"%(temperature * 1000, node)
|
||||
os.system(cmd)
|
||||
|
||||
cmd = "echo '%d' > %s" % (temperature * 1000, node)
|
||||
os.system(cmd)
|
||||
|
||||
return (True)
|
||||
|
||||
|
||||
def set_low_threshold(self, temperature):
|
||||
node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_low_threshold")
|
||||
if node is None:
|
||||
print "ERROR %s does not exist"%node
|
||||
print("ERROR %s does not exist" % node)
|
||||
return None
|
||||
cmd = "echo '%d' > %s"%(temperature * 1000, node)
|
||||
cmd = "echo '%d' > %s" % (temperature * 1000, node)
|
||||
os.system(cmd)
|
||||
|
||||
return (True)
|
||||
@ -126,12 +121,11 @@ class PddfThermal(ThermalBase):
|
||||
else:
|
||||
attr_value = float(output['status'])
|
||||
|
||||
if output['mode']=='bmc':
|
||||
if output['mode'] == 'bmc':
|
||||
return attr_value
|
||||
else:
|
||||
return (attr_value/float(1000))
|
||||
|
||||
|
||||
def get_low_critical_threshold(self):
|
||||
"""
|
||||
Retrieves the low critical threshold temperature of thermal
|
||||
@ -149,26 +143,25 @@ class PddfThermal(ThermalBase):
|
||||
else:
|
||||
attr_value = float(output['status'])
|
||||
|
||||
if output['mode']=='bmc':
|
||||
if output['mode'] == 'bmc':
|
||||
return attr_value
|
||||
else:
|
||||
return (attr_value/float(1000))
|
||||
|
||||
|
||||
# Helper Functions
|
||||
|
||||
def get_temp_label(self):
|
||||
if 'bmc' in self.pddf_obj.data[self.thermal_obj_name].keys():
|
||||
return None
|
||||
if 'bmc' in self.pddf_obj.data[self.thermal_obj_name].keys():
|
||||
return None
|
||||
else:
|
||||
if self.thermal_obj_name in self.pddf_obj.data.keys():
|
||||
dev= self.pddf_obj.data[self.thermal_obj_name]
|
||||
dev = self.pddf_obj.data[self.thermal_obj_name]
|
||||
topo_info = dev['i2c']['topo_info']
|
||||
label="%s-i2c-%d-%x" % (topo_info['dev_type'], int(topo_info['parent_bus'], 0),
|
||||
int(topo_info['dev_addr'], 0))
|
||||
return (label)
|
||||
label = "%s-i2c-%d-%x" % (topo_info['dev_type'], int(topo_info['parent_bus'], 0),
|
||||
int(topo_info['dev_addr'], 0))
|
||||
return (label)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def dump_sysfs(self):
|
||||
return self.pddf_obj.cli_dump_dsysfs('temp-sensors')
|
||||
|
File diff suppressed because it is too large
Load Diff
1
slave.mk
1
slave.mk
@ -872,6 +872,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
|
||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2)) \
|
||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_API_PY2)) \
|
||||
$(if $(findstring y,$(PDDF_SUPPORT)),$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY2))) \
|
||||
$(if $(findstring y,$(PDDF_SUPPORT)),$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY3))) \
|
||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_YANG_MODELS_PY3)) \
|
||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CTRMGRD)) \
|
||||
$(addprefix $(FILES_PATH)/,$($(SONIC_CTRMGRD)_FILES)) \
|
||||
|
Loading…
Reference in New Issue
Block a user