From 909a7e94bba1cb3787a2b62063930c22a71f5582 Mon Sep 17 00:00:00 2001 From: roylee123 Date: Fri, 22 Dec 2017 10:54:30 +0800 Subject: [PATCH 1/3] Update sonic-platform-modules-accton to lastest Signed-off-by: roylee123 --- platform/broadcom/sonic-platform-modules-accton | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-accton b/platform/broadcom/sonic-platform-modules-accton index 7ba26ec403c7..e66b74fcf7a9 160000 --- a/platform/broadcom/sonic-platform-modules-accton +++ b/platform/broadcom/sonic-platform-modules-accton @@ -1 +1 @@ -Subproject commit 7ba26ec403c7f0d0acb958f794311ac3fd1af9a1 +Subproject commit e66b74fcf7a943d8c7c8f241a8221eca65171ced From a40d2d9781bf68d45bf8681256fbbe283e110e6d Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Mon, 22 Jan 2018 10:52:52 -0800 Subject: [PATCH 2/3] Install sonic-platform-common package in platform-monitor docker for ledd (#1330) * Install sonic-platform-common package in platform-monitor docker for ledd * Specify Python wheel dependencies in docker-platform-monitor.mk; Remove explicit specifications from Dockerfile.j2 --- dockers/docker-platform-monitor/Dockerfile.j2 | 48 +++++++------------ rules/docker-platform-monitor.mk | 2 + 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/dockers/docker-platform-monitor/Dockerfile.j2 b/dockers/docker-platform-monitor/Dockerfile.j2 index b6406b3e3a6a..4dd8acaf0e26 100755 --- a/dockers/docker-platform-monitor/Dockerfile.j2 +++ b/dockers/docker-platform-monitor/Dockerfile.j2 @@ -9,44 +9,30 @@ RUN apt-get update # Install required packages RUN apt-get install -y python-pip sensord fancontrol -{% if docker_platform_monitor_debs.strip() %} -# Copy built Debian packages -COPY \ -{% for deb in docker_platform_monitor_debs.split(' ') -%} +{% if docker_platform_monitor_debs.strip() -%} +# Copy all locally-built Debian package dependencies +COPY{{' '}} +{%- for deb in docker_platform_monitor_debs.split(' ') -%} debs/{{ deb }}{{' '}} {%- endfor -%} -debs/ -{%- endif %} +/debs/ -{% if docker_platform_monitor_debs.strip() %} -# Install built Debian packages -RUN dpkg -i \ -{% for deb in docker_platform_monitor_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor %} -{%- endif %} +# Install all locally-built Debian package dependencies +# and implicitly install their dependencies +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/*.deb +{% endif %} -{% if docker_platform_monitor_whls.strip() %} -# Copy built Python wheels -COPY \ -{% for whl in docker_platform_monitor_whls.split(' ') -%} +{% if docker_platform_monitor_whls.strip() -%} +# Copy all locally-built Python wheel dependencies +COPY{{' '}} +{%- for whl in docker_platform_monitor_whls.split(' ') -%} python-wheels/{{ whl }}{{' '}} {%- endfor -%} -python-wheels/ -{%- endif %} - -{% if docker_platform_monitor_whls.strip() %} -# Install built Python wheels -RUN pip install \ -{% for whl in docker_platform_monitor_whls.split(' ') -%} -python-wheels/{{ whl }}{{' '}} -{%- endfor %} -{%- endif %} - -COPY python-wheels /python-wheels +/python-wheels/ -# Install Python SwSS SDK (dependency of sonic-ledd) -RUN pip install /python-wheels/swsssdk-2.0.1-py2-none-any.whl +# Install all locally-built Python wheel dependencies +RUN pip install /python-wheels/*.whl +{% endif %} # Clean up RUN apt-get remove -y python-pip diff --git a/rules/docker-platform-monitor.mk b/rules/docker-platform-monitor.mk index 76e7dac4ab63..345e82f7b86f 100644 --- a/rules/docker-platform-monitor.mk +++ b/rules/docker-platform-monitor.mk @@ -3,6 +3,8 @@ DOCKER_PLATFORM_MONITOR = docker-platform-monitor.gz $(DOCKER_PLATFORM_MONITOR)_PATH = $(DOCKERS_PATH)/docker-platform-monitor $(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(SONIC_LEDD) +$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2) +$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2) $(DOCKER_PLATFORM_MONITOR)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE) SONIC_DOCKER_IMAGES += $(DOCKER_PLATFORM_MONITOR) From 5c11d4934be3915a58df317a95be96ea15df68eb Mon Sep 17 00:00:00 2001 From: roy_lee Date: Wed, 7 Mar 2018 11:18:47 +0800 Subject: [PATCH 3/3] [As7816-64x] Validate psuutil and psuutil. Signed-off-by: roy_lee --- .../plugins/psuutil.py | 61 +++++++++++++++++++ .../plugins/sfputil.py | 14 ++--- .../broadcom/sonic-platform-modules-accton | 2 +- 3 files changed, 67 insertions(+), 10 deletions(-) create mode 100755 device/accton/x86_64-accton_as7816_64x-r0/plugins/psuutil.py diff --git a/device/accton/x86_64-accton_as7816_64x-r0/plugins/psuutil.py b/device/accton/x86_64-accton_as7816_64x-r0/plugins/psuutil.py new file mode 100755 index 000000000000..707c7c897c82 --- /dev/null +++ b/device/accton/x86_64-accton_as7816_64x-r0/plugins/psuutil.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +############################################################################# +# Accton +# +# Module contains an implementation of SONiC PSU Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +import os.path + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +class PsuUtil(PsuBase): + """Platform-specific PSUutil class""" + + def __init__(self): + PsuBase.__init__(self) + + self.psu_path = "/sys/bus/i2c/devices/" + self.psu_presence = "/psu_present" + self.psu_oper_status = "/psu_power_good" + self.psu_mapping = { + 1: "10-0053", + 2: "9-0050", + } + + def get_num_psus(self): + return len(self.psu_mapping) + + def get_psu_status(self, index): + if index is None: + return False + + status = 0 + node = self.psu_path + self.psu_mapping[index]+self.psu_oper_status + try: + with open(node, 'r') as power_status: + status = int(power_status.read()) + except IOError: + return False + + return status == 1 + + def get_psu_presence(self, index): + if index is None: + return False + + status = 0 + node = self.psu_path + self.psu_mapping[index] + self.psu_presence + try: + with open(node, 'r') as presence_status: + status = int(presence_status.read()) + except IOError: + return False + + return status == 1 diff --git a/device/accton/x86_64-accton_as7816_64x-r0/plugins/sfputil.py b/device/accton/x86_64-accton_as7816_64x-r0/plugins/sfputil.py index 7c82583c26bb..26c2b37c6722 100644 --- a/device/accton/x86_64-accton_as7816_64x-r0/plugins/sfputil.py +++ b/device/accton/x86_64-accton_as7816_64x-r0/plugins/sfputil.py @@ -94,9 +94,8 @@ def reset(self, port_num): # Check for invalid port_num if port_num < self._port_start or port_num > self._port_end: return False - - path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset" - port_ps = path.format(self.port_to_i2c_mapping[port_num+1]) + path = "/sys/bus/i2c/devices/19-0060/module_reset_{0}" + port_ps = path.format(port_num+1) try: reg_file = open(port_ps, 'w') @@ -104,20 +103,17 @@ def reset(self, port_num): print "Error: unable to open file: %s" % str(e) return False - #toggle reset + #HW will clear reset after set. reg_file.seek(0) reg_file.write('1') - time.sleep(1) - reg_file.seek(0) - reg_file.write('0') reg_file.close() return True def set_low_power_mode(self, port_nuM, lpmode): - raise NotImplementedErro + raise NotImplementedError def get_low_power_mode(self, port_num): - raise NotImplementedErro + raise NotImplementedError def get_presence(self, port_num): # Check for invalid port_num diff --git a/platform/broadcom/sonic-platform-modules-accton b/platform/broadcom/sonic-platform-modules-accton index 5c48c84b0f3f..aaaea8d12838 160000 --- a/platform/broadcom/sonic-platform-modules-accton +++ b/platform/broadcom/sonic-platform-modules-accton @@ -1 +1 @@ -Subproject commit 5c48c84b0f3f5ee8b44f02ff3e0c3d1ad2169066 +Subproject commit aaaea8d12838de634fd27e936e4086258933cbac