1 From 1577df1f8edf3e322eb743eab8f8e82ee6e3f5ee Mon Sep 17 00:00:00 2001
2 From: Jackie Huang <jackie.huang@windriver.com>
3 Date: Thu, 16 Nov 2023 16:52:33 +0800
4 Subject: [PATCH 2/2] sysinv-agent: get cpu model from lscpu for Arm
6 Change-Id: I70a155b98090a0bb83577345f64c3ffb281183e8
7 Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
9 sysinv/sysinv/sysinv/sysinv/agent/node.py | 28 +++++++++++++++++++++++
10 1 file changed, 28 insertions(+)
12 diff --git a/sysinv/sysinv/sysinv/sysinv/agent/node.py b/sysinv/sysinv/sysinv/sysinv/agent/node.py
13 index 4b75a11af..2a09b43cb 100644
14 --- a/sysinv/sysinv/sysinv/sysinv/agent/node.py
15 +++ b/sysinv/sysinv/sysinv/sysinv/agent/node.py
16 @@ -20,6 +20,8 @@ import re
17 from oslo_log import log as logging
18 import tsconfig.tsconfig as tsc
20 +from sysinv.common import utils
22 LOG = logging.getLogger(__name__)
24 # Defines the size of one kilobyte
25 @@ -223,8 +225,10 @@ class NodeOperator(object):
27 # In the case topology not detected, hard-code structures
28 if self.num_nodes == 0:
29 + cpu_model = self._get_cpu_model_lscpu()
30 n_sockets, n_cores, n_threads = (1, int(self.num_cpus), 1)
33 for socket_id in range(n_sockets):
34 self.topology[socket_id] = {}
35 if socket_id not in sockets:
36 @@ -245,7 +249,11 @@ class NodeOperator(object):
41 + attrs.update({'cpu_model': cpu_model})
46 # Define Thread-Socket-Core order for logical cpu enumeration
48 @@ -267,6 +275,8 @@ class NodeOperator(object):
53 + attrs.update({'cpu_model': cpu_model})
56 self.num_nodes = len(list(self.topology.keys()))
57 @@ -275,6 +285,24 @@ class NodeOperator(object):
61 + def _get_cpu_model_lscpu(self):
62 + """Get cpu model from lscpu
65 + string: the cpu model name
68 + output = utils.execute(
69 + "lscpu | grep 'Model name' | cut -f 2- -d:|awk '{$1=$1}1'",
72 + if isinstance(output, tuple):
73 + cpu_model = output[0]
75 + cpu_model = cpu_model.strip()
76 + LOG.info("CPU Model name: {}".format(cpu_model))
79 def _get_immediate_subdirs(self, dir):
80 return [name for name in listdir(dir)
81 if os.path.isdir(join(dir, name))]