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>
diff --git a/extras/vpp_config/vpplib/CpuUtils.py b/extras/vpp_config/vpplib/CpuUtils.py
index f5c23bc..23f418d 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 @@
@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 @@
"""
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 @@
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 @@
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 @@
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,