From 648330668b8224e6e8ce04f829111c94d591433e Mon Sep 17 00:00:00 2001 From: sridhar-ravindran <45350577+sridhar-ravindran@users.noreply.github.com> Date: Thu, 25 Jul 2019 00:45:46 +0530 Subject: [PATCH] [DELLEMC][S6000] 201811 Porting of Platform 2.0 Reboot Reason (#3156) Added Reboot Reason for S6000 in platform 2.0 Fixed issue in process-reboot-cause Added package uninstall code in platform de-init code for z9100, s6100 - How I did it -> Added support for S6000 Reboot Reason -> Added platform.py for all platforms -> Verified show reboot-cause command with the code changes. Added UT logs with show reboot-cause -> Modified process-reboot-cause service to start after pmon.service. In S6000, we have to wait for nvram to be loaded. -> If reboot-cause service starts before pmon.service, show reboot-cause is showing incorrect reason. -> Bug fix in process-reboot-cause file - import sonic_platform + import sonic_platform.platform --- .../debian/platform-modules-s6000.init | 84 +++------------- .../debian/platform-modules-s6000.install | 4 + .../sonic-platform-modules-dell/debian/rules | 8 ++ .../s6000/modules/dell_s6000_platform.c | 23 +++++ .../s6000/scripts/s6000_platform.sh | 98 +++++++++++++++++++ .../s6000/setup.py | 1 + .../s6000/sonic_platform/__init__.py | 2 + .../s6000/sonic_platform/chassis.py | 61 ++++++++++++ .../s6000/sonic_platform/platform.py | 26 +++++ .../systemd/platform-modules-s6000.service | 4 +- .../s6100/scripts/s6100_platform.sh | 9 +- .../s6100/sonic_platform/__init__.py | 3 +- .../s6100/sonic_platform/platform.py | 26 +++++ .../z9100/scripts/z9100_platform.sh | 9 +- .../z9100/sonic_platform/__init__.py | 4 +- .../z9100/sonic_platform/platform.py | 26 +++++ 16 files changed, 310 insertions(+), 78 deletions(-) create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6000/scripts/s6000_platform.sh create mode 120000 platform/broadcom/sonic-platform-modules-dell/s6000/setup.py create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/platform.py create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/platform.py mode change 120000 => 100755 platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/platform.py diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.init b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.init index f16f7e01ef6e..94bddb6afe20 100755 --- a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.init +++ b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.init @@ -11,89 +11,29 @@ # Short-Description: Setup S6000 board. ### END INIT INFO -add_i2c_devices() { - - echo 24c02 0x50 > /sys/class/i2c-adapter/i2c-1/new_device - echo 24c02 0x51 > /sys/class/i2c-adapter/i2c-1/new_device - echo dni_dps460 0x58 > /sys/class/i2c-adapter/i2c-1/new_device - echo dni_dps460 0x59 > /sys/class/i2c-adapter/i2c-1/new_device - echo jc42 0x18 > /sys/class/i2c-adapter/i2c-10/new_device - echo emc1403 0x4d > /sys/class/i2c-adapter/i2c-10/new_device - echo spd 0x50 > /sys/class/i2c-adapter/i2c-10/new_device - echo 24c02 0x53 > /sys/class/i2c-adapter/i2c-10/new_device - echo max6620 0x29 > /sys/class/i2c-adapter/i2c-11/new_device - echo max6620 0x2a > /sys/class/i2c-adapter/i2c-11/new_device - echo ltc4215 0x40 > /sys/class/i2c-adapter/i2c-11/new_device - echo ltc4215 0x42 > /sys/class/i2c-adapter/i2c-11/new_device - echo tmp75 0x4c > /sys/class/i2c-adapter/i2c-11/new_device - echo tmp75 0x4d > /sys/class/i2c-adapter/i2c-11/new_device - echo tmp75 0x4e > /sys/class/i2c-adapter/i2c-11/new_device - echo 24c02 0x51 > /sys/class/i2c-adapter/i2c-11/new_device - echo 24c02 0x52 > /sys/class/i2c-adapter/i2c-11/new_device - echo 24c02 0x53 > /sys/class/i2c-adapter/i2c-11/new_device - for i in `seq 0 31`; do - echo sff8436 0x50 > /sys/class/i2c-adapter/i2c-$((20+i))/new_device - done -} - -remove_i2c_devices() { - echo 0x50 > /sys/class/i2c-adapter/i2c-1/delete_device - echo 0x51 > /sys/class/i2c-adapter/i2c-1/delete_device - echo 0x58 > /sys/class/i2c-adapter/i2c-1/delete_device - echo 0x59 > /sys/class/i2c-adapter/i2c-1/delete_device - echo 0x18 > /sys/class/i2c-adapter/i2c-10/delete_device - echo 0x4d > /sys/class/i2c-adapter/i2c-10/delete_device - echo 0x50 > /sys/class/i2c-adapter/i2c-10/delete_device - echo 0x53 > /sys/class/i2c-adapter/i2c-10/delete_device - echo 0x29 > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x2a > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x40 > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x42 > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x4c > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x4d > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x4e > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x51 > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x52 > /sys/class/i2c-adapter/i2c-11/delete_device - echo 0x53 > /sys/class/i2c-adapter/i2c-11/delete_device - for i in `seq 0 31`; do - echo 0x50 > /sys/class/i2c-adapter/i2c-$((20+i))/delete_device - done -} - case "$1" in start) - echo -n "Setting up board... " - - depmod -a - modprobe i2c_mux_gpio - modprobe dell_s6000_platform + echo -n "Setting up board... " - add_i2c_devices + /usr/local/bin/s6000_platform.sh init - /usr/local/bin/set-fan-speed 15000 - /usr/local/bin/reset-qsfp - - echo "done." - ;; + echo "done." + ;; stop) - echo "done." - - remove_i2c_devices + /usr/local/bin/s6000_platform.sh deinit + echo "done." - rmmod dell_s6000_platform - rmmod i2c_mux_gpio - ;; + ;; force-reload|restart) - echo "Not supported" - ;; + echo "Not supported" + ;; *) - echo "Usage: /etc/init.d/platform-modules-s6000.init {start|stop}" - exit 1 - ;; + echo "Usage: /etc/init.d/platform-modules-s6000.init {start|stop}" + exit 1 + ;; esac exit 0 - diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install index 63eeddf04e96..c2dcb5dc03a9 100644 --- a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install +++ b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install @@ -1,2 +1,6 @@ +s6000/scripts/s6000_platform.sh usr/local/bin +s6000/scripts/reset-qsfp usr/local/bin +s6000/scripts/set-fan-speed usr/local/bin s6000/systemd/platform-modules-s6000.service etc/systemd/system common/io_rd_wr.py usr/local/bin +s6000/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0 diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/rules b/platform/broadcom/sonic-platform-modules-dell/debian/rules index 55b336c7413e..4db58cc74449 100755 --- a/platform/broadcom/sonic-platform-modules-dell/debian/rules +++ b/platform/broadcom/sonic-platform-modules-dell/debian/rules @@ -25,6 +25,10 @@ override_dh_auto_build: cd $(MOD_SRC_DIR)/$${mod}; \ python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ cd $(MOD_SRC_DIR); \ + elif [ $$mod = "s6000" ]; then \ + cd $(MOD_SRC_DIR)/$${mod}; \ + python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + cd $(MOD_SRC_DIR); \ fi; \ echo "making man page alias $$mod -> $$mod APIs";\ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ @@ -59,6 +63,10 @@ override_dh_clean: rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \ rm -rf $(MOD_SRC_DIR)/$${mod}/build; \ rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \ + elif [ $$mod = "s6000" ]; then \ + rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/build; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \ fi; \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ done) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/modules/dell_s6000_platform.c b/platform/broadcom/sonic-platform-modules-dell/s6000/modules/dell_s6000_platform.c index 5e205973d674..8c0a13e8e1ca 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/modules/dell_s6000_platform.c +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/modules/dell_s6000_platform.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #define S6000_MUX_BASE_NR 10 #define QSFP_MODULE_BASE_NR 20 @@ -20,6 +22,7 @@ #define QSFP_MODULE_NUM 16 #define QSFP_DEVICE_NUM 2 +#define RTC_NVRAM_REBOOT_REASON_OFFSET 0x49 static void device_release(struct device *dev) { @@ -1061,6 +1064,24 @@ static ssize_t get_slave_cpld_ver(struct device *dev, return sprintf(buf, "0x%x\n", data); } +static ssize_t get_reboot_reason(struct device *dev, + struct device_attribute *devattr, char *buf) +{ + uint8_t data = 0; + + /* Last Reboot reason in saved in RTC NVRAM offset 0x49 + * We write the reboot reason into nvram offset, + * as part of platform_reboot implementation from userspace. + + * COLD_RESET = 0xE # Cold Reset (value) + * WARM_RESET = 0x6 # Warm Reset (value) + */ + + /* Read it from this offset, and export it as last_reboot_reason */ + data = nvram_read_byte(RTC_NVRAM_REBOOT_REASON_OFFSET); + + return sprintf(buf, "0x%x\n", data); +} static DEVICE_ATTR(qsfp_modsel, S_IRUGO, get_modsel, NULL); static DEVICE_ATTR(qsfp_modprs, S_IRUGO, get_modprs, NULL); @@ -1083,6 +1104,7 @@ static DEVICE_ATTR(fan2_led, S_IRUGO | S_IWUSR, get_fan2_led, set_fan2_led); static DEVICE_ATTR(system_cpld_ver, S_IRUGO, get_system_cpld_ver, NULL); static DEVICE_ATTR(master_cpld_ver, S_IRUGO, get_master_cpld_ver, NULL); static DEVICE_ATTR(slave_cpld_ver, S_IRUGO, get_slave_cpld_ver, NULL); +static DEVICE_ATTR(last_reboot_reason, S_IRUGO, get_reboot_reason, NULL); static struct attribute *s6000_cpld_attrs[] = { &dev_attr_qsfp_modsel.attr, @@ -1106,6 +1128,7 @@ static struct attribute *s6000_cpld_attrs[] = { &dev_attr_system_cpld_ver.attr, &dev_attr_master_cpld_ver.attr, &dev_attr_slave_cpld_ver.attr, + &dev_attr_last_reboot_reason.attr, NULL, }; diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/s6000_platform.sh b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/s6000_platform.sh new file mode 100755 index 000000000000..316fbaec5fee --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/s6000_platform.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +### BEGIN INIT INFO +# Provides: setup-board +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Setup S6000 board. +### END INIT INFO + +add_i2c_devices() { + + echo 24c02 0x50 > /sys/class/i2c-adapter/i2c-1/new_device + echo 24c02 0x51 > /sys/class/i2c-adapter/i2c-1/new_device + echo dni_dps460 0x58 > /sys/class/i2c-adapter/i2c-1/new_device + echo dni_dps460 0x59 > /sys/class/i2c-adapter/i2c-1/new_device + echo jc42 0x18 > /sys/class/i2c-adapter/i2c-10/new_device + echo emc1403 0x4d > /sys/class/i2c-adapter/i2c-10/new_device + echo spd 0x50 > /sys/class/i2c-adapter/i2c-10/new_device + echo 24c02 0x53 > /sys/class/i2c-adapter/i2c-10/new_device + echo max6620 0x29 > /sys/class/i2c-adapter/i2c-11/new_device + echo max6620 0x2a > /sys/class/i2c-adapter/i2c-11/new_device + echo ltc4215 0x40 > /sys/class/i2c-adapter/i2c-11/new_device + echo ltc4215 0x42 > /sys/class/i2c-adapter/i2c-11/new_device + echo tmp75 0x4c > /sys/class/i2c-adapter/i2c-11/new_device + echo tmp75 0x4d > /sys/class/i2c-adapter/i2c-11/new_device + echo tmp75 0x4e > /sys/class/i2c-adapter/i2c-11/new_device + echo 24c02 0x51 > /sys/class/i2c-adapter/i2c-11/new_device + echo 24c02 0x52 > /sys/class/i2c-adapter/i2c-11/new_device + echo 24c02 0x53 > /sys/class/i2c-adapter/i2c-11/new_device + for i in `seq 0 31`; do + echo sff8436 0x50 > /sys/class/i2c-adapter/i2c-$((20+i))/new_device + done +} + +remove_i2c_devices() { + echo 0x50 > /sys/class/i2c-adapter/i2c-1/delete_device + echo 0x51 > /sys/class/i2c-adapter/i2c-1/delete_device + echo 0x58 > /sys/class/i2c-adapter/i2c-1/delete_device + echo 0x59 > /sys/class/i2c-adapter/i2c-1/delete_device + echo 0x18 > /sys/class/i2c-adapter/i2c-10/delete_device + echo 0x4d > /sys/class/i2c-adapter/i2c-10/delete_device + echo 0x50 > /sys/class/i2c-adapter/i2c-10/delete_device + echo 0x53 > /sys/class/i2c-adapter/i2c-10/delete_device + echo 0x29 > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x2a > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x40 > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x42 > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x4c > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x4d > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x4e > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x51 > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x52 > /sys/class/i2c-adapter/i2c-11/delete_device + echo 0x53 > /sys/class/i2c-adapter/i2c-11/delete_device + for i in `seq 0 31`; do + echo 0x50 > /sys/class/i2c-adapter/i2c-$((20+i))/delete_device + done +} + +install_python_api_package() { + device="/usr/share/sonic/device" + platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + + if [ -e $device/$platform/sonic_platform-1.0-py2-none-any.whl ]; then + rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl) + fi +} + +remove_python_api_package() { + rv=$(pip show sonic-platform > /dev/null 2>/dev/null) + if [ $? -eq 0 ]; then + rv = $(pip uninstall -y sonic-platform > /dev/null 2>/dev/null) + fi +} + +if [[ "$1" == "init" ]]; then + depmod -a + modprobe nvram + modprobe i2c_mux_gpio + modprobe dell_s6000_platform + install_python_api_package + + add_i2c_devices + + /usr/local/bin/set-fan-speed 15000 + /usr/local/bin/reset-qsfp +elif [[ "$1" == "deinit" ]]; then + remove_i2c_devices + rmmod dell_s6000_platform + rmmod nvram + rmmod i2c_mux_gpio + remove_python_api_package +else + echo "s6000_platform : Invalid option !" +fi diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/setup.py b/platform/broadcom/sonic-platform-modules-dell/s6000/setup.py new file mode 120000 index 000000000000..4f6de9941d96 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/setup.py @@ -0,0 +1 @@ +../s6100/setup.py \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py new file mode 100755 index 000000000000..d82f3749319c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = ["platform", "chassis"] +from sonic_platform import * diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py new file mode 100755 index 000000000000..b1046d9310f8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + import os + from sonic_platform_base.chassis_base import ChassisBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Chassis(ChassisBase): + """ + DELLEMC Platform-specific Chassis class + """ + + MAILBOX_DIR = "/sys/devices/platform/dell-s6000-cpld.0" + + reset_reason_dict = {} + reset_reason_dict[0xe] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE + reset_reason_dict[0x6] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE + + def __init__(self): + ChassisBase.__init__(self) + + def get_register(self, reg_name): + rv = 'ERR' + mb_reg_file = self.MAILBOX_DIR+'/'+reg_name + + if (not os.path.isfile(mb_reg_file)): + return rv + + try: + with open(mb_reg_file, 'r') as fd: + rv = fd.read() + except Exception as error: + rv = 'ERR' + + rv = rv.rstrip('\r\n') + rv = rv.lstrip(" ") + return rv + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + """ + reset_reason = int(self.get_register('last_reboot_reason'), base=16) + + # In S6000, We track the reboot reason by writing the reason in + # NVRAM. Only Warmboot and Coldboot reason are supported here. + + if (reset_reason in self.reset_reason_dict): + return (self.reset_reason_dict[reset_reason], None) + + return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Invalid Reason") + diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/platform.py new file mode 100755 index 000000000000..426db717281b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/platform.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + import os + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + """ + DELLEMC Platform-specific class + """ + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() + diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service b/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service index 246dee9b64f3..b55a466890bd 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service @@ -5,8 +5,8 @@ Before=pmon.service [Service] Type=oneshot -ExecStart=-/etc/init.d/platform-modules-s6000 start -ExecStop=-/etc/init.d/platform-modules-s6000 stop +ExecStart=/usr/local/bin/s6000_platform.sh init +ExecStop=/usr/local/bin/s6000_platform.sh deinit RemainAfterExit=yes [Install] diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh index 3b455a9bf933..71a5d269fec0 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh @@ -222,7 +222,13 @@ install_python_api_package() { platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl) - echo "pip install result = $rv" +} + +remove_python_api_package() { + rv=$(pip show sonic-platform > /dev/null 2>/dev/null) + if [ $? -eq 0 ]; then + rv = $(pip uninstall -y sonic-platform > /dev/null 2>/dev/null) + fi } init_devnum @@ -261,6 +267,7 @@ elif [[ "$1" == "deinit" ]]; then modprobe -r i2c-mux-pca954x modprobe -r i2c-dev modprobe -r dell_ich + remove_python_api_package else echo "s6100_platform : Invalid option !" fi diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py index 139597f9cb07..4bfefa0fb636 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py @@ -1,2 +1,3 @@ - +__all__ = ["platform", "chassis"] +from sonic_platform import * diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/platform.py new file mode 100755 index 000000000000..426db717281b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/platform.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + import os + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + """ + DELLEMC Platform-specific class + """ + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() + diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/scripts/z9100_platform.sh b/platform/broadcom/sonic-platform-modules-dell/z9100/scripts/z9100_platform.sh index a98da8ff2fbc..276acd882f14 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/scripts/z9100_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/scripts/z9100_platform.sh @@ -205,7 +205,13 @@ install_python_api_package() { platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl) - echo "pip install result = $rv" +} + +remove_python_api_package() { + rv=$(pip show sonic-platform > /dev/null 2>/dev/null) + if [ $? -eq 0 ]; then + rv = $(pip uninstall -y sonic-platform > /dev/null 2>/dev/null) + fi } init_devnum @@ -250,6 +256,7 @@ elif [[ "$1" == "deinit" ]]; then modprobe -r i2c-mux-pca954x modprobe -r i2c-dev modprobe -r dell_ich + remove_python_api_package else echo "z9100_platform : Invalid option !" fi diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py deleted file mode 120000 index 9972084d4dfb..000000000000 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py +++ /dev/null @@ -1 +0,0 @@ -../../s6100/sonic_platform/__init__.py \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py new file mode 100755 index 000000000000..4bfefa0fb636 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py @@ -0,0 +1,3 @@ +__all__ = ["platform", "chassis"] +from sonic_platform import * + diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/platform.py new file mode 100755 index 000000000000..426db717281b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/platform.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + import os + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + """ + DELLEMC Platform-specific class + """ + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() +