[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 \
|
ntpstat \
|
||||||
openssh-server \
|
openssh-server \
|
||||||
python \
|
python \
|
||||||
python-jsonschema \
|
|
||||||
python-apt \
|
python-apt \
|
||||||
traceroute \
|
traceroute \
|
||||||
iputils-ping \
|
iputils-ping \
|
||||||
|
@ -23,13 +23,13 @@ RUN apt-get update && \
|
|||||||
python-smbus \
|
python-smbus \
|
||||||
ethtool \
|
ethtool \
|
||||||
dmidecode \
|
dmidecode \
|
||||||
i2c-tools \
|
i2c-tools
|
||||||
python-jsonschema
|
|
||||||
|
|
||||||
# TODO: Remove these lines once we no longer need Python 2
|
# TODO: Remove these lines once we no longer need Python 2
|
||||||
RUN apt-get install -f -y python-dev python-pip
|
RUN apt-get install -f -y python-dev python-pip
|
||||||
RUN pip2 install --upgrade 'pip<21'
|
RUN pip2 install --upgrade 'pip<21'
|
||||||
RUN apt-get purge -y python-pip
|
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.
|
# 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
|
# 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 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
|
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" %}
|
{% if pddf_support == "y" %}
|
||||||
# Install pddf-platform-api-base Python 2 package
|
# Install pddf-platform-api-base Python 2 package
|
||||||
PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME=$(basename {{pddf_platform_api_base_py2_wheel_path}})
|
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 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 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
|
sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# Install sonic-platform-common Python 3 package
|
# Install pddf-platform-api-base Python 3 package
|
||||||
PLATFORM_COMMON_PY3_WHEEL_NAME=$(basename {{platform_common_py3_wheel_path}})
|
PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME=$(basename {{pddf_platform_api_base_py3_wheel_path}})
|
||||||
sudo cp {{platform_common_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME
|
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_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_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 #}
|
{# Barefoot platform vendors' sonic_platform packages import the Python 'thrift' library #}
|
||||||
{% if sonic_asic_platform == "barefoot" %}
|
{% 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)_CACHE_MODE := GIT_CONTENT_SHA
|
||||||
$(PDDF_PLATFORM_API_BASE_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
|
$(PDDF_PLATFORM_API_BASE_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
|
||||||
$(PDDF_PLATFORM_API_BASE_PY2)_DEP_FILES := $(DEP_FILES)
|
$(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_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY2))"
|
||||||
export 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=[
|
packages=[
|
||||||
'sonic_platform_pddf_base',
|
'sonic_platform_pddf_base',
|
||||||
],
|
],
|
||||||
|
install_requires=[
|
||||||
|
'jsonschema==2.6.0'
|
||||||
|
],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 3 - Alpha',
|
'Development Status :: 3 - Alpha',
|
||||||
'Environment :: Plugins',
|
'Environment :: Plugins',
|
||||||
@ -24,6 +27,7 @@ setup(
|
|||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Operating System :: POSIX :: Linux',
|
'Operating System :: POSIX :: Linux',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
'Topic :: Utilities',
|
'Topic :: Utilities',
|
||||||
],
|
],
|
||||||
keywords='sonic SONiC platform PLATFORM',
|
keywords='sonic SONiC platform PLATFORM',
|
||||||
|
@ -18,6 +18,7 @@ try:
|
|||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
class PddfChassis(ChassisBase):
|
class PddfChassis(ChassisBase):
|
||||||
"""
|
"""
|
||||||
PDDF Generic Chassis class
|
PDDF Generic Chassis class
|
||||||
@ -33,7 +34,7 @@ class PddfChassis(ChassisBase):
|
|||||||
self.plugin_data = pddf_plugin_data if pddf_plugin_data else None
|
self.plugin_data = pddf_plugin_data if pddf_plugin_data else None
|
||||||
if not self.pddf_obj or not self.plugin_data:
|
if not self.pddf_obj or not self.plugin_data:
|
||||||
try:
|
try:
|
||||||
import pddfparse
|
from . import pddfparse
|
||||||
import json
|
import json
|
||||||
self.pddf_obj = pddfparse.PddfParse()
|
self.pddf_obj = pddfparse.PddfParse()
|
||||||
with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd:
|
with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd:
|
||||||
@ -90,8 +91,6 @@ class PddfChassis(ChassisBase):
|
|||||||
print "Set off: " + color
|
print "Set off: " + color
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the name of the chassis
|
Retrieves the name of the chassis
|
||||||
@ -438,9 +437,9 @@ class PddfChassis(ChassisBase):
|
|||||||
# System LED methods
|
# System LED methods
|
||||||
##############################################
|
##############################################
|
||||||
def set_system_led(self, led_device_name, color):
|
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:
|
if result == False:
|
||||||
print msg
|
print(msg)
|
||||||
return (False)
|
return (False)
|
||||||
|
|
||||||
index = self.pddf_obj.data[led_device_name]['dev_attr']['index']
|
index = self.pddf_obj.data[led_device_name]['dev_attr']['index']
|
||||||
@ -451,9 +450,8 @@ class PddfChassis(ChassisBase):
|
|||||||
self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path())
|
self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path())
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
|
|
||||||
def get_system_led(self, led_device_name):
|
def get_system_led(self, led_device_name):
|
||||||
if (not led_device_name in self.pddf_obj.data.keys()):
|
if led_device_name not in self.pddf_obj.data.keys():
|
||||||
status = "[FAILED] " + led_device_name + " is not configured"
|
status = "[FAILED] " + led_device_name + " is not configured"
|
||||||
return (status)
|
return (status)
|
||||||
|
|
||||||
@ -465,7 +463,6 @@ class PddfChassis(ChassisBase):
|
|||||||
color = self.pddf_obj.get_led_color()
|
color = self.pddf_obj.get_led_color()
|
||||||
return (color)
|
return (color)
|
||||||
|
|
||||||
|
|
||||||
##############################################
|
##############################################
|
||||||
# Other methods
|
# Other methods
|
||||||
##############################################
|
##############################################
|
||||||
@ -513,4 +510,3 @@ class PddfChassis(ChassisBase):
|
|||||||
has been inserted and sfp 11 has been removed.
|
has been inserted and sfp 11 has been removed.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -67,47 +67,41 @@ class PddfEeprom(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
tlv_index += ord(eeprom[tlv_index+1]) + 2
|
tlv_index += ord(eeprom[tlv_index+1]) + 2
|
||||||
|
|
||||||
def serial_number_str(self):
|
def serial_number_str(self):
|
||||||
(is_valid, results) = self.get_tlv_field(
|
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_SERIAL_NUMBER)
|
||||||
self.eeprom_data, self._TLV_CODE_SERIAL_NUMBER)
|
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return "N/A"
|
return "N/A"
|
||||||
return results[2]
|
return results[2]
|
||||||
|
|
||||||
def base_mac_addr(self):
|
def base_mac_addr(self):
|
||||||
(is_valid, t) = self.get_tlv_field(
|
(is_valid, t) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_MAC_BASE)
|
||||||
self.eeprom_data, self._TLV_CODE_MAC_BASE)
|
|
||||||
if not is_valid or t[1] != 6:
|
if not is_valid or t[1] != 6:
|
||||||
return super(TlvInfoDecoder, self).switchaddrstr(e)
|
return super(TlvInfoDecoder, self).switchaddrstr(e)
|
||||||
|
|
||||||
return ":".join([binascii.b2a_hex(T) for T in t[2]])
|
return ":".join([binascii.b2a_hex(T) for T in t[2]])
|
||||||
|
|
||||||
def modelstr(self):
|
def modelstr(self):
|
||||||
(is_valid, results) = self.get_tlv_field(
|
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_PRODUCT_NAME)
|
||||||
self.eeprom_data, self._TLV_CODE_PRODUCT_NAME)
|
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return "N/A"
|
return "N/A"
|
||||||
|
|
||||||
return results[2]
|
return results[2]
|
||||||
|
|
||||||
def part_number_str(self):
|
def part_number_str(self):
|
||||||
(is_valid, results) = self.get_tlv_field(
|
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_PART_NUMBER)
|
||||||
self.eeprom_data, self._TLV_CODE_PART_NUMBER)
|
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return "N/A"
|
return "N/A"
|
||||||
|
|
||||||
return results[2]
|
return results[2]
|
||||||
|
|
||||||
def serial_str(self):
|
def serial_str(self):
|
||||||
(is_valid, results) = self.get_tlv_field(
|
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_SERVICE_TAG)
|
||||||
self.eeprom_data, self._TLV_CODE_SERVICE_TAG)
|
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return "N/A"
|
return "N/A"
|
||||||
|
|
||||||
return results[2]
|
return results[2]
|
||||||
|
|
||||||
def revision_str(self):
|
def revision_str(self):
|
||||||
(is_valid, results) = self.get_tlv_field(
|
(is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_DEVICE_VERSION)
|
||||||
self.eeprom_data, self._TLV_CODE_DEVICE_VERSION)
|
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return "N/A"
|
return "N/A"
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ class PddfFan(FanBase):
|
|||||||
self.platform = self.pddf_obj.get_platform()
|
self.platform = self.pddf_obj.get_platform()
|
||||||
|
|
||||||
if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']:
|
if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']:
|
||||||
print "Invalid fantray index %d\n"%tray_idx
|
print("Invalid fantray index %d\n" % tray_idx)
|
||||||
return
|
return
|
||||||
|
|
||||||
if fan_idx < 0 or fan_idx >= self.platform['num_fans_pertray']:
|
if fan_idx < 0 or fan_idx >= self.platform['num_fans_pertray']:
|
||||||
print "Invalid fan index (within a tray) %d\n"%fan_idx
|
print("Invalid fan index (within a tray) %d\n" % fan_idx)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.fantray_index = tray_idx+1
|
self.fantray_index = tray_idx+1
|
||||||
@ -266,21 +266,20 @@ class PddfFan(FanBase):
|
|||||||
A boolean, True if speed is set successfully, False if not
|
A boolean, True if speed is set successfully, False if not
|
||||||
"""
|
"""
|
||||||
if self.is_psu_fan:
|
if self.is_psu_fan:
|
||||||
print "Setting PSU fan speed is not allowed"
|
print("Setting PSU fan speed is not allowed")
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
if speed < 0 or speed > 100:
|
if speed < 0 or speed > 100:
|
||||||
print "Error: Invalid speed %d. Please provide a valid speed percentage"%speed
|
print("Error: Invalid speed %d. Please provide a valid speed percentage" % speed)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if 'duty_cycle_to_pwm' not in self.plugin_data['FAN']:
|
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
|
return False
|
||||||
else:
|
else:
|
||||||
duty_cycle_to_pwm = eval(self.plugin_data['FAN']['duty_cycle_to_pwm'])
|
duty_cycle_to_pwm = eval(self.plugin_data['FAN']['duty_cycle_to_pwm'])
|
||||||
pwm = int(round(duty_cycle_to_pwm(speed)))
|
pwm = int(round(duty_cycle_to_pwm(speed)))
|
||||||
|
|
||||||
|
|
||||||
status = False
|
status = False
|
||||||
idx = (self.fantray_index-1)*self.platform['num_fans_pertray'] + self.fan_index
|
idx = (self.fantray_index-1)*self.platform['num_fans_pertray'] + self.fan_index
|
||||||
attr = "fan" + str(idx) + "_pwm"
|
attr = "fan" + str(idx) + "_pwm"
|
||||||
@ -296,12 +295,11 @@ class PddfFan(FanBase):
|
|||||||
index = str(self.fantray_index-1)
|
index = str(self.fantray_index-1)
|
||||||
led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED"
|
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:
|
if result == False:
|
||||||
print msg
|
print(msg)
|
||||||
return (False)
|
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('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('index', index, self.pddf_obj.get_led_path())
|
||||||
@ -309,12 +307,11 @@ class PddfFan(FanBase):
|
|||||||
self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path())
|
self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path())
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
|
|
||||||
def get_status_led(self):
|
def get_status_led(self):
|
||||||
index = str(self.fantray_index-1)
|
index = str(self.fantray_index-1)
|
||||||
fan_led_device = "FANTRAY{}".format(self.fantray_index) + "_LED"
|
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
|
# Implement a generic status_led color scheme
|
||||||
if self.get_status():
|
if self.get_status():
|
||||||
return self.STATUS_LED_COLOR_GREEN
|
return self.STATUS_LED_COLOR_GREEN
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
import pddfparse
|
from . import pddfparse
|
||||||
from sonic_platform_base.platform_base import PlatformBase
|
from sonic_platform_base.platform_base import PlatformBase
|
||||||
from sonic_platform.chassis import Chassis
|
from sonic_platform.chassis import Chassis
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
@ -23,6 +23,7 @@ class PddfPlatform(PlatformBase):
|
|||||||
"""
|
"""
|
||||||
pddf_data = {}
|
pddf_data = {}
|
||||||
pddf_plugin_data = {}
|
pddf_plugin_data = {}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Initialize the JSON data
|
# Initialize the JSON data
|
||||||
self.pddf_data = pddfparse.PddfParse()
|
self.pddf_data = pddfparse.PddfParse()
|
||||||
@ -30,7 +31,7 @@ class PddfPlatform(PlatformBase):
|
|||||||
self.pddf_plugin_data = json.load(pd)
|
self.pddf_plugin_data = json.load(pd)
|
||||||
|
|
||||||
if not self.pddf_data or not self.pddf_plugin_data:
|
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
|
raise ValueError
|
||||||
|
|
||||||
PlatformBase.__init__(self)
|
PlatformBase.__init__(self)
|
||||||
|
@ -27,7 +27,6 @@ class PddfPsu(PsuBase):
|
|||||||
pddf_obj = {}
|
pddf_obj = {}
|
||||||
plugin_data = {}
|
plugin_data = {}
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
|
def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
|
||||||
PsuBase.__init__(self)
|
PsuBase.__init__(self)
|
||||||
if not pddf_data or not pddf_plugin_data:
|
if not pddf_data or not pddf_plugin_data:
|
||||||
@ -230,9 +229,9 @@ class PddfPsu(PsuBase):
|
|||||||
index = str(self.psu_index-1)
|
index = str(self.psu_index-1)
|
||||||
led_device_name = "PSU{}".format(self.psu_index) + "_LED"
|
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:
|
if result == False:
|
||||||
print msg
|
print(msg)
|
||||||
return (False)
|
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']
|
||||||
@ -245,7 +244,7 @@ class PddfPsu(PsuBase):
|
|||||||
def get_status_led(self):
|
def get_status_led(self):
|
||||||
index = str(self.psu_index-1)
|
index = str(self.psu_index-1)
|
||||||
psu_led_device = "PSU{}_LED".format(self.psu_index)
|
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
|
# Implement a generic status_led color scheme
|
||||||
if self.get_powergood_status():
|
if self.get_powergood_status():
|
||||||
return self.STATUS_LED_COLOR_GREEN
|
return self.STATUS_LED_COLOR_GREEN
|
||||||
|
@ -10,7 +10,7 @@ try:
|
|||||||
from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom
|
from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom
|
||||||
from sonic_platform_base.sonic_sfp.sff8472 import sffbase
|
from sonic_platform_base.sonic_sfp.sff8472 import sffbase
|
||||||
from sonic_platform_base.sonic_sfp.inf8628 import inf8628InterfaceId
|
from sonic_platform_base.sonic_sfp.inf8628 import inf8628InterfaceId
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
# definitions of the offset and width for values in XCVR info eeprom
|
# definitions of the offset and width for values in XCVR info eeprom
|
||||||
@ -126,6 +126,7 @@ INFO_OFFSET = 128
|
|||||||
DOM_OFFSET = 0
|
DOM_OFFSET = 0
|
||||||
DOM_OFFSET1 = 384
|
DOM_OFFSET1 = 384
|
||||||
|
|
||||||
|
|
||||||
class PddfSfp(SfpBase):
|
class PddfSfp(SfpBase):
|
||||||
"""
|
"""
|
||||||
PDDF generic Sfp class
|
PDDF generic Sfp class
|
||||||
@ -154,7 +155,7 @@ class PddfSfp(SfpBase):
|
|||||||
for n in range(0, num_bytes):
|
for n in range(0, num_bytes):
|
||||||
eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2)
|
eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2)
|
||||||
except Exception as e:
|
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:
|
finally:
|
||||||
if sysfsfile_eeprom:
|
if sysfsfile_eeprom:
|
||||||
sysfsfile_eeprom.close()
|
sysfsfile_eeprom.close()
|
||||||
@ -174,7 +175,7 @@ class PddfSfp(SfpBase):
|
|||||||
self._port_start = 0
|
self._port_start = 0
|
||||||
self._port_end = int(self.platform['num_ports'])
|
self._port_end = int(self.platform['num_ports'])
|
||||||
if index < self._port_start or index >= self._port_end:
|
if index < self._port_start or index >= self._port_end:
|
||||||
print "Invalid port index %d"%index
|
print("Invalid port index %d" % index)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.port_index = index+1
|
self.port_index = index+1
|
||||||
@ -229,7 +230,6 @@ class PddfSfp(SfpBase):
|
|||||||
if not self.get_presence():
|
if not self.get_presence():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
if self.is_osfp_port:
|
if self.is_osfp_port:
|
||||||
sfpi_obj = inf8628InterfaceId()
|
sfpi_obj = inf8628InterfaceId()
|
||||||
offset = 0
|
offset = 0
|
||||||
@ -268,26 +268,27 @@ class PddfSfp(SfpBase):
|
|||||||
if sfpi_obj is None:
|
if sfpi_obj is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
if self.is_osfp_port:
|
if self.is_osfp_port:
|
||||||
sfp_type_raw = self.__read_eeprom_specific_bytes((offset + type_offset), XCVR_TYPE_WIDTH)
|
sfp_type_raw = self.__read_eeprom_specific_bytes((offset + type_offset), XCVR_TYPE_WIDTH)
|
||||||
if sfp_type_raw is not None:
|
if sfp_type_raw is not None:
|
||||||
sfp_type_data = sfpi_obj.parse_sfp_type(sfp_type_raw, 0)
|
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)
|
sfp_type_abbrv_name = sfpi_obj.parse_sfp_type_abbrv_name(sfp_typ_raw, 0)
|
||||||
else:
|
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:
|
if sfp_interface_bulk_raw is not None:
|
||||||
sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw, 0)
|
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:
|
if sfp_vendor_oui_raw is not None:
|
||||||
sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui(sfp_vendor_oui_raw, 0)
|
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:
|
if sfp_vendor_date_raw is not None:
|
||||||
sfp_vendor_date_data = sfpi_obj.parse_vendor_date(sfp_vendor_date_raw, 0)
|
sfp_vendor_date_data = sfpi_obj.parse_vendor_date(sfp_vendor_date_raw, 0)
|
||||||
|
|
||||||
|
|
||||||
sfp_vendor_name_raw = self.__read_eeprom_specific_bytes(
|
sfp_vendor_name_raw = self.__read_eeprom_specific_bytes(
|
||||||
(offset + vendor_name_offset), XCVR_VENDOR_NAME_WIDTH)
|
(offset + vendor_name_offset), XCVR_VENDOR_NAME_WIDTH)
|
||||||
sfp_vendor_name_data = sfpi_obj.parse_vendor_name(
|
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['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['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_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_type'] = "Unknown"
|
||||||
xcvr_info_dict['cable_length'] = "Unknown"
|
xcvr_info_dict['cable_length'] = "Unknown"
|
||||||
|
|
||||||
@ -344,7 +346,8 @@ class PddfSfp(SfpBase):
|
|||||||
|
|
||||||
nkey = 'Nominal Bit Rate(100Mbs)'
|
nkey = 'Nominal Bit Rate(100Mbs)'
|
||||||
if nkey in sfp_interface_bulk_data['data']:
|
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:
|
else:
|
||||||
xcvr_info_dict['nominal_bit_rate'] = 'N/A'
|
xcvr_info_dict['nominal_bit_rate'] = 'N/A'
|
||||||
elif sfp_type == 'OSFP':
|
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']
|
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['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
|
return xcvr_info_dict
|
||||||
|
|
||||||
@ -446,7 +450,8 @@ class PddfSfp(SfpBase):
|
|||||||
qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value']
|
qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value']
|
||||||
qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['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')):
|
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:
|
if dom_channel_monitor_raw is not None:
|
||||||
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
|
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
|
||||||
else:
|
else:
|
||||||
@ -457,13 +462,14 @@ class PddfSfp(SfpBase):
|
|||||||
xcvr_dom_info_dict['tx3power'] = 'N/A'
|
xcvr_dom_info_dict['tx3power'] = 'N/A'
|
||||||
xcvr_dom_info_dict['tx4power'] = 'N/A'
|
xcvr_dom_info_dict['tx4power'] = 'N/A'
|
||||||
else:
|
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:
|
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:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value']
|
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['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value']
|
||||||
xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value']
|
xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value']
|
||||||
@ -501,7 +507,8 @@ class PddfSfp(SfpBase):
|
|||||||
else:
|
else:
|
||||||
return None
|
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:
|
if dom_channel_monitor_raw is not None:
|
||||||
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
|
dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
|
||||||
else:
|
else:
|
||||||
@ -527,7 +534,6 @@ class PddfSfp(SfpBase):
|
|||||||
xcvr_dom_info_dict['reset_status'] = self.get_reset_status()
|
xcvr_dom_info_dict['reset_status'] = self.get_reset_status()
|
||||||
xcvr_dom_info_dict['lp_mode'] = self.get_lpmode()
|
xcvr_dom_info_dict['lp_mode'] = self.get_lpmode()
|
||||||
|
|
||||||
|
|
||||||
return xcvr_dom_info_dict
|
return xcvr_dom_info_dict
|
||||||
|
|
||||||
def get_transceiver_threshold_info(self):
|
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['vcchighwarning'] = module_threshold_data['VccHighWarning']['value']
|
||||||
xcvr_dom_threshold_info_dict['vcclowwarning'] = module_threshold_data['VccLowWarning']['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:
|
if dom_thres_raw:
|
||||||
channel_threshold_values = sfpd_obj.parse_channel_threshold_values(
|
channel_threshold_values = sfpd_obj.parse_channel_threshold_values(
|
||||||
dom_thres_raw, 0)
|
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['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value']
|
||||||
xcvr_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value']
|
xcvr_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return xcvr_dom_threshold_info_dict
|
return xcvr_dom_threshold_info_dict
|
||||||
|
|
||||||
def get_reset_status(self):
|
def get_reset_status(self):
|
||||||
@ -884,13 +889,15 @@ class PddfSfp(SfpBase):
|
|||||||
status = ord(eeprom.read(1))
|
status = ord(eeprom.read(1))
|
||||||
|
|
||||||
if ((status & 0x3) == 0x3):
|
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:
|
else:
|
||||||
lpmode = 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
|
# 1. "Power override" bit is 0
|
||||||
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
# 2. "Power override" bit is 1 and "Power set" bit is 0
|
||||||
|
lpmode = False
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print("Error: unable to open file: %s" % str(e))
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
if eeprom is not None:
|
if eeprom is not None:
|
||||||
@ -919,7 +926,6 @@ class PddfSfp(SfpBase):
|
|||||||
if not self.get_presence():
|
if not self.get_presence():
|
||||||
return power_override
|
return power_override
|
||||||
|
|
||||||
|
|
||||||
if self.is_osfp_port:
|
if self.is_osfp_port:
|
||||||
pass
|
pass
|
||||||
elif self.is_qsfp_port:
|
elif self.is_qsfp_port:
|
||||||
@ -1087,7 +1093,7 @@ class PddfSfp(SfpBase):
|
|||||||
eeprom_f.seek(QSFP_CONTROL_OFFSET)
|
eeprom_f.seek(QSFP_CONTROL_OFFSET)
|
||||||
eeprom_f.write(buf[0])
|
eeprom_f.write(buf[0])
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print("Error: unable to open file: %s" % str(e))
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
if eeprom_f is not None:
|
if eeprom_f is not None:
|
||||||
@ -1113,7 +1119,7 @@ class PddfSfp(SfpBase):
|
|||||||
eeprom_f.seek(SFP_STATUS_CONTROL_OFFSET)
|
eeprom_f.seek(SFP_STATUS_CONTROL_OFFSET)
|
||||||
eeprom_f.write(buf[0])
|
eeprom_f.write(buf[0])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error: unable to open file: %s" % str(e))
|
print(("Error: unable to open file: %s" % str(e)))
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
if eeprom_f:
|
if eeprom_f:
|
||||||
@ -1168,7 +1174,7 @@ class PddfSfp(SfpBase):
|
|||||||
eeprom_f.seek(QSFP_CONTROL_OFFSET)
|
eeprom_f.seek(QSFP_CONTROL_OFFSET)
|
||||||
eeprom_f.write(buf[0])
|
eeprom_f.write(buf[0])
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print("Error: unable to open file: %s" % str(e))
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
if eeprom_f is not None:
|
if eeprom_f is not None:
|
||||||
@ -1218,7 +1224,7 @@ class PddfSfp(SfpBase):
|
|||||||
eeprom_f.write(buffer[0])
|
eeprom_f.write(buffer[0])
|
||||||
return True
|
return True
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print("Error: unable to open file: %s" % str(e))
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
if eeprom_f is not None:
|
if eeprom_f is not None:
|
||||||
@ -1286,7 +1292,7 @@ class PddfSfp(SfpBase):
|
|||||||
eeprom_f.seek(QSFP_POWEROVERRIDE_OFFSET)
|
eeprom_f.seek(QSFP_POWEROVERRIDE_OFFSET)
|
||||||
eeprom_f.write(buffer[0])
|
eeprom_f.write(buffer[0])
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print "Error: unable to open file: %s" % str(e)
|
print("Error: unable to open file: %s" % str(e))
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
if eeprom_f is not None:
|
if eeprom_f is not None:
|
||||||
@ -1298,7 +1304,6 @@ class PddfSfp(SfpBase):
|
|||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the name of the device
|
Retrieves the name of the device
|
||||||
|
@ -13,7 +13,6 @@ except ImportError as e:
|
|||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PddfThermal(ThermalBase):
|
class PddfThermal(ThermalBase):
|
||||||
"""PDDF generic Thermal class"""
|
"""PDDF generic Thermal class"""
|
||||||
pddf_obj = {}
|
pddf_obj = {}
|
||||||
@ -54,7 +53,6 @@ class PddfThermal(ThermalBase):
|
|||||||
else:
|
else:
|
||||||
return (attr_value/float(1000))
|
return (attr_value/float(1000))
|
||||||
|
|
||||||
|
|
||||||
def get_high_threshold(self):
|
def get_high_threshold(self):
|
||||||
output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_high_threshold")
|
output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_high_threshold")
|
||||||
if not output:
|
if not output:
|
||||||
@ -70,7 +68,6 @@ class PddfThermal(ThermalBase):
|
|||||||
else:
|
else:
|
||||||
return (attr_value/float(1000))
|
return (attr_value/float(1000))
|
||||||
|
|
||||||
|
|
||||||
def get_low_threshold(self):
|
def get_low_threshold(self):
|
||||||
output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_low_threshold")
|
output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_low_threshold")
|
||||||
if not output:
|
if not output:
|
||||||
@ -86,11 +83,10 @@ class PddfThermal(ThermalBase):
|
|||||||
else:
|
else:
|
||||||
return (attr_value/float(1000))
|
return (attr_value/float(1000))
|
||||||
|
|
||||||
|
|
||||||
def set_high_threshold(self, temperature):
|
def set_high_threshold(self, temperature):
|
||||||
node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_high_threshold")
|
node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_high_threshold")
|
||||||
if node is None:
|
if node is None:
|
||||||
print "ERROR %s does not exist"%node
|
print("ERROR %s does not exist" % node)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
cmd = "echo '%d' > %s" % (temperature * 1000, node)
|
cmd = "echo '%d' > %s" % (temperature * 1000, node)
|
||||||
@ -98,11 +94,10 @@ class PddfThermal(ThermalBase):
|
|||||||
|
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
|
|
||||||
def set_low_threshold(self, temperature):
|
def set_low_threshold(self, temperature):
|
||||||
node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_low_threshold")
|
node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_low_threshold")
|
||||||
if node is None:
|
if node is None:
|
||||||
print "ERROR %s does not exist"%node
|
print("ERROR %s does not exist" % node)
|
||||||
return None
|
return None
|
||||||
cmd = "echo '%d' > %s" % (temperature * 1000, node)
|
cmd = "echo '%d' > %s" % (temperature * 1000, node)
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
@ -131,7 +126,6 @@ class PddfThermal(ThermalBase):
|
|||||||
else:
|
else:
|
||||||
return (attr_value/float(1000))
|
return (attr_value/float(1000))
|
||||||
|
|
||||||
|
|
||||||
def get_low_critical_threshold(self):
|
def get_low_critical_threshold(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the low critical threshold temperature of thermal
|
Retrieves the low critical threshold temperature of thermal
|
||||||
@ -154,8 +148,8 @@ class PddfThermal(ThermalBase):
|
|||||||
else:
|
else:
|
||||||
return (attr_value/float(1000))
|
return (attr_value/float(1000))
|
||||||
|
|
||||||
|
|
||||||
# Helper Functions
|
# Helper Functions
|
||||||
|
|
||||||
def get_temp_label(self):
|
def get_temp_label(self):
|
||||||
if 'bmc' in self.pddf_obj.data[self.thermal_obj_name].keys():
|
if 'bmc' in self.pddf_obj.data[self.thermal_obj_name].keys():
|
||||||
return None
|
return None
|
||||||
@ -169,6 +163,5 @@ class PddfThermal(ThermalBase):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def dump_sysfs(self):
|
def dump_sysfs(self):
|
||||||
return self.pddf_obj.cli_dump_dsysfs('temp-sensors')
|
return self.pddf_obj.cli_dump_dsysfs('temp-sensors')
|
||||||
|
@ -42,12 +42,11 @@ class PddfParse():
|
|||||||
if os.path.exists('/usr/share/sonic/platform'):
|
if os.path.exists('/usr/share/sonic/platform'):
|
||||||
os.unlink("/usr/share/sonic/platform")
|
os.unlink("/usr/share/sonic/platform")
|
||||||
|
|
||||||
|
|
||||||
self.data_sysfs_obj = {}
|
self.data_sysfs_obj = {}
|
||||||
self.sysfs_obj = {}
|
self.sysfs_obj = {}
|
||||||
|
|
||||||
|
|
||||||
# Returns platform and HW SKU
|
# Returns platform and HW SKU
|
||||||
|
|
||||||
def get_platform_and_hwsku(self):
|
def get_platform_and_hwsku(self):
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
|
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
|
||||||
@ -65,7 +64,7 @@ class PddfParse():
|
|||||||
stdout = proc.communicate()[0]
|
stdout = proc.communicate()[0]
|
||||||
proc.wait()
|
proc.wait()
|
||||||
hwsku = stdout.rstrip('\n')
|
hwsku = stdout.rstrip('\n')
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
raise OSError("Cannot detect platform")
|
raise OSError("Cannot detect platform")
|
||||||
|
|
||||||
return (platform, hwsku)
|
return (platform, hwsku)
|
||||||
@ -76,7 +75,7 @@ class PddfParse():
|
|||||||
def runcmd(self, cmd):
|
def runcmd(self, cmd):
|
||||||
rc = os.system(cmd)
|
rc = os.system(cmd)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
print "%s -- command failed"%cmd
|
print("%s -- command failed" % cmd)
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
def get_dev_idx(self, dev, ops):
|
def get_dev_idx(self, dev, ops):
|
||||||
@ -85,7 +84,6 @@ class PddfParse():
|
|||||||
|
|
||||||
return pdev['dev_attr']['dev_idx']
|
return pdev['dev_attr']['dev_idx']
|
||||||
|
|
||||||
|
|
||||||
def get_path(self, target, attr):
|
def get_path(self, target, attr):
|
||||||
aa = target + attr
|
aa = target + attr
|
||||||
|
|
||||||
@ -105,16 +103,14 @@ class PddfParse():
|
|||||||
if path != "":
|
if path != "":
|
||||||
string = path
|
string = path
|
||||||
|
|
||||||
|
|
||||||
if string is not None:
|
if string is not None:
|
||||||
string = string.rstrip()
|
string = string.rstrip()
|
||||||
|
|
||||||
cache[aa] = string
|
cache[aa] = string
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
def get_device_type(self, key):
|
def get_device_type(self, key):
|
||||||
if not key in self.data.keys():
|
if key not in self.data.keys():
|
||||||
return None
|
return None
|
||||||
return self.data[key]['dev_info']['device_type']
|
return self.data[key]['dev_info']['device_type']
|
||||||
|
|
||||||
@ -122,10 +118,10 @@ class PddfParse():
|
|||||||
return self.data['PLATFORM']
|
return self.data['PLATFORM']
|
||||||
|
|
||||||
def get_num_psu_fans(self, dev):
|
def get_num_psu_fans(self, dev):
|
||||||
if not dev in self.data.keys():
|
if dev not in self.data.keys():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if not 'num_psu_fans' in self.data[dev]['dev_attr']:
|
if 'num_psu_fans' not in self.data[dev]['dev_attr']:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
return self.data[dev]['dev_attr']['num_psu_fans']
|
return self.data[dev]['dev_attr']['num_psu_fans']
|
||||||
@ -146,7 +142,6 @@ class PddfParse():
|
|||||||
|
|
||||||
return (color_map[color])
|
return (color_map[color])
|
||||||
|
|
||||||
|
|
||||||
def get_led_color_devtype(self, key):
|
def get_led_color_devtype(self, key):
|
||||||
attr_list = self.data[key]['i2c']['attr_list']
|
attr_list = self.data[key]['i2c']['attr_list']
|
||||||
for attr in attr_list:
|
for attr in attr_list:
|
||||||
@ -187,7 +182,6 @@ class PddfParse():
|
|||||||
return(color_map[attr['attr_name']])
|
return(color_map[attr['attr_name']])
|
||||||
return (color_map['STATUS_LED_COLOR_OFF'])
|
return (color_map['STATUS_LED_COLOR_OFF'])
|
||||||
|
|
||||||
|
|
||||||
def get_led_color_from_cpld(self, led_device_name):
|
def get_led_color_from_cpld(self, led_device_name):
|
||||||
index = self.data[led_device_name]['dev_attr']['index']
|
index = self.data[led_device_name]['dev_attr']['index']
|
||||||
device_name = self.data[led_device_name]['dev_info']['device_name']
|
device_name = self.data[led_device_name]['dev_info']['device_name']
|
||||||
@ -218,7 +212,7 @@ class PddfParse():
|
|||||||
cmd = "echo {} > {}".format(_value, attr_path)
|
cmd = "echo {} > {}".format(_value, attr_path)
|
||||||
self.runcmd(cmd)
|
self.runcmd(cmd)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "Invalid gpio path : " + attr_path
|
print("Invalid gpio path : " + attr_path)
|
||||||
return (False)
|
return (False)
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
@ -231,9 +225,8 @@ class PddfParse():
|
|||||||
self.create_attr('dev_ops', 'set_status', self.get_led_path())
|
self.create_attr('dev_ops', 'set_status', self.get_led_path())
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
|
|
||||||
def get_system_led_color(self, led_device_name):
|
def get_system_led_color(self, led_device_name):
|
||||||
if (not led_device_name in self.data.keys()):
|
if led_device_name not in self.data.keys():
|
||||||
status = "[FAILED] " + led_device_name + " is not configured"
|
status = "[FAILED] " + led_device_name + " is not configured"
|
||||||
return (status)
|
return (status)
|
||||||
|
|
||||||
@ -246,9 +239,9 @@ class PddfParse():
|
|||||||
return color
|
return color
|
||||||
|
|
||||||
def set_system_led_color(self, led_device_name, color):
|
def set_system_led_color(self, led_device_name, color):
|
||||||
result, msg = self.is_supported_sysled_state(led_device_name, color);
|
result, msg = self.is_supported_sysled_state(led_device_name, color)
|
||||||
if result == False:
|
if result == False:
|
||||||
print msg
|
print(msg)
|
||||||
return (result)
|
return (result)
|
||||||
|
|
||||||
type = self.get_led_color_devtype(led_device_name)
|
type = self.get_led_color_devtype(led_device_name)
|
||||||
@ -269,7 +262,6 @@ class PddfParse():
|
|||||||
return (True)
|
return (True)
|
||||||
return (False)
|
return (False)
|
||||||
|
|
||||||
|
|
||||||
def show_device_sysfs(self, dev, ops):
|
def show_device_sysfs(self, dev, ops):
|
||||||
parent = dev['dev_info']['device_parent']
|
parent = dev['dev_info']['device_parent']
|
||||||
pdev = self.data[parent]
|
pdev = self.data[parent]
|
||||||
@ -277,8 +269,8 @@ class PddfParse():
|
|||||||
return "/sys/bus/i2c/devices/"+"i2c-%d" % int(pdev['i2c']['topo_info']['dev_addr'], 0)
|
return "/sys/bus/i2c/devices/"+"i2c-%d" % int(pdev['i2c']['topo_info']['dev_addr'], 0)
|
||||||
return self.show_device_sysfs(pdev, ops) + "/" + "i2c-%d" % int(dev['i2c']['topo_info']['parent_bus'], 0)
|
return self.show_device_sysfs(pdev, ops) + "/" + "i2c-%d" % int(dev['i2c']['topo_info']['parent_bus'], 0)
|
||||||
|
|
||||||
|
|
||||||
# This is alid for 'at24' type of EEPROM devices. Only one attribtue 'eeprom'
|
# This is alid for 'at24' type of EEPROM devices. Only one attribtue 'eeprom'
|
||||||
|
|
||||||
def show_attr_eeprom_device(self, dev, ops):
|
def show_attr_eeprom_device(self, dev, ops):
|
||||||
str = ""
|
str = ""
|
||||||
attr_name = ops['attr']
|
attr_name = ops['attr']
|
||||||
@ -286,7 +278,7 @@ class PddfParse():
|
|||||||
KEY = "eeprom"
|
KEY = "eeprom"
|
||||||
dsysfs_path = ""
|
dsysfs_path = ""
|
||||||
|
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
for attr in attr_list:
|
for attr in attr_list:
|
||||||
@ -300,7 +292,7 @@ class PddfParse():
|
|||||||
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
||||||
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
||||||
"/%s" % real_name
|
"/%s" % real_name
|
||||||
if not dsysfs_path in self.data_sysfs_obj[KEY]:
|
if dsysfs_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
||||||
str += dsysfs_path+"\n"
|
str += dsysfs_path+"\n"
|
||||||
return str
|
return str
|
||||||
@ -308,16 +300,15 @@ class PddfParse():
|
|||||||
def show_attr_gpio_device(self, dev, ops):
|
def show_attr_gpio_device(self, dev, ops):
|
||||||
ret = ""
|
ret = ""
|
||||||
KEY = "gpio"
|
KEY = "gpio"
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def show_attr_mux_device(self, dev, ops):
|
def show_attr_mux_device(self, dev, ops):
|
||||||
ret = ""
|
ret = ""
|
||||||
KEY = "mux"
|
KEY = "mux"
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
@ -336,7 +327,7 @@ class PddfParse():
|
|||||||
KEY = "psu"
|
KEY = "psu"
|
||||||
dsysfs_path = ""
|
dsysfs_path = ""
|
||||||
|
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
if target == 'all' or target == dev['dev_info']['virt_parent']:
|
if target == 'all' or target == dev['dev_info']['virt_parent']:
|
||||||
@ -347,7 +338,7 @@ class PddfParse():
|
|||||||
# Check and enable the gpio from class
|
# Check and enable the gpio from class
|
||||||
attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset'])
|
attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset'])
|
||||||
if (os.path.exists(attr_path)):
|
if (os.path.exists(attr_path)):
|
||||||
if not attr_path in self.data_sysfs_obj[KEY]:
|
if attr_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(attr_path)
|
self.data_sysfs_obj[KEY].append(attr_path)
|
||||||
ret += attr_path + '\n'
|
ret += attr_path + '\n'
|
||||||
else:
|
else:
|
||||||
@ -360,16 +351,14 @@ class PddfParse():
|
|||||||
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
||||||
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
||||||
"/%s" % real_name
|
"/%s" % real_name
|
||||||
if not dsysfs_path in self.data_sysfs_obj[KEY]:
|
if dsysfs_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
||||||
ret += dsysfs_path+"\n"
|
ret += dsysfs_path+"\n"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def show_attr_psu_device(self, dev, ops):
|
def show_attr_psu_device(self, dev, ops):
|
||||||
return self.show_attr_psu_i2c_device(dev, ops)
|
return self.show_attr_psu_i2c_device(dev, ops)
|
||||||
|
|
||||||
|
|
||||||
def show_attr_fan_device(self, dev, ops):
|
def show_attr_fan_device(self, dev, ops):
|
||||||
ret = ""
|
ret = ""
|
||||||
attr_name = ops['attr']
|
attr_name = ops['attr']
|
||||||
@ -377,17 +366,16 @@ class PddfParse():
|
|||||||
KEY = "fan"
|
KEY = "fan"
|
||||||
dsysfs_path = ""
|
dsysfs_path = ""
|
||||||
|
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
|
|
||||||
for attr in attr_list:
|
for attr in attr_list:
|
||||||
if attr_name == attr['attr_name'] or attr_name == 'all':
|
if attr_name == attr['attr_name'] or attr_name == 'all':
|
||||||
if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio":
|
if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio":
|
||||||
# Check and enable the gpio from class
|
# Check and enable the gpio from class
|
||||||
attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset'])
|
attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset'])
|
||||||
if (os.path.exists(attr_path)):
|
if (os.path.exists(attr_path)):
|
||||||
if not attr_path in self.data_sysfs_obj[KEY]:
|
if attr_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(attr_path)
|
self.data_sysfs_obj[KEY].append(attr_path)
|
||||||
ret += attr_path + '\n'
|
ret += attr_path + '\n'
|
||||||
else:
|
else:
|
||||||
@ -400,7 +388,7 @@ class PddfParse():
|
|||||||
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
||||||
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
||||||
"/%s" % real_name
|
"/%s" % real_name
|
||||||
if not dsysfs_path in self.data_sysfs_obj[KEY]:
|
if dsysfs_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
||||||
ret += dsysfs_path+"\n"
|
ret += dsysfs_path+"\n"
|
||||||
return ret
|
return ret
|
||||||
@ -413,10 +401,9 @@ class PddfParse():
|
|||||||
KEY = "temp-sensors"
|
KEY = "temp-sensors"
|
||||||
dsysfs_path = ""
|
dsysfs_path = ""
|
||||||
|
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
|
|
||||||
for attr in attr_list:
|
for attr in attr_list:
|
||||||
if attr_name == attr['attr_name'] or attr_name == 'all':
|
if attr_name == attr['attr_name'] or attr_name == 'all':
|
||||||
path = self.show_device_sysfs(dev, ops)+"/%d-00%x/" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
path = self.show_device_sysfs(dev, ops)+"/%d-00%x/" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
||||||
@ -429,7 +416,7 @@ class PddfParse():
|
|||||||
if (os.path.exists(path)):
|
if (os.path.exists(path)):
|
||||||
full_path = glob.glob(path + 'hwmon/hwmon*/' + real_name)[0]
|
full_path = glob.glob(path + 'hwmon/hwmon*/' + real_name)[0]
|
||||||
dsysfs_path = full_path
|
dsysfs_path = full_path
|
||||||
if not dsysfs_path in self.data_sysfs_obj[KEY]:
|
if dsysfs_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
||||||
str += full_path + "\n"
|
str += full_path + "\n"
|
||||||
return str
|
return str
|
||||||
@ -441,26 +428,24 @@ class PddfParse():
|
|||||||
KEY = "sys-status"
|
KEY = "sys-status"
|
||||||
dsysfs_path = ""
|
dsysfs_path = ""
|
||||||
|
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
|
|
||||||
for attr in attr_list:
|
for attr in attr_list:
|
||||||
if attr_name == attr['attr_name'] or attr_name == 'all':
|
if attr_name == attr['attr_name'] or attr_name == 'all':
|
||||||
dsysfs_path = "/sys/kernel/pddf/devices/sysstatus/sysstatus_data/" + attr['attr_name']
|
dsysfs_path = "/sys/kernel/pddf/devices/sysstatus/sysstatus_data/" + attr['attr_name']
|
||||||
if not dsysfs_path in self.data_sysfs_obj[KEY]:
|
if dsysfs_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
||||||
ret += dsysfs_path+"\n"
|
ret += dsysfs_path+"\n"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def show_attr_xcvr_i2c_device(self, dev, ops):
|
def show_attr_xcvr_i2c_device(self, dev, ops):
|
||||||
target = ops['target']
|
target = ops['target']
|
||||||
attr_name = ops['attr']
|
attr_name = ops['attr']
|
||||||
ret = ""
|
ret = ""
|
||||||
dsysfs_path = ""
|
dsysfs_path = ""
|
||||||
KEY = "xcvr"
|
KEY = "xcvr"
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
if target == 'all' or target == dev['dev_info']['virt_parent']:
|
if target == 'all' or target == dev['dev_info']['virt_parent']:
|
||||||
@ -471,7 +456,7 @@ class PddfParse():
|
|||||||
# Check and enable the gpio from class
|
# Check and enable the gpio from class
|
||||||
attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset'])
|
attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset'])
|
||||||
if (os.path.exists(attr_path)):
|
if (os.path.exists(attr_path)):
|
||||||
if not attr_path in self.data_sysfs_obj[KEY]:
|
if attr_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(attr_path)
|
self.data_sysfs_obj[KEY].append(attr_path)
|
||||||
ret += attr_path + '\n'
|
ret += attr_path + '\n'
|
||||||
else:
|
else:
|
||||||
@ -484,27 +469,26 @@ class PddfParse():
|
|||||||
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
"/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0),
|
||||||
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
int(dev['i2c']['topo_info']['dev_addr'], 0)) + \
|
||||||
"/%s" % real_name
|
"/%s" % real_name
|
||||||
if not dsysfs_path in self.data_sysfs_obj[KEY]:
|
if dsysfs_path not in self.data_sysfs_obj[KEY]:
|
||||||
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
self.data_sysfs_obj[KEY].append(dsysfs_path)
|
||||||
ret += dsysfs_path+"\n"
|
ret += dsysfs_path+"\n"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def show_attr_xcvr_device(self, dev, ops):
|
def show_attr_xcvr_device(self, dev, ops):
|
||||||
return self.show_attr_xcvr_i2c_device(dev, ops)
|
return self.show_attr_xcvr_i2c_device(dev, ops)
|
||||||
|
|
||||||
def show_attr_cpld_device(self, dev, ops):
|
def show_attr_cpld_device(self, dev, ops):
|
||||||
ret = ""
|
ret = ""
|
||||||
KEY = "cpld"
|
KEY = "cpld"
|
||||||
if not KEY in self.data_sysfs_obj:
|
if KEY not in self.data_sysfs_obj:
|
||||||
self.data_sysfs_obj[KEY] = []
|
self.data_sysfs_obj[KEY] = []
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
# SHOW DEFS
|
# SHOW DEFS
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
|
|
||||||
def check_led_cmds(self, key, ops):
|
def check_led_cmds(self, key, ops):
|
||||||
name = ops['target']+'_LED'
|
name = ops['target']+'_LED'
|
||||||
if (ops['target'] == 'config' or ops['attr'] == 'all') or \
|
if (ops['target'] == 'config' or ops['attr'] == 'all') or \
|
||||||
@ -517,44 +501,42 @@ class PddfParse():
|
|||||||
def dump_sysfs_obj(self, obj, key_type):
|
def dump_sysfs_obj(self, obj, key_type):
|
||||||
if (key_type == 'keys'):
|
if (key_type == 'keys'):
|
||||||
for key in obj.keys():
|
for key in obj.keys():
|
||||||
print key
|
print(key)
|
||||||
return
|
return
|
||||||
|
|
||||||
for key in obj:
|
for key in obj:
|
||||||
if (key == key_type or key_type == 'all'):
|
if (key == key_type or key_type == 'all'):
|
||||||
print key+":"
|
print(key+":")
|
||||||
for entry in obj[key]:
|
for entry in obj[key]:
|
||||||
print "\t"+entry
|
print("\t"+entry)
|
||||||
|
|
||||||
def add_list_sysfs_obj(self, obj, KEY, list):
|
def add_list_sysfs_obj(self, obj, KEY, list):
|
||||||
for sysfs in list:
|
for sysfs in list:
|
||||||
if not sysfs in obj[KEY]:
|
if sysfs not in obj[KEY]:
|
||||||
obj[KEY].append(sysfs)
|
obj[KEY].append(sysfs)
|
||||||
|
|
||||||
def sysfs_attr(self, key, value, path, obj, obj_key):
|
def sysfs_attr(self, key, value, path, obj, obj_key):
|
||||||
sysfs_path = "/sys/kernel/%s/%s" % (path, key)
|
sysfs_path = "/sys/kernel/%s/%s" % (path, key)
|
||||||
if not sysfs_path in obj[obj_key]:
|
if sysfs_path not in obj[obj_key]:
|
||||||
obj[obj_key].append(sysfs_path)
|
obj[obj_key].append(sysfs_path)
|
||||||
|
|
||||||
|
|
||||||
def sysfs_device(self, attr, path, obj, obj_key):
|
def sysfs_device(self, attr, path, obj, obj_key):
|
||||||
for key in attr.keys():
|
for key in attr.keys():
|
||||||
sysfs_path = "/sys/kernel/%s/%s" % (path, key)
|
sysfs_path = "/sys/kernel/%s/%s" % (path, key)
|
||||||
if not sysfs_path in obj[obj_key]:
|
if sysfs_path not in obj[obj_key]:
|
||||||
obj[obj_key].append(sysfs_path)
|
obj[obj_key].append(sysfs_path)
|
||||||
|
|
||||||
def show_eeprom_device(self, dev, ops):
|
def show_eeprom_device(self, dev, ops):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def show_mux_device(self, dev, ops):
|
def show_mux_device(self, dev, ops):
|
||||||
KEY = 'mux'
|
KEY = 'mux'
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/mux", self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/mux", self.sysfs_obj, KEY)
|
||||||
self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/mux", self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/mux", self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/mux/dev_ops"
|
sysfs_path = "/sys/kernel/pddf/devices/mux/dev_ops"
|
||||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
if sysfs_path not in self.sysfs_obj[KEY]:
|
||||||
self.sysfs_obj[KEY].append(sysfs_path)
|
self.sysfs_obj[KEY].append(sysfs_path)
|
||||||
list = ['/sys/kernel/pddf/devices/mux/i2c_type',
|
list = ['/sys/kernel/pddf/devices/mux/i2c_type',
|
||||||
'/sys/kernel/pddf/devices/mux/i2c_name',
|
'/sys/kernel/pddf/devices/mux/i2c_name',
|
||||||
@ -563,24 +545,23 @@ class PddfParse():
|
|||||||
|
|
||||||
def show_gpio_device(self, dev, ops):
|
def show_gpio_device(self, dev, ops):
|
||||||
KEY = 'gpio'
|
KEY = 'gpio'
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/gpio", self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/gpio", self.sysfs_obj, KEY)
|
||||||
self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/gpio", self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/gpio", self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/gpio/dev_ops"
|
sysfs_path = "/sys/kernel/pddf/devices/gpio/dev_ops"
|
||||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
if sysfs_path not in self.sysfs_obj[KEY]:
|
||||||
self.sysfs_obj[KEY].append(sysfs_path)
|
self.sysfs_obj[KEY].append(sysfs_path)
|
||||||
list = ['/sys/kernel/pddf/devices/gpio/i2c_type',
|
list = ['/sys/kernel/pddf/devices/gpio/i2c_type',
|
||||||
'/sys/kernel/pddf/devices/gpio/i2c_name',
|
'/sys/kernel/pddf/devices/gpio/i2c_name',
|
||||||
'/sys/kernel/pddf/devices/gpio/error']
|
'/sys/kernel/pddf/devices/gpio/error']
|
||||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
||||||
|
|
||||||
|
|
||||||
def show_psu_i2c_device(self, dev, ops):
|
def show_psu_i2c_device(self, dev, ops):
|
||||||
KEY = 'psu'
|
KEY = 'psu'
|
||||||
path = 'pddf/devices/psu/i2c'
|
path = 'pddf/devices/psu/i2c'
|
||||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']:
|
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']:
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/psu_idx"
|
sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/psu_idx"
|
||||||
@ -589,7 +570,7 @@ class PddfParse():
|
|||||||
for attr in dev['i2c']['attr_list']:
|
for attr in dev['i2c']['attr_list']:
|
||||||
self.sysfs_device(attr, "pddf/devices/psu/i2c", self.sysfs_obj, KEY)
|
self.sysfs_device(attr, "pddf/devices/psu/i2c", self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/dev_ops"
|
sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/dev_ops"
|
||||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
if sysfs_path not in self.sysfs_obj[KEY]:
|
||||||
self.sysfs_obj[KEY].append(sysfs_path)
|
self.sysfs_obj[KEY].append(sysfs_path)
|
||||||
list = ['/sys/kernel/pddf/devices/psu/i2c/i2c_type',
|
list = ['/sys/kernel/pddf/devices/psu/i2c/i2c_type',
|
||||||
'/sys/kernel/pddf/devices/fan/i2c/i2c_name',
|
'/sys/kernel/pddf/devices/fan/i2c/i2c_name',
|
||||||
@ -597,24 +578,22 @@ class PddfParse():
|
|||||||
'/sys/kernel/pddf/devices/psu/i2c/attr_ops']
|
'/sys/kernel/pddf/devices/psu/i2c/attr_ops']
|
||||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
||||||
|
|
||||||
|
|
||||||
def show_psu_device(self, dev, ops):
|
def show_psu_device(self, dev, ops):
|
||||||
self.show_psu_i2c_device(dev, ops)
|
self.show_psu_i2c_device(dev, ops)
|
||||||
return
|
return
|
||||||
|
|
||||||
def show_client_device(self):
|
def show_client_device(self):
|
||||||
KEY = 'client'
|
KEY = 'client'
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
list = ['/sys/kernel/pddf/devices/showall']
|
list = ['/sys/kernel/pddf/devices/showall']
|
||||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
||||||
|
|
||||||
|
|
||||||
def show_fan_device(self, dev, ops):
|
def show_fan_device(self, dev, ops):
|
||||||
KEY = 'fan'
|
KEY = 'fan'
|
||||||
path = 'pddf/devices/fan/i2c'
|
path = 'pddf/devices/fan/i2c'
|
||||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']:
|
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']:
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
|
|
||||||
self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY)
|
||||||
@ -628,32 +607,30 @@ class PddfParse():
|
|||||||
'/sys/kernel/pddf/devices/fan/i2c/dev_ops']
|
'/sys/kernel/pddf/devices/fan/i2c/dev_ops']
|
||||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
||||||
|
|
||||||
|
|
||||||
def show_temp_sensor_device(self, dev, ops):
|
def show_temp_sensor_device(self, dev, ops):
|
||||||
return
|
return
|
||||||
|
|
||||||
def show_sysstatus_device(self, dev, ops):
|
def show_sysstatus_device(self, dev, ops):
|
||||||
KEY = 'sysstatus'
|
KEY = 'sysstatus'
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
for attr in dev['attr_list']:
|
for attr in dev['attr_list']:
|
||||||
self.sysfs_device(attr, "pddf/devices/sysstatus", self.sysfs_obj, KEY)
|
self.sysfs_device(attr, "pddf/devices/sysstatus", self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/sysstatus/attr_ops"
|
sysfs_path = "/sys/kernel/pddf/devices/sysstatus/attr_ops"
|
||||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
if sysfs_path not in self.sysfs_obj[KEY]:
|
||||||
self.sysfs_obj[KEY].append(sysfs_path)
|
self.sysfs_obj[KEY].append(sysfs_path)
|
||||||
|
|
||||||
|
|
||||||
def show_xcvr_i2c_device(self, dev, ops):
|
def show_xcvr_i2c_device(self, dev, ops):
|
||||||
KEY = 'xcvr'
|
KEY = 'xcvr'
|
||||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']:
|
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']:
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY)
|
||||||
|
|
||||||
for attr in dev['i2c']['attr_list']:
|
for attr in dev['i2c']['attr_list']:
|
||||||
self.sysfs_device(attr, "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY)
|
self.sysfs_device(attr, "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/xcvr/i2c/dev_ops"
|
sysfs_path = "/sys/kernel/pddf/devices/xcvr/i2c/dev_ops"
|
||||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
if sysfs_path not in self.sysfs_obj[KEY]:
|
||||||
self.sysfs_obj[KEY].append(sysfs_path)
|
self.sysfs_obj[KEY].append(sysfs_path)
|
||||||
list = ['/sys/kernel/pddf/devices/xcvr/i2c/i2c_type',
|
list = ['/sys/kernel/pddf/devices/xcvr/i2c/i2c_type',
|
||||||
'/sys/kernel/pddf/devices/xcvr/i2c/i2c_name',
|
'/sys/kernel/pddf/devices/xcvr/i2c/i2c_name',
|
||||||
@ -661,7 +638,6 @@ class PddfParse():
|
|||||||
'/sys/kernel/pddf/devices/xcvr/i2c/attr_ops']
|
'/sys/kernel/pddf/devices/xcvr/i2c/attr_ops']
|
||||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
||||||
|
|
||||||
|
|
||||||
def show_xcvr_device(self, dev, ops):
|
def show_xcvr_device(self, dev, ops):
|
||||||
self.show_xcvr_i2c_device(dev, ops)
|
self.show_xcvr_i2c_device(dev, ops)
|
||||||
return
|
return
|
||||||
@ -669,11 +645,11 @@ class PddfParse():
|
|||||||
def show_cpld_device(self, dev, ops):
|
def show_cpld_device(self, dev, ops):
|
||||||
KEY = 'cpld'
|
KEY = 'cpld'
|
||||||
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLD']:
|
if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLD']:
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/cpld", self.sysfs_obj, KEY)
|
self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/cpld", self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/cpld/dev_ops"
|
sysfs_path = "/sys/kernel/pddf/devices/cpld/dev_ops"
|
||||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
if sysfs_path not in self.sysfs_obj[KEY]:
|
||||||
self.sysfs_obj[KEY].append(sysfs_path)
|
self.sysfs_obj[KEY].append(sysfs_path)
|
||||||
list = ['/sys/kernel/pddf/devices/cpld/i2c_type',
|
list = ['/sys/kernel/pddf/devices/cpld/i2c_type',
|
||||||
'/sys/kernel/pddf/devices/cpld/i2c_name',
|
'/sys/kernel/pddf/devices/cpld/i2c_name',
|
||||||
@ -683,7 +659,7 @@ class PddfParse():
|
|||||||
def show_led_platform_device(self, key, ops):
|
def show_led_platform_device(self, key, ops):
|
||||||
if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM':
|
if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM':
|
||||||
KEY = 'platform'
|
KEY = 'platform'
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
path = 'pddf/devices/platform'
|
path = 'pddf/devices/platform'
|
||||||
self.sysfs_attr('num_psus', self.data['PLATFORM']['num_psus'], path, self.sysfs_obj, KEY)
|
self.sysfs_attr('num_psus', self.data['PLATFORM']['num_psus'], path, self.sysfs_obj, KEY)
|
||||||
@ -692,7 +668,7 @@ class PddfParse():
|
|||||||
def show_led_device(self, key, ops):
|
def show_led_device(self, key, ops):
|
||||||
if self.check_led_cmds(key, ops):
|
if self.check_led_cmds(key, ops):
|
||||||
KEY = 'led'
|
KEY = 'led'
|
||||||
if not KEY in self.sysfs_obj:
|
if KEY not in self.sysfs_obj:
|
||||||
self.sysfs_obj[KEY] = []
|
self.sysfs_obj[KEY] = []
|
||||||
path = "pddf/devices/led"
|
path = "pddf/devices/led"
|
||||||
for attr in self.data[key]['i2c']['attr_list']:
|
for attr in self.data[key]['i2c']['attr_list']:
|
||||||
@ -706,13 +682,12 @@ class PddfParse():
|
|||||||
if (attr_key != 'attr_name' and attr_key != 'swpld_addr' and attr_key != 'swpld_addr_offset'):
|
if (attr_key != 'attr_name' and attr_key != 'swpld_addr' and attr_key != 'swpld_addr_offset'):
|
||||||
self.sysfs_attr(attr_key, attr[attr_key], attr_path, self.sysfs_obj, KEY)
|
self.sysfs_attr(attr_key, attr[attr_key], attr_path, self.sysfs_obj, KEY)
|
||||||
sysfs_path = "/sys/kernel/pddf/devices/led/dev_ops"
|
sysfs_path = "/sys/kernel/pddf/devices/led/dev_ops"
|
||||||
if not sysfs_path in self.sysfs_obj[KEY]:
|
if sysfs_path not in self.sysfs_obj[KEY]:
|
||||||
self.sysfs_obj[KEY].append(sysfs_path)
|
self.sysfs_obj[KEY].append(sysfs_path)
|
||||||
list = ['/sys/kernel/pddf/devices/led/cur_state/color',
|
list = ['/sys/kernel/pddf/devices/led/cur_state/color',
|
||||||
'/sys/kernel/pddf/devices/led/cur_state/color_state']
|
'/sys/kernel/pddf/devices/led/cur_state/color_state']
|
||||||
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
self.add_list_sysfs_obj(self.sysfs_obj, KEY, list)
|
||||||
|
|
||||||
|
|
||||||
def validate_xcvr_device(self, dev, ops):
|
def validate_xcvr_device(self, dev, ops):
|
||||||
devtype_list = ['optoe1', 'optoe2']
|
devtype_list = ['optoe1', 'optoe2']
|
||||||
dev_attribs = ['xcvr_present', 'xcvr_reset', 'xcvr_intr_status', 'xcvr_lpmode']
|
dev_attribs = ['xcvr_present', 'xcvr_reset', 'xcvr_intr_status', 'xcvr_lpmode']
|
||||||
@ -723,7 +698,7 @@ class PddfParse():
|
|||||||
if 'attr_name' in attr.keys() and 'eeprom' in attr.values():
|
if 'attr_name' in attr.keys() and 'eeprom' in attr.values():
|
||||||
ret_val = "xcvr validation success"
|
ret_val = "xcvr validation success"
|
||||||
else:
|
else:
|
||||||
print "xcvr validation Failed"
|
print("xcvr validation Failed")
|
||||||
return
|
return
|
||||||
|
|
||||||
elif dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']:
|
elif dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']:
|
||||||
@ -731,9 +706,9 @@ class PddfParse():
|
|||||||
if attr.get("attr_name") in dev_attribs:
|
if attr.get("attr_name") in dev_attribs:
|
||||||
ret_val = "Success"
|
ret_val = "Success"
|
||||||
else:
|
else:
|
||||||
print "xcvr validation Failed"
|
print("xcvr validation Failed")
|
||||||
return
|
return
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
def validate_eeprom_device(self, dev, ops):
|
def validate_eeprom_device(self, dev, ops):
|
||||||
devtype_list = ['24c02']
|
devtype_list = ['24c02']
|
||||||
@ -746,7 +721,7 @@ class PddfParse():
|
|||||||
for attr in dev['i2c']['attr_list']:
|
for attr in dev['i2c']['attr_list']:
|
||||||
if attr.get("attr_name") in dev_attribs:
|
if attr.get("attr_name") in dev_attribs:
|
||||||
ret_val = "eeprom success"
|
ret_val = "eeprom success"
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
def validate_mux_device(self, dev, ops):
|
def validate_mux_device(self, dev, ops):
|
||||||
devtype_list = ['pca9548', 'pca954x']
|
devtype_list = ['pca9548', 'pca954x']
|
||||||
@ -757,7 +732,7 @@ class PddfParse():
|
|||||||
for attr in dev['i2c']['channel']:
|
for attr in dev['i2c']['channel']:
|
||||||
if attr.get("chn") in dev_channels:
|
if attr.get("chn") in dev_channels:
|
||||||
ret_val = "Mux success"
|
ret_val = "Mux success"
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
def validate_cpld_device(self, dev, ops):
|
def validate_cpld_device(self, dev, ops):
|
||||||
devtype_list = ['i2c_cpld']
|
devtype_list = ['i2c_cpld']
|
||||||
@ -765,8 +740,7 @@ class PddfParse():
|
|||||||
|
|
||||||
if dev['i2c']['topo_info']['dev_type'] in devtype_list:
|
if dev['i2c']['topo_info']['dev_type'] in devtype_list:
|
||||||
ret_val = "cpld success"
|
ret_val = "cpld success"
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
|
|
||||||
def validate_sysstatus_device(self, dev, ops):
|
def validate_sysstatus_device(self, dev, ops):
|
||||||
dev_attribs = ['board_info', 'cpld1_version', 'power_module_status', 'system_reset5',
|
dev_attribs = ['board_info', 'cpld1_version', 'power_module_status', 'system_reset5',
|
||||||
@ -778,7 +752,7 @@ class PddfParse():
|
|||||||
for attr in dev['attr_list']:
|
for attr in dev['attr_list']:
|
||||||
if attr.get("attr_name") in dev_attribs:
|
if attr.get("attr_name") in dev_attribs:
|
||||||
ret_val = "sysstatus success"
|
ret_val = "sysstatus success"
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
def validate_temp_sensor_device(self, dev, ops):
|
def validate_temp_sensor_device(self, dev, ops):
|
||||||
devtype_list = ['lm75']
|
devtype_list = ['lm75']
|
||||||
@ -790,7 +764,7 @@ class PddfParse():
|
|||||||
for attr in dev['i2c']['attr_list']:
|
for attr in dev['i2c']['attr_list']:
|
||||||
if attr.get("attr_name") in dev_attribs:
|
if attr.get("attr_name") in dev_attribs:
|
||||||
ret_val = "tempsensor success"
|
ret_val = "tempsensor success"
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
def validate_fan_device(self, dev, ops):
|
def validate_fan_device(self, dev, ops):
|
||||||
ret_val = "fan failed"
|
ret_val = "fan failed"
|
||||||
@ -799,7 +773,7 @@ class PddfParse():
|
|||||||
if dev['i2c']['dev_attr']['num_fan'] is not None:
|
if dev['i2c']['dev_attr']['num_fan'] is not None:
|
||||||
ret_val = "fan success"
|
ret_val = "fan success"
|
||||||
|
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
def validate_psu_device(self, dev, ops):
|
def validate_psu_device(self, dev, ops):
|
||||||
dev_attribs = ['psu_present', 'psu_model_name', 'psu_power_good', 'psu_mfr_id', 'psu_serial_num',
|
dev_attribs = ['psu_present', 'psu_model_name', 'psu_power_good', 'psu_mfr_id', 'psu_serial_num',
|
||||||
@ -818,7 +792,7 @@ class PddfParse():
|
|||||||
else:
|
else:
|
||||||
ret_val = "psu failed"
|
ret_val = "psu failed"
|
||||||
|
|
||||||
print ret_val
|
print(ret_val)
|
||||||
|
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
# SPYTEST
|
# SPYTEST
|
||||||
@ -829,18 +803,17 @@ class PddfParse():
|
|||||||
with open(node, 'r') as f:
|
with open(node, 'r') as f:
|
||||||
status = f.read()
|
status = f.read()
|
||||||
except IOError:
|
except IOError:
|
||||||
print "PDDF_VERIFY_ERR: IOError: node:%s key:%s"%(node, key)
|
print("PDDF_VERIFY_ERR: IOError: node:%s key:%s" % (node, key))
|
||||||
return
|
return
|
||||||
|
|
||||||
status = status.rstrip("\n\r")
|
status = status.rstrip("\n\r")
|
||||||
if attr[key] != status:
|
if attr[key] != status:
|
||||||
print "PDDF_VERIFY_ERR: node: %s switch:%s"%(node, status)
|
print("PDDF_VERIFY_ERR: node: %s switch:%s" % (node, status))
|
||||||
|
|
||||||
def verify_device(self, attr, path, ops):
|
def verify_device(self, attr, path, ops):
|
||||||
for key in attr.keys():
|
for key in attr.keys():
|
||||||
self.verify_attr(key, attr, path)
|
self.verify_attr(key, attr, path)
|
||||||
|
|
||||||
|
|
||||||
def get_led_device(self, device_name):
|
def get_led_device(self, device_name):
|
||||||
self.create_attr('device_name', self.data[device_name]['dev_info']['device_name'], "pddf/devices/led")
|
self.create_attr('device_name', self.data[device_name]['dev_info']['device_name'], "pddf/devices/led")
|
||||||
self.create_attr('index', self.data[device_name]['dev_attr']['index'], "pddf/devices/led")
|
self.create_attr('index', self.data[device_name]['dev_attr']['index'], "pddf/devices/led")
|
||||||
@ -851,24 +824,22 @@ class PddfParse():
|
|||||||
dir = '/sys/kernel/pddf/devices/'+validate_type
|
dir = '/sys/kernel/pddf/devices/'+validate_type
|
||||||
if (os.path.exists(dir) or validate_type == 'client'):
|
if (os.path.exists(dir) or validate_type == 'client'):
|
||||||
for sysfs in obj[validate_type]:
|
for sysfs in obj[validate_type]:
|
||||||
if(not os.path.exists(sysfs)):
|
if not os.path.exists(sysfs):
|
||||||
print "[SYSFS FILE] " + sysfs + ": does not exist"
|
print("[SYSFS FILE] " + sysfs + ": does not exist")
|
||||||
else:
|
else:
|
||||||
print "[SYSFS DIR] " + dir + ": does not exist"
|
print("[SYSFS DIR] " + dir + ": does not exist")
|
||||||
|
|
||||||
def validate_dsysfs_creation(self, obj, validate_type):
|
def validate_dsysfs_creation(self, obj, validate_type):
|
||||||
if validate_type in obj.keys():
|
if validate_type in obj.keys():
|
||||||
# There is a possibility that some components dont have any device-self.data attr
|
# There is a possibility that some components dont have any device-self.data attr
|
||||||
if not obj[validate_type]:
|
if not obj[validate_type]:
|
||||||
print "[SYSFS ATTR] for " + validate_type + ": empty"
|
print("[SYSFS ATTR] for " + validate_type + ": empty")
|
||||||
else:
|
else:
|
||||||
for sysfs in obj[validate_type]:
|
for sysfs in obj[validate_type]:
|
||||||
if(not os.path.exists(sysfs)):
|
if not os.path.exists(sysfs):
|
||||||
print "[SYSFS FILE] " + sysfs + ": does not exist"
|
print("[SYSFS FILE] " + sysfs + ": does not exist")
|
||||||
else:
|
else:
|
||||||
print "[SYSFS DIR] " + dir + ": not configured"
|
print("[SYSFS DIR] " + dir + ": not configured")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def verify_sysfs_data(self, verify_type):
|
def verify_sysfs_data(self, verify_type):
|
||||||
if (verify_type == 'LED'):
|
if (verify_type == 'LED'):
|
||||||
@ -887,8 +858,6 @@ class PddfParse():
|
|||||||
if (entry == 'swpld_addr' or entry == 'swpld_addr_offset'):
|
if (entry == 'swpld_addr' or entry == 'swpld_addr_offset'):
|
||||||
self.verify_attr(entry, attr, 'pddf/devices/led')
|
self.verify_attr(entry, attr, 'pddf/devices/led')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def schema_validation(self, validate_type):
|
def schema_validation(self, validate_type):
|
||||||
process_validate_type = 0
|
process_validate_type = 0
|
||||||
for key in self.data.keys():
|
for key in self.data.keys():
|
||||||
@ -898,8 +867,8 @@ class PddfParse():
|
|||||||
try:
|
try:
|
||||||
device_type = self.data[key]["dev_info"]["device_type"]
|
device_type = self.data[key]["dev_info"]["device_type"]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "dev_info or device_type ERROR: " + key
|
print("dev_info or device_type ERROR: " + key)
|
||||||
print e
|
print(e)
|
||||||
|
|
||||||
if validate_type == 'mismatch':
|
if validate_type == 'mismatch':
|
||||||
process_validate_type = 1
|
process_validate_type = 1
|
||||||
@ -914,7 +883,7 @@ class PddfParse():
|
|||||||
elif validate_type == 'empty':
|
elif validate_type == 'empty':
|
||||||
process_validate_type = 1
|
process_validate_type = 1
|
||||||
if not device_type:
|
if not device_type:
|
||||||
print "Empty device_type for " + key
|
print("Empty device_type for " + key)
|
||||||
continue
|
continue
|
||||||
elif (validate_type == 'all' or validate_type == device_type):
|
elif (validate_type == 'all' or validate_type == device_type):
|
||||||
process_validate_type = 1
|
process_validate_type = 1
|
||||||
@ -929,22 +898,22 @@ class PddfParse():
|
|||||||
temp_obj[device_type] = self.data[key]
|
temp_obj[device_type] = self.data[key]
|
||||||
for schema_file in schema_list:
|
for schema_file in schema_list:
|
||||||
if (os.path.exists(schema_file)):
|
if (os.path.exists(schema_file)):
|
||||||
print "Validate " + schema_file + ";" + key
|
print("Validate " + schema_file + ";" + key)
|
||||||
json_data = json.dumps(temp_obj)
|
json_data = json.dumps(temp_obj)
|
||||||
with open(schema_file, 'r') as f:
|
with open(schema_file, 'r') as f:
|
||||||
schema = json.load(f)
|
schema = json.load(f)
|
||||||
try:
|
try:
|
||||||
validate(temp_obj, schema)
|
validate(temp_obj, schema)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "Validation ERROR: " + schema_file + ";" + key
|
print("Validation ERROR: " + schema_file + ";" + key)
|
||||||
if validate_type == 'mismatch':
|
if validate_type == 'mismatch':
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print e
|
print(e)
|
||||||
else:
|
else:
|
||||||
print "ERROR Missing File: " + schema_file
|
print("ERROR Missing File: " + schema_file)
|
||||||
if not process_validate_type:
|
if not process_validate_type:
|
||||||
print "device_type: " + validate_type + " not configured"
|
print("device_type: " + validate_type + " not configured")
|
||||||
|
|
||||||
def modules_validation(self, validate_type):
|
def modules_validation(self, validate_type):
|
||||||
kos = []
|
kos = []
|
||||||
@ -972,27 +941,26 @@ class PddfParse():
|
|||||||
if supported_type:
|
if supported_type:
|
||||||
if module_validation_status:
|
if module_validation_status:
|
||||||
module_validation_status.append(":ERROR not loaded")
|
module_validation_status.append(":ERROR not loaded")
|
||||||
print str(module_validation_status)[1:-1]
|
print(str(module_validation_status)[1:-1])
|
||||||
else:
|
else:
|
||||||
print "Loaded"
|
print("Loaded")
|
||||||
else:
|
else:
|
||||||
print validate_type + " not configured"
|
print(validate_type + " not configured")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
# PARSE DEFS
|
# PARSE DEFS
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
|
|
||||||
def psu_parse(self, dev, ops):
|
def psu_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = ""
|
ret = ""
|
||||||
for ifce in dev['i2c']['interface']:
|
for ifce in dev['i2c']['interface']:
|
||||||
ret = getattr(self, ops['cmd']+"_psu_device")(self.data[ifce['dev']], ops)
|
ret = getattr(self, ops['cmd']+"_psu_device")(self.data[ifce['dev']], ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_psu_device failed".format(ops['cmd'])
|
print("{}_psu_device failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1004,11 +972,11 @@ class PddfParse():
|
|||||||
def fan_parse(self, dev, ops):
|
def fan_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = getattr(self, ops['cmd']+"_fan_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_fan_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_fan_device failed".format(ops['cmd'])
|
print("{}_fan_device failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1021,11 +989,11 @@ class PddfParse():
|
|||||||
def temp_sensor_parse(self, dev, ops):
|
def temp_sensor_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = getattr(self, ops['cmd']+"_temp_sensor_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_temp_sensor_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_temp_sensor_device failed".format(ops['cmd'])
|
print("{}_temp_sensor_device failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1038,11 +1006,11 @@ class PddfParse():
|
|||||||
def cpld_parse(self, dev, ops):
|
def cpld_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = getattr(self, ops['cmd']+"_cpld_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_cpld_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_cpld_device failed".format(ops['cmd'])
|
print("{}_cpld_device failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1052,17 +1020,14 @@ class PddfParse():
|
|||||||
|
|
||||||
return parse_str
|
return parse_str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def sysstatus_parse(self, dev, ops):
|
def sysstatus_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = getattr(self, ops['cmd']+"_sysstatus_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_sysstatus_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_sysstatus_device failed".format(ops['cmd'])
|
print("{}_sysstatus_device failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1075,11 +1040,11 @@ class PddfParse():
|
|||||||
def gpio_parse(self, dev, ops):
|
def gpio_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = getattr(self, ops['cmd']+"_gpio_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_gpio_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_temp_sensor_device failed".format(ops['cmd'])
|
print("{}_temp_sensor_device failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1089,15 +1054,14 @@ class PddfParse():
|
|||||||
|
|
||||||
return parse_str
|
return parse_str
|
||||||
|
|
||||||
|
|
||||||
def mux_parse(self, dev, ops):
|
def mux_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_mux_device() cmd failed".format(ops['cmd'])
|
print("{}_mux_device() cmd failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1106,7 +1070,7 @@ class PddfParse():
|
|||||||
|
|
||||||
for ch in dev['i2c']['channel']:
|
for ch in dev['i2c']['channel']:
|
||||||
ret = self.dev_parse(self.data[ch['dev']], ops)
|
ret = self.dev_parse(self.data[ch['dev']], ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
@ -1121,7 +1085,7 @@ class PddfParse():
|
|||||||
parse_str = ""
|
parse_str = ""
|
||||||
for ch in reversed(dev['i2c']['channel']):
|
for ch in reversed(dev['i2c']['channel']):
|
||||||
ret = self.dev_parse(self.data[ch['dev']], ops)
|
ret = self.dev_parse(self.data[ch['dev']], ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
@ -1132,11 +1096,11 @@ class PddfParse():
|
|||||||
parse_str += ret
|
parse_str += ret
|
||||||
|
|
||||||
ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_mux_device() cmd failed".format(ops['cmd'])
|
print("{}_mux_device() cmd failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1145,15 +1109,14 @@ class PddfParse():
|
|||||||
|
|
||||||
return parse_str
|
return parse_str
|
||||||
|
|
||||||
|
|
||||||
def eeprom_parse(self, dev, ops):
|
def eeprom_parse(self, dev, ops):
|
||||||
parse_str = ""
|
parse_str = ""
|
||||||
ret = getattr(self, ops['cmd']+"_eeprom_device")(dev, ops)
|
ret = getattr(self, ops['cmd']+"_eeprom_device")(dev, ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_eeprom_device() cmd failed".format(ops['cmd'])
|
print("{}_eeprom_device() cmd failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1167,11 +1130,11 @@ class PddfParse():
|
|||||||
ret = ""
|
ret = ""
|
||||||
for ifce in dev['i2c']['interface']:
|
for ifce in dev['i2c']['interface']:
|
||||||
ret = getattr(self, ops['cmd']+"_xcvr_device")(self.data[ifce['dev']], ops)
|
ret = getattr(self, ops['cmd']+"_xcvr_device")(self.data[ifce['dev']], ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
print "{}_eeprom_device() cmd failed".format(ops['cmd'])
|
print("{}_eeprom_device() cmd failed".format(ops['cmd']))
|
||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@ -1185,7 +1148,7 @@ class PddfParse():
|
|||||||
dev1 = self.data[dev['dev']]
|
dev1 = self.data[dev['dev']]
|
||||||
for d in dev1['i2c']['DEVICES']:
|
for d in dev1['i2c']['DEVICES']:
|
||||||
ret = self.dev_parse(self.data[d['dev']], ops)
|
ret = self.dev_parse(self.data[d['dev']], ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
@ -1202,7 +1165,7 @@ class PddfParse():
|
|||||||
dev1 = self.data[dev['dev']]
|
dev1 = self.data[dev['dev']]
|
||||||
for d in dev1['i2c']['DEVICES']:
|
for d in dev1['i2c']['DEVICES']:
|
||||||
ret = self.dev_parse(self.data[d['dev']], ops)
|
ret = self.dev_parse(self.data[d['dev']], ops)
|
||||||
if not ret is None:
|
if ret is not None:
|
||||||
if str(ret).isdigit():
|
if str(ret).isdigit():
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
# in case if 'create' functions
|
# in case if 'create' functions
|
||||||
@ -1213,7 +1176,6 @@ class PddfParse():
|
|||||||
parse_str += ret
|
parse_str += ret
|
||||||
return parse_str
|
return parse_str
|
||||||
|
|
||||||
|
|
||||||
def dev_parse(self, dev, ops):
|
def dev_parse(self, dev, ops):
|
||||||
attr = dev['dev_info']
|
attr = dev['dev_info']
|
||||||
if attr['device_type'] == 'CPU':
|
if attr['device_type'] == 'CPU':
|
||||||
@ -1255,7 +1217,7 @@ class PddfParse():
|
|||||||
return self.sysstatus_parse(dev, ops)
|
return self.sysstatus_parse(dev, ops)
|
||||||
|
|
||||||
def is_supported_sysled_state(self, sysled_name, sysled_state):
|
def is_supported_sysled_state(self, sysled_name, sysled_state):
|
||||||
if not sysled_name in self.data.keys():
|
if sysled_name not in self.data.keys():
|
||||||
return False, "[FAILED] " + sysled_name + " is not configured"
|
return False, "[FAILED] " + sysled_name + " is not configured"
|
||||||
for attr in self.data[sysled_name]['i2c']['attr_list']:
|
for attr in self.data[sysled_name]['i2c']['attr_list']:
|
||||||
if attr['attr_name'] == sysled_state:
|
if attr['attr_name'] == sysled_state:
|
||||||
@ -1288,7 +1250,6 @@ class PddfParse():
|
|||||||
cmd = "echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops"
|
cmd = "echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops"
|
||||||
self.runcmd(cmd)
|
self.runcmd(cmd)
|
||||||
|
|
||||||
|
|
||||||
def led_parse(self, ops):
|
def led_parse(self, ops):
|
||||||
getattr(self, ops['cmd']+"_led_platform_device")("PLATFORM", ops)
|
getattr(self, ops['cmd']+"_led_platform_device")("PLATFORM", ops)
|
||||||
for key in self.data.keys():
|
for key in self.data.keys():
|
||||||
@ -1297,7 +1258,6 @@ class PddfParse():
|
|||||||
if attr['device_type'] == 'LED':
|
if attr['device_type'] == 'LED':
|
||||||
getattr(self, ops['cmd']+"_led_device")(key, ops)
|
getattr(self, ops['cmd']+"_led_device")(key, ops)
|
||||||
|
|
||||||
|
|
||||||
def get_device_list(self, list, type):
|
def get_device_list(self, list, type):
|
||||||
for key in self.data.keys():
|
for key in self.data.keys():
|
||||||
if key != 'PLATFORM' and 'dev_info' in self.data[key]:
|
if key != 'PLATFORM' and 'dev_info' in self.data[key]:
|
||||||
@ -1305,7 +1265,6 @@ class PddfParse():
|
|||||||
if attr['device_type'] == type:
|
if attr['device_type'] == type:
|
||||||
list.append(self.data[key])
|
list.append(self.data[key])
|
||||||
|
|
||||||
|
|
||||||
def create_pddf_devices(self):
|
def create_pddf_devices(self):
|
||||||
self.led_parse({"cmd": "create", "target": "all", "attr": "all"})
|
self.led_parse({"cmd": "create", "target": "all", "attr": "all"})
|
||||||
create_ret = 0
|
create_ret = 0
|
||||||
@ -1338,7 +1297,6 @@ class PddfParse():
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def validate_pddf_devices(self, *args):
|
def validate_pddf_devices(self, *args):
|
||||||
self.populate_pddf_sysfsobj()
|
self.populate_pddf_sysfsobj()
|
||||||
v_ops = {'cmd': 'validate', 'target': 'all', 'attr': 'all'}
|
v_ops = {'cmd': 'validate', 'target': 'all', 'attr': 'all'}
|
||||||
@ -1364,7 +1322,7 @@ class PddfParse():
|
|||||||
field_name = str(bmc_attr['field_name']).strip()
|
field_name = str(bmc_attr['field_name']).strip()
|
||||||
field_pos = int(bmc_attr['field_pos'])-1
|
field_pos = int(bmc_attr['field_pos'])-1
|
||||||
|
|
||||||
if not bmc_cmd in bmc_cache:
|
if bmc_cmd not in bmc_cache:
|
||||||
self.populate_bmc_cache_db(bmc_attr)
|
self.populate_bmc_cache_db(bmc_attr)
|
||||||
else:
|
else:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
@ -1417,7 +1375,7 @@ class PddfParse():
|
|||||||
|
|
||||||
if value != 'N/A':
|
if value != 'N/A':
|
||||||
tmp = ''.join(chr(int(i, 16)) for i in value.split())
|
tmp = ''.join(chr(int(i, 16)) for i in value.split())
|
||||||
tmp = "".join(i for i in unicode(tmp) if unicodedata.category(i)[0]!="C")
|
tmp = "".join(i for i in str(tmp) if unicodedata.category(i)[0] != "C")
|
||||||
value = str(tmp)
|
value = str(tmp)
|
||||||
|
|
||||||
return (value)
|
return (value)
|
||||||
@ -1505,4 +1463,3 @@ class PddfParse():
|
|||||||
output['status'] = True
|
output['status'] = True
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
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)/,$(REDIS_DUMP_LOAD_PY2)) \
|
||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_API_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_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_YANG_MODELS_PY3)) \
|
||||||
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CTRMGRD)) \
|
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CTRMGRD)) \
|
||||||
$(addprefix $(FILES_PATH)/,$($(SONIC_CTRMGRD)_FILES)) \
|
$(addprefix $(FILES_PATH)/,$($(SONIC_CTRMGRD)_FILES)) \
|
||||||
|
Reference in New Issue
Block a user