From 1c13340f8ea067211fb4d141789cee14b9721aa5 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Sat, 23 Jan 2021 00:25:11 -0800 Subject: [PATCH 1/6] [docker-config-engine-stretch]: Add missing dependency PYTHON2_SWSSCOMMON (#6538) Otherwise all the docker image derived from docker-config-engine-stretch will have broken SONIC_CONFIG_ENGINE_PY2 The bug is introduced in #6406 --- rules/docker-config-engine-stretch.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/docker-config-engine-stretch.mk b/rules/docker-config-engine-stretch.mk index 485e10fbb71..ad112bb034d 100644 --- a/rules/docker-config-engine-stretch.mk +++ b/rules/docker-config-engine-stretch.mk @@ -2,6 +2,7 @@ DOCKER_CONFIG_ENGINE_STRETCH = docker-config-engine-stretch.gz $(DOCKER_CONFIG_ENGINE_STRETCH)_PATH = $(DOCKERS_PATH)/docker-config-engine-stretch +$(DOCKER_CONFIG_ENGINE_STRETCH)_DEPENDS += $(LIBSWSSCOMMON) $(PYTHON2_SWSSCOMMON) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SWSSSDK_PY2) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2) From ef6a05f07e70aed9f8e552979c620c5277eec465 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Sat, 23 Jan 2021 00:26:46 -0800 Subject: [PATCH 2/6] [DellEMC Z9332f] Remove duplicate ipmihelper.py script (#6536) Fixes #6445 Because the ipmihelper.py script in the 9332 folder is slightly different than the common one (due to LGTM fixes), when the common one gets copied during build time it causes the workspace/build to become dirty. Signed-off-by: Danny Allen --- .../common/ipmihelper.py | 6 +- .../z9332f/sonic_platform/ipmihelper.py | 269 ------------------ 2 files changed, 3 insertions(+), 272 deletions(-) delete mode 100644 platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py diff --git a/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py b/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py index f70c505d491..ceeaebfbf04 100644 --- a/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py +++ b/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py @@ -38,7 +38,7 @@ def get_ipmitool_raw_output(args): proc.wait() if not proc.returncode: result = stdout.rstrip('\n') - except: + except EnvironmentError: pass for i in result.split(): @@ -180,7 +180,7 @@ def _get_ipmitool_fru_print(self): proc.wait() if not proc.returncode: result = stdout.decode('utf-8').rstrip('\n') - except: + except EnvironmentError: pass return result @@ -253,7 +253,7 @@ def get_fru_data(self, offset, count=1): proc.wait() if not proc.returncode: result = stdout.decode('utf-8').rstrip('\n') - except: + except EnvironmentError: is_valid = False if (not result) or (not is_valid): diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py deleted file mode 100644 index ceeaebfbf04..00000000000 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py +++ /dev/null @@ -1,269 +0,0 @@ -#!/usr/bin/python3 - -######################################################################## -# DellEMC -# -# Module contains implementation of IpmiSensor and IpmiFru classes that -# provide Sensor's and FRU's information respectively. -# -######################################################################## - -import subprocess -import re - -# IPMI Request Network Function Codes -NetFn_SensorEvent = 0x04 -NetFn_Storage = 0x0A - -# IPMI Sensor Device Commands -Cmd_GetSensorReadingFactors = 0x23 -Cmd_GetSensorThreshold = 0x27 -Cmd_GetSensorReading = 0x2D - -# IPMI FRU Device Commands -Cmd_ReadFRUData = 0x11 - -def get_ipmitool_raw_output(args): - """ - Returns a list the elements of which are the individual bytes of - ipmitool raw command output. - """ - result_bytes = list() - result = "" - command = "ipmitool raw {}".format(args) - try: - proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - if not proc.returncode: - result = stdout.rstrip('\n') - except EnvironmentError: - pass - - for i in result.split(): - result_bytes.append(int(i, 16)) - - return result_bytes - -class IpmiSensor(object): - - # Sensor Threshold types and their respective bit masks - THRESHOLD_BIT_MASK = { - "LowerNonCritical" : 0, - "LowerCritical" : 1, - "LowerNonRecoverable" : 2, - "UpperNonCritical" : 3, - "UpperCritical" : 4, - "UpperNonRecoverable" : 5 - } - - def __init__(self, sensor_id, is_discrete=False): - self.id = sensor_id - self.is_discrete = is_discrete - - def _get_converted_sensor_reading(self, raw_value): - """ - Returns a 2 element tuple(bool, int) in which first element - provides the validity of the reading and the second element is - the converted sensor reading - """ - # Get Sensor Reading Factors - cmd_args = "{} {} {} {}".format(NetFn_SensorEvent, - Cmd_GetSensorReadingFactors, - self.id, raw_value) - factors = get_ipmitool_raw_output(cmd_args) - - if len(factors) != 7: - return False, 0 - - # Compute Twos complement - def get_twos_complement(val, bits): - if val & (1 << (bits - 1)): - val = val - (1 << bits) - return val - - # Calculate actual sensor value from the raw sensor value - # using the sensor reading factors. - M = get_twos_complement(((factors[2] & 0xC0) << 8) | factors[1], 10) - B = get_twos_complement(((factors[4] & 0xC0) << 8) | factors[3], 10) - R_exp = get_twos_complement((factors[6] & 0xF0) >> 4, 4) - B_exp = get_twos_complement(factors[6] & 0x0F, 4) - - converted_reading = ((M * raw_value) + (B * 10**B_exp)) * 10**R_exp - - return True, converted_reading - - def get_reading(self): - """ - For Threshold sensors, returns the sensor reading. - For Discrete sensors, returns the state value. - - Returns: - A tuple (bool, int) where the first element provides the - validity of the reading and the second element provides the - sensor reading/state value. - """ - # Get Sensor Reading - cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorReading, - self.id) - output = get_ipmitool_raw_output(cmd_args) - if len(output) != 4: - return False, 0 - - # Check reading/state unavailable - if output[1] & 0x20: - return False, 0 - - if self.is_discrete: - state = ((output[3] & 0x7F) << 8) | output[2] - return True, state - else: - return self._get_converted_sensor_reading(output[0]) - - def get_threshold(self, threshold_type): - """ - Returns the sensor's threshold value for a given threshold type. - - Args: - threshold_type (str) - one of the below mentioned - threshold type strings - - "LowerNonCritical" - "LowerCritical" - "LowerNonRecoverable" - "UpperNonCritical" - "UpperCritical" - "UpperNonRecoverable" - Returns: - A tuple (bool, int) where the first element provides the - validity of that threshold and second element provides the - threshold value. - """ - # Thresholds are not valid for discrete sensors - if self.is_discrete: - raise TypeError("Threshold is not applicable for Discrete Sensor") - - if threshold_type not in list(self.THRESHOLD_BIT_MASK.keys()): - raise ValueError("Invalid threshold type {} provided. Valid types " - "are {}".format(threshold_type, - list(self.THRESHOLD_BIT_MASK.keys()))) - - bit_mask = self.THRESHOLD_BIT_MASK[threshold_type] - - # Get Sensor Threshold - cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorThreshold, - self.id) - thresholds = get_ipmitool_raw_output(cmd_args) - if len(thresholds) != 7: - return False, 0 - - valid_thresholds = thresholds.pop(0) - # Check whether particular threshold is readable - if valid_thresholds & (1 << bit_mask): - return self._get_converted_sensor_reading(thresholds[bit_mask]) - else: - return False, 0 - -class IpmiFru(object): - - def __init__(self, fru_id): - self.id = fru_id - - def _get_ipmitool_fru_print(self): - result = "" - command = "ipmitool fru print {}".format(self.id) - try: - proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - if not proc.returncode: - result = stdout.decode('utf-8').rstrip('\n') - except EnvironmentError: - pass - - return result - - def _get_from_fru(self, info): - """ - Returns a string containing the info from FRU - """ - fru_output = self._get_ipmitool_fru_print() - if not fru_output: - return "NA" - - info_req = re.search(r"%s\s*:(.*)" % info, fru_output) - if not info_req: - return "NA" - - return info_req.group(1).strip() - - def get_board_serial(self): - """ - Returns a string containing the Serial Number of the device. - """ - return self._get_from_fru('Board Serial') - - def get_board_part_number(self): - """ - Returns a string containing the Part Number of the device. - """ - return self._get_from_fru('Board Part Number') - - def get_board_mfr_id(self): - """ - Returns a string containing the manufacturer id of the FRU. - """ - return self._get_from_fru('Board Mfg') - - def get_board_product(self): - """ - Returns a string containing the manufacturer id of the FRU. - """ - return self._get_from_fru('Board Product') - - def get_fru_data(self, offset, count=1): - """ - Reads and returns the FRU data at the provided offset. - - Args: - offset (int) - FRU offset to read - count (int) - Number of bytes to read [optional, default = 1] - Returns: - A tuple (bool, list(int)) where the first element provides - the validity of the data read and the second element is a - list, the elements of which are the individual bytes of the - FRU data read. - """ - result_bytes = list() - is_valid = True - result = "" - - offset_LSB = offset & 0xFF - offset_MSB = offset & 0xFF00 - command = "ipmitool raw {} {} {} {} {} {}".format(NetFn_Storage, - Cmd_ReadFRUData, - self.id, offset_LSB, - offset_MSB, count) - try: - proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - if not proc.returncode: - result = stdout.decode('utf-8').rstrip('\n') - except EnvironmentError: - is_valid = False - - if (not result) or (not is_valid): - return False, result_bytes - - for i in result.split(): - result_bytes.append(int(i, 16)) - - read_count = result_bytes.pop(0) - if read_count != count: - return False, result_bytes - else: - return True, result_bytes From 4a8e5134607c9ec9655ef43fc6990a474605bdd2 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sat, 23 Jan 2021 00:28:04 -0800 Subject: [PATCH 3/6] [sonic-platform-daemons] Update submodule (#6535) Submodule changes to be committed: * src/sonic-platform-daemons 81318f7...e72f6cd (3): > [ledd] Minor refactor; add unit tests (#143) > [thermalctld] Report unit test coverage (#141) > [psud] Increase unit test coverage (#140) --- src/sonic-platform-daemons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index 81318f7afdb..e72f6cd9588 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit 81318f7afdb65bd15af387c97152948d22cf9834 +Subproject commit e72f6cd958810e3af9b18a71bc078dbb8c5d6cac From d4cde6d31071eea035f9fbfcbc55184d03e080b3 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sat, 23 Jan 2021 00:29:13 -0800 Subject: [PATCH 4/6] [process-reboot-cause] Make process-reboot-cause executable (#6534) process-reboot-cause script should be executable. --- src/sonic-host-services/scripts/process-reboot-cause | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/sonic-host-services/scripts/process-reboot-cause diff --git a/src/sonic-host-services/scripts/process-reboot-cause b/src/sonic-host-services/scripts/process-reboot-cause old mode 100644 new mode 100755 From 8ce1e3ed92ed0e141bd74d99f76af61e34b96ffd Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Sat, 23 Jan 2021 00:29:35 -0800 Subject: [PATCH 5/6] [build-docker-buster]: Install libboost 1.171 In Build Docker (#6532) Installing newst buster version of libboost (v1.71) in build docker. signed-off-by: Tamer Ahmed --- sonic-slave-buster/Dockerfile.j2 | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 61ece64a113..0890f0b68c6 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -61,7 +61,6 @@ RUN apt-get update && apt-get install -y \ dh-exec \ kmod \ libtinyxml2-6a \ - libboost-program-options1.67-dev \ libtinyxml2-dev \ python \ python-pip \ @@ -121,7 +120,6 @@ RUN apt-get update && apt-get install -y \ module-assistant \ # For thrift build\ gem2deb \ - libboost-all-dev \ libevent-dev \ libglib2.0-dev \ libqt4-dev \ @@ -321,7 +319,27 @@ RUN apt-get update && apt-get install -y \ docbook-to-man \ docbook-utils \ # For kdump-tools - libbz2-dev + libbz2-dev \ +# For linkmgrd + libboost1.71-dev \ + libboost-program-options1.71-dev \ + libboost-system1.71-dev \ + libboost-thread1.71-dev \ + libboost-atomic1.71-dev \ + libboost-chrono1.71-dev \ + libboost-container1.71-dev \ + libboost-context1.71-dev \ + libboost-contract1.71-dev \ + libboost-coroutine1.71-dev \ + libboost-date-time1.71-dev \ + libboost-fiber1.71-dev \ + libboost-filesystem1.71-dev \ + libboost-graph-parallel1.71-dev \ + libboost-log1.71-dev \ + libboost-regex1.71-dev \ + googletest \ + libgtest-dev \ + libgcc-8-dev # Build fix for ARMHF buster libsairedis {%- if CONFIGURED_ARCH == "armhf" %} From 238803d6bfe7959604c883b3e31468f46c6a1714 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sat, 23 Jan 2021 00:32:06 -0800 Subject: [PATCH 6/6] [sonic-host-services] Report unit test coverage (#6533) To view unit test coverage of sonic-host-services package upon build --- src/sonic-host-services/pytest.ini | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/sonic-host-services/pytest.ini diff --git a/src/sonic-host-services/pytest.ini b/src/sonic-host-services/pytest.ini new file mode 100644 index 00000000000..83b74d373c0 --- /dev/null +++ b/src/sonic-host-services/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml