From: Christos Sfakianakis <csfakian(a)redhat.com>
Make the following changes to comply with python 3:
- lnst.Recipes.ENRT.BaseEnrtRecipe: convert regex and 'split' arguments
in _pin_dev_interrupts from text into bytes.
- lnst.Recipes.ENRT.XfrmTools: in the case of 'ipsec_esp_aead', use new
integer
division operator for the key construction. Decode bytes to text in the case of
'esp_ah_comp' fucntion.
- lnst.Tests.PacketAssert: convert the output/error of the packet assert process
into text.
- lnst.Recipes.ENRT.SimpleMacsecRecipe: convert zip result into a sequence to
support indexing.
Signed-off-by: Christos Sfakianakis <csfakian(a)redhat.com>
---
lnst/Recipes/ENRT/BaseEnrtRecipe.py | 6 +++---
lnst/Recipes/ENRT/SimpleMacsecRecipe.py | 2 +-
lnst/Recipes/ENRT/XfrmTools.py | 4 ++--
lnst/Tests/PacketAssert.py | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py
index 249fffa..60f61ad 100644
--- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py
+++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py
@@ -341,7 +341,7 @@ class BaseEnrtRecipe(PingTestAndEvaluate, PerfRecipe):
def _pin_dev_interrupts(self, dev, cpu):
netns = dev.netns
cpu_info = netns.run("lscpu").stdout
- regex = "CPU\(s\): *([0-9]*)"
+ regex = b"CPU\(s\): *([0-9]*)"
num_cpus = int(re.search(regex, cpu_info).groups()[0])
if cpu < 0 or cpu > num_cpus - 1:
raise RecipeError("Invalid CPU value given: %d. Accepted value
%s." %
@@ -351,14 +351,14 @@ class BaseEnrtRecipe(PingTestAndEvaluate, PerfRecipe):
res = netns.run("grep {} /proc/interrupts | cut -f1 -d: | sed 's/
//'"
.format(dev.name))
intrs = res.stdout
- split = res.stdout.split("\n")
+ split = res.stdout.split(b"\n")
if len(split) == 1 and split[0] == '':
res = netns.run("dev_irqs=/sys/class/net/{}/device/msi_irqs; "
"[ -d $dev_irqs ] && ls -1 $dev_irqs"
.format(dev.name))
intrs = res.stdout
- for intr in intrs.split("\n"):
+ for intr in intrs.split(b"\n"):
try:
int(intr)
netns.run("echo -n {} > /proc/irq/{}/smp_affinity_list"
diff --git a/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
b/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
index 47ab907..1da586d 100644
--- a/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
+++ b/lnst/Recipes/ENRT/SimpleMacsecRecipe.py
@@ -129,7 +129,7 @@ class SimpleMacsecRecipe(BaseEnrtRecipe):
net_addr = "192.168.100"
net_addr6 = "fc00:0:0:0"
host1, host2 = main_config.host1, main_config.host2
- k_ids = zip(self.ids, self.keys)
+ k_ids = list(zip(self.ids, self.keys))
hosts_and_keys = [(host1, host2, k_ids), (host2, host1, k_ids[::-1])]
for host_a, host_b, k_ids in hosts_and_keys:
host_a.msec0 = MacsecDevice(realdev=host_a.eth0,
encrypt=sub_config.encrypt)
diff --git a/lnst/Recipes/ENRT/XfrmTools.py b/lnst/Recipes/ENRT/XfrmTools.py
index 468259e..d6dadb4 100644
--- a/lnst/Recipes/ENRT/XfrmTools.py
+++ b/lnst/Recipes/ENRT/XfrmTools.py
@@ -2,7 +2,7 @@ from lnst.Common.LnstError import LnstError
def generate_key(length):
key = "0x"
- key = key + (length/8) * "0b"
+ key = key + (length//8) * "0b"
return key
def configure_ipsec_esp_aead(m1, ip1, m2, ip2, algo, algo_key, icv_len,
@@ -40,7 +40,7 @@ def configure_ipsec_esp_ah_comp(m1, ip1, m2, ip2, ciph_alg, ciph_key,
hash_alg,
m_keys = []
for m in [m1, m2]:
res = m.run("rpm -qa iproute")
- if (res.stdout.find("iproute-2") != -1):
+ if (res.stdout.decode().find("iproute-2") != -1):
m_keys.append("0x")
else:
m_keys.append("")
diff --git a/lnst/Tests/PacketAssert.py b/lnst/Tests/PacketAssert.py
index 9452a4f..25a92ba 100644
--- a/lnst/Tests/PacketAssert.py
+++ b/lnst/Tests/PacketAssert.py
@@ -76,8 +76,8 @@ class PacketAssert(BaseTestModule):
raise LnstError("Could not handle interrupt properly.")
with packet_assert_process.stdout, packet_assert_process.stderr:
- stderr=packet_assert_process.stderr.read()
- stdout=packet_assert_process.stdout.read()
+ stderr=packet_assert_process.stderr.read().decode()
+ stdout=packet_assert_process.stdout.read().decode()
self._res_data["stderr"] = stderr
--
2.17.1
_______________________________________________
LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org
Fedora Code of Conduct:
https://getfedora.org/code-of-conduct.html
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedora...
This patch fails to apply due to BaseEnrtRecipe being modified in one of
the previously pushed patchsets.
Additionaly the "decode()" calls on stdout and stderr attributes of a
finished Job are no longer necessary, also part of a previously applied
patchset.
-Ondrej