From 72412e149b25240456be6200daa769e52d3c8f03 Mon Sep 17 00:00:00 2001 From: Jackie Huang Date: Mon, 9 Dec 2024 14:22:59 +0800 Subject: [PATCH] patches-arm: add patches based on stx.9.0 for config Add patches based on stx.9.0 for config repo: https://opendev.org/starlingx/config.git Issue-ID: INF-481 Signed-off-by: Jackie Huang Change-Id: I45477666e7167afefaa35ce7430d7d80e864a4d4 --- .../0001-sysinv-fix-the-console-for-arm64.patch | 113 +++++++++++++++++++++ ...nv-agent-get-cpu-model-from-lscpu-for-Arm.patch | 84 +++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0001-sysinv-fix-the-console-for-arm64.patch create mode 100644 scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0002-sysinv-agent-get-cpu-model-from-lscpu-for-Arm.patch diff --git a/scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0001-sysinv-fix-the-console-for-arm64.patch b/scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0001-sysinv-fix-the-console-for-arm64.patch new file mode 100644 index 00000000..76bb1b38 --- /dev/null +++ b/scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0001-sysinv-fix-the-console-for-arm64.patch @@ -0,0 +1,113 @@ +From ad5f1615e2aa6b1029b183b9c062d47e270150ad Mon Sep 17 00:00:00 2001 +From: Jackie Huang +Date: Fri, 26 May 2023 17:08:02 +0800 +Subject: [PATCH 1/2] sysinv: fix the console for arm64 + +The default console for arm64 is ttyAMA0, use +dpkg-architecture to check the host arch and +replace the hardcoded console name. + +Test Plan: +PASS: build-pkgs on x86-64 host +PASS: build-image on x86-64 host +PASS: build-pkgs on arm64 host +PASS: build-image on arm64 host +PASS: Deploy AIO-SX on x86-64 target +PASS: Deploy AIO-SX on arm64 target +PASS: Deploy AIO-DX on arm64 targets +PASS: Deploy std (2+2+2) on arm64 targets + +Story: 2010739 +Task: 48285 + +Change-Id: I583172cfd029cbb66acee01d1068100dce020075 +Signed-off-by: Jackie Huang +--- + config-gate/debian/deb_folder/rules | 5 +++++ + sysinv/cgts-client/debian/deb_folder/rules | 7 +++++++ + sysinv/sysinv/debian/deb_folder/rules | 9 +++++++++ + 3 files changed, 21 insertions(+) + +diff --git a/config-gate/debian/deb_folder/rules b/config-gate/debian/deb_folder/rules +index 2f8325067..8346c9b5e 100755 +--- a/config-gate/debian/deb_folder/rules ++++ b/config-gate/debian/deb_folder/rules +@@ -1,6 +1,8 @@ + #!/usr/bin/make -f + #export DH_VERBOSE = 1 + ++export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null) ++ + %: + dh $@ + +@@ -8,6 +10,9 @@ override_dh_auto_build: + : # Nothing to build + + override_dh_auto_install: ++ifeq ($(DEB_HOST_ARCH),arm64) ++ sed -i "s/ttyS0/ttyAMA0/" $(CURDIR)/*.service ++endif + $(MAKE) SBINDIR=`pwd`/debian/tmp/usr/sbin \ + SYSTEMDDIR=`pwd`/debian/tmp/lib/systemd/system install + +diff --git a/sysinv/cgts-client/debian/deb_folder/rules b/sysinv/cgts-client/debian/deb_folder/rules +index d21022388..57c96bf4a 100755 +--- a/sysinv/cgts-client/debian/deb_folder/rules ++++ b/sysinv/cgts-client/debian/deb_folder/rules +@@ -1,15 +1,22 @@ + #!/usr/bin/make -f + #export DH_VERBOSE = 1 + ++export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null) ++ + export PYBUILD_NAME=cgts-client + # (chuck) - workaround for pbr version detection when running install + export PBR_VERSION=1.0.0 + ROOT := $(CURDIR)/debian/tmp ++CGTS_DIR := $(CURDIR)/cgtsclient + + %: + dh $@ --with python3 --buildsystem=pybuild + + override_dh_install: ++ifeq ($(DEB_HOST_ARCH),arm64) ++ sed -i "s/ttyS0/ttyAMA0/" $(CGTS_DIR)/v1/iHost_shell.py \ ++ $(CGTS_DIR)/tests/v1/test_ihost.py ++endif + python3 setup.py install -f --install-layout=deb \ + --root=$(CURDIR)/debian/tmp + python3 setup.py bdist_wheel \ +diff --git a/sysinv/sysinv/debian/deb_folder/rules b/sysinv/sysinv/debian/deb_folder/rules +index 1f4767bc3..13e800dc2 100755 +--- a/sysinv/sysinv/debian/deb_folder/rules ++++ b/sysinv/sysinv/debian/deb_folder/rules +@@ -1,9 +1,12 @@ + #!/usr/bin/make -f + #export DH_VERBOSE = 1 + ++export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null) ++ + export PYBUILD_NAME=sysinv + export PBR_VERSION=1.0.0 + DEBIAN_DIR := $(CURDIR)/debian/tmp ++SYSINV_DIR := $(CURDIR)/sysinv + + %: + dh $@ --with python3 --buildsystem=pybuild +@@ -15,6 +18,12 @@ override_dh_auto_test: + endif + + override_dh_install: ++ifeq ($(DEB_HOST_ARCH),arm64) ++ sed -i "s/ttyS0/ttyAMA0/" $(SYSINV_DIR)/db/sqlalchemy/models.py \ ++ $(SYSINV_DIR)/conductor/manager.py \ ++ $(SYSINV_DIR)/tests/db/utils.py \ ++ $(SYSINV_DIR)/tests/conductor/test_manager.py ++endif + python3 setup.py install -f --install-layout=deb \ + --root=$(CURDIR)/debian/tmp + python3 setup.py bdist_wheel \ +-- +2.30.2 + diff --git a/scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0002-sysinv-agent-get-cpu-model-from-lscpu-for-Arm.patch b/scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0002-sysinv-agent-get-cpu-model-from-lscpu-for-Arm.patch new file mode 100644 index 00000000..67646a5d --- /dev/null +++ b/scripts/build_inf_debian/meta-patches-arm/stx90/cgcs-root/stx/config/0002-sysinv-agent-get-cpu-model-from-lscpu-for-Arm.patch @@ -0,0 +1,84 @@ +From 1577df1f8edf3e322eb743eab8f8e82ee6e3f5ee Mon Sep 17 00:00:00 2001 +From: Jackie Huang +Date: Thu, 16 Nov 2023 16:52:33 +0800 +Subject: [PATCH 2/2] sysinv-agent: get cpu model from lscpu for Arm + +Change-Id: I70a155b98090a0bb83577345f64c3ffb281183e8 +Signed-off-by: Jackie Huang +--- + sysinv/sysinv/sysinv/sysinv/agent/node.py | 28 +++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/sysinv/sysinv/sysinv/sysinv/agent/node.py b/sysinv/sysinv/sysinv/sysinv/agent/node.py +index 4b75a11af..2a09b43cb 100644 +--- a/sysinv/sysinv/sysinv/sysinv/agent/node.py ++++ b/sysinv/sysinv/sysinv/sysinv/agent/node.py +@@ -20,6 +20,8 @@ import re + from oslo_log import log as logging + import tsconfig.tsconfig as tsc + ++from sysinv.common import utils ++ + LOG = logging.getLogger(__name__) + + # Defines the size of one kilobyte +@@ -223,8 +225,10 @@ class NodeOperator(object): + + # In the case topology not detected, hard-code structures + if self.num_nodes == 0: ++ cpu_model = self._get_cpu_model_lscpu() + n_sockets, n_cores, n_threads = (1, int(self.num_cpus), 1) + self.topology = {} ++ cpu = 0 + for socket_id in range(n_sockets): + self.topology[socket_id] = {} + if socket_id not in sockets: +@@ -245,7 +249,11 @@ class NodeOperator(object): + 'thread': thread_id, + 'capabilities': {}, + } ++ if cpu_model: ++ attrs.update({'cpu_model': cpu_model}) ++ + icpus.append(attrs) ++ cpu += 1 + + # Define Thread-Socket-Core order for logical cpu enumeration + cpu = 0 +@@ -267,6 +275,8 @@ class NodeOperator(object): + 'thread': thread_id, + 'capabilities': {}, + } ++ if cpu_model: ++ attrs.update({'cpu_model': cpu_model}) + icpus.append(attrs) + cpu += 1 + self.num_nodes = len(list(self.topology.keys())) +@@ -275,6 +285,24 @@ class NodeOperator(object): + + return inumas, icpus + ++ def _get_cpu_model_lscpu(self): ++ """Get cpu model from lscpu ++ ++ Returns: ++ string: the cpu model name ++ """ ++ cpu_model = "" ++ output = utils.execute( ++ "lscpu | grep 'Model name' | cut -f 2- -d:|awk '{$1=$1}1'", ++ shell=True) ++ ++ if isinstance(output, tuple): ++ cpu_model = output[0] ++ if cpu_model: ++ cpu_model = cpu_model.strip() ++ LOG.info("CPU Model name: {}".format(cpu_model)) ++ return cpu_model ++ + def _get_immediate_subdirs(self, dir): + return [name for name in listdir(dir) + if os.path.isdir(join(dir, name))] +-- +2.30.2 + -- 2.16.6