From a30e09bb87186c92953b3d67c0bf568c3707390e Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Fri, 19 Jul 2019 11:17:55 +0800 Subject: [PATCH] add get_platform_cpus Add helper function for platform cpu number calculation Change-Id: I6f656594e80fb067794cc14ba8f01db84585d198 Partial-Bug: 1834796 Signed-off-by: Bin Yang --- worker-utils/centos/build_srpm.data | 2 +- worker-utils/centos/worker-utils.spec | 1 + worker-utils/worker-utils/cpumap_functions.sh | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/worker-utils/centos/build_srpm.data b/worker-utils/centos/build_srpm.data index 274059f442..a356789ac5 100644 --- a/worker-utils/centos/build_srpm.data +++ b/worker-utils/centos/build_srpm.data @@ -1,3 +1,3 @@ SRC_DIR="worker-utils" COPY_LIST="$SRC_DIR/LICENSE" -TIS_PATCH_VER=3 +TIS_PATCH_VER=4 diff --git a/worker-utils/centos/worker-utils.spec b/worker-utils/centos/worker-utils.spec index 73d7d2bf11..1607d9051b 100644 --- a/worker-utils/centos/worker-utils.spec +++ b/worker-utils/centos/worker-utils.spec @@ -13,6 +13,7 @@ BuildRequires: systemd-devel Requires: systemd Requires: python Requires: /bin/systemctl +Requires: perl %description Initial worker node resource reservation and misc. utilities diff --git a/worker-utils/worker-utils/cpumap_functions.sh b/worker-utils/worker-utils/cpumap_functions.sh index 6d8db514ab..ab961f45f0 100644 --- a/worker-utils/worker-utils/cpumap_functions.sh +++ b/worker-utils/worker-utils/cpumap_functions.sh @@ -268,6 +268,17 @@ function get_platform_cpu_list { echo ${PLATFORM_CPULIST} } +################################################################################ +# Return number of CPUs reserved for platform +################################################################################ +function get_platform_cpus { + local PLATFORM_CPULIST + PLATFORM_CPULIST=($(platform_expanded_cpu_list | \ + perl -pe 's/(\d+)-(\d+)/join(",",$1..$2)/eg'| \ + sed 's/,/ /g')) + echo ${#PLATFORM_CPULIST[@]} +} + ################################################################################ # Return list of CPUs reserved for vswitch ################################################################################