aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vpp_config/vpplib/CpuUtils.py
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2018-12-19 02:05:25 -0800
committerDave Barach <openvpp@barachs.net>2019-01-10 21:26:08 +0000
commit339bc6b51dd1ea7d783b211c485881ccb495fd0d (patch)
treed910b6bf0dcc49b675ac406cffd3e576e9090061 /extras/vpp_config/vpplib/CpuUtils.py
parent6ad7231c00287b7c1241c6e1dbbfda86f15798b4 (diff)
vpp_config: Rework for Python2/3 compatibility.
On ubuntu: $cd <basedir>/extras/vpp_config $./scripts/clean.sh $./scripts/cp-data.sh $sudo apt-get install python3-pip python3-setuptools $python3 -m pip install . $vpp-config Changes: * Convert to print() function. * raw_input changes. * floor division changes. * replace vpp-config.py with a setuptools 'vpp-config' entry_point. * replace netaddr with ipaddress from the standard library and backport. * .decode() subprocess.Popen's stdout because in python3 they are bytes. Change-Id: Id98894ee54e0c31a0ba0304134b159caef415705 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'extras/vpp_config/vpplib/CpuUtils.py')
-rw-r--r--extras/vpp_config/vpplib/CpuUtils.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/extras/vpp_config/vpplib/CpuUtils.py b/extras/vpp_config/vpplib/CpuUtils.py
index f5c23bc141a..23f418d33be 100644
--- a/extras/vpp_config/vpplib/CpuUtils.py
+++ b/extras/vpp_config/vpplib/CpuUtils.py
@@ -12,7 +12,7 @@
# limitations under the License.
"""CPU utilities library."""
-
+from __future__ import absolute_import, division
import re
from vpplib.VPPUtil import VPPUtil
@@ -43,8 +43,8 @@ class CpuUtils(object):
@staticmethod
def is_smt_enabled(cpu_info):
"""Uses CPU mapping to find out if SMT is enabled or not. If SMT is
- enabled, the L1d,L1i,L2,L3 setting is the same for two processors. These
- two processors are two threads of one core.
+ enabled, the L1d,L1i,L2,L3 setting is the same for two processors.
+ These two processors are two threads of one core.
:param cpu_info: CPU info, the output of "lscpu -p".
:type cpu_info: list
@@ -53,7 +53,7 @@ class CpuUtils(object):
"""
cpu_mems = [item[-4:] for item in cpu_info]
- cpu_mems_len = len(cpu_mems) / CpuUtils.NR_OF_THREADS
+ cpu_mems_len = len(cpu_mems) // CpuUtils.NR_OF_THREADS
count = 0
for cpu_mem in cpu_mems[:cpu_mems_len]:
if cpu_mem in cpu_mems[cpu_mems_len:]:
@@ -137,7 +137,7 @@ class CpuUtils(object):
if smt_enabled and not smt_used:
cpu_list_len = len(cpu_list)
- cpu_list = cpu_list[:cpu_list_len / CpuUtils.NR_OF_THREADS]
+ cpu_list = cpu_list[:cpu_list_len // CpuUtils.NR_OF_THREADS]
return cpu_list
@@ -171,8 +171,8 @@ class CpuUtils(object):
cpu_cnt = cpu_list_len - skip_cnt
if smt_used:
- cpu_list_0 = cpu_list[:cpu_list_len / CpuUtils.NR_OF_THREADS]
- cpu_list_1 = cpu_list[cpu_list_len / CpuUtils.NR_OF_THREADS:]
+ cpu_list_0 = cpu_list[:cpu_list_len // CpuUtils.NR_OF_THREADS]
+ cpu_list_1 = cpu_list[cpu_list_len // CpuUtils.NR_OF_THREADS:]
cpu_list = [cpu for cpu in cpu_list_0[skip_cnt:skip_cnt + cpu_cnt]]
cpu_list_ex = [cpu for cpu in
cpu_list_1[skip_cnt:skip_cnt + cpu_cnt]]
@@ -236,8 +236,8 @@ class CpuUtils(object):
smt_used=smt_used)
if smt_used:
cpu_list_len = len(cpu_list)
- cpu_list_0 = cpu_list[:cpu_list_len / CpuUtils.NR_OF_THREADS]
- cpu_list_1 = cpu_list[cpu_list_len / CpuUtils.NR_OF_THREADS:]
+ cpu_list_0 = cpu_list[:cpu_list_len // CpuUtils.NR_OF_THREADS]
+ cpu_list_1 = cpu_list[cpu_list_len // CpuUtils.NR_OF_THREADS:]
cpu_range = "{}{}{},{}{}{}".format(cpu_list_0[0], sep,
cpu_list_0[-1],
cpu_list_1[0], sep,