File 0002-ovs-monitor-ipsec-Convert-Python2-code-to-Python3.patch of Package openvswitch.16704
From 5d9fe63543f141537de9b25ac082aa9223152958 Mon Sep 17 00:00:00 2001
From: lzhecheng <lzhecheng@vmware.com>
Date: Thu, 6 Aug 2020 04:23:39 +0000
Subject: [PATCH 2/2] ovs-monitor-ipsec: Convert Python2 code to Python3.
Submitted-at: https://github.com/openvswitch/ovs/pull/331
Reported-at: https://github.com/openvswitch/ovs-issues/issues/192
Fixes: 1ca0323e7c29 ("Require Python 3 and remove support for Python 2.")
Signed-off-by: lzhecheng <lzhecheng@vmware.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
AUTHORS.rst | 1 +
ipsec/ovs-monitor-ipsec.in | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index f0c25f945..4c8772f63 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -419,6 +419,7 @@ Zhenyu Gao sysugaozhenyu@gmail.com
ZhiPeng Lu luzhipeng@uniudc.com
Zhou Yangchao 1028519445@qq.com
aginwala amginwal@gmail.com
+lzhecheng lzhecheng@vmware.com
parameswaran krishnamurthy parkrish@gmail.com
solomon liwei.solomon@gmail.com
wenxu wenxu@ucloud.cn
diff --git a/ipsec/ovs-monitor-ipsec.in b/ipsec/ovs-monitor-ipsec.in
index da8b92b6c..b84608a55 100755
--- a/ipsec/ovs-monitor-ipsec.in
+++ b/ipsec/ovs-monitor-ipsec.in
@@ -101,7 +101,7 @@ class XFRM(object):
proc = subprocess.Popen([self.IP, 'xfrm', 'policy'],
stdout=subprocess.PIPE)
while True:
- line = proc.stdout.readline().strip()
+ line = proc.stdout.readline().strip().decode()
if line == '':
break
a = line.split(" ")
@@ -124,7 +124,7 @@ class XFRM(object):
proc = subprocess.Popen([self.IP, 'xfrm', 'state'],
stdout=subprocess.PIPE)
while True:
- line = proc.stdout.readline().strip()
+ line = proc.stdout.readline().strip().decode()
if line == '':
break
a = line.split(" ")
@@ -254,7 +254,7 @@ conn prevent_unencrypted_vxlan
proc = subprocess.Popen([self.IPSEC, 'status'], stdout=subprocess.PIPE)
while True:
- line = proc.stdout.readline().strip()
+ line = proc.stdout.readline().strip().decode()
if line == '':
break
tunnel_name = line.split(":")
@@ -348,7 +348,7 @@ conn prevent_unencrypted_vxlan
# about possibility of ovs-monitor-ipsec to block for each tunnel
# while strongSwan sends IKE messages over Internet.
conns_dict = self.get_active_conns()
- for ifname, conns in conns_dict.iteritems():
+ for ifname, conns in conns_dict.items():
tunnel = monitor.tunnels.get(ifname)
for conn in conns:
# IPsec "connection" names that we choose in strongswan
@@ -544,7 +544,7 @@ conn prevent_unencrypted_vxlan
# Delete old connections
conns_dict = self.get_active_conns()
- for ifname, conns in conns_dict.iteritems():
+ for ifname, conns in conns_dict.items():
tunnel = monitor.tunnels.get(ifname)
for conn in conns:
@@ -616,7 +616,7 @@ conn prevent_unencrypted_vxlan
proc = subprocess.Popen([self.IPSEC, 'status'], stdout=subprocess.PIPE)
while True:
- line = proc.stdout.readline().strip()
+ line = proc.stdout.readline().strip().decode()
if line == '':
break
@@ -997,7 +997,7 @@ class IPsecMonitor(object):
skb_mark = None
is_valid = False
- for row in data["Open_vSwitch"].rows.itervalues():
+ for row in data["Open_vSwitch"].rows.values():
pki[0] = row.other_config.get("certificate")
pki[1] = row.other_config.get("private_key")
pki[2] = row.other_config.get("ca_cert")
@@ -1024,7 +1024,7 @@ class IPsecMonitor(object):
table."""
ifaces = set()
- for row in data["Interface"].rows.itervalues():
+ for row in data["Interface"].rows.values():
if not self.is_tunneling_type_supported(row.type):
continue
if not self.is_ipsec_required(row.options):
@@ -1055,7 +1055,7 @@ class IPsecMonitor(object):
return
s = ""
conns = self.ike_helper.get_active_conns()
- for name, tunnel in self.tunnels.iteritems():
+ for name, tunnel in self.tunnels.items():
s += tunnel.show(policies, securities, conns)
unix_conn.reply(s)
@@ -1072,7 +1072,7 @@ class IPsecMonitor(object):
if self.ike_helper.config_global(self):
needs_refresh = True
- for name, tunnel in self.tunnels.iteritems():
+ for name, tunnel in self.tunnels.items():
if tunnel.last_refreshed_version != tunnel.version:
tunnel.last_refreshed_version = tunnel.version
needs_refresh = True
@@ -1102,7 +1102,7 @@ class IPsecMonitor(object):
proc.wait()
if proc.returncode:
raise Exception(proc.stderr.read())
- m = re.search(r"CN=(.+?),", proc.stdout.readline())
+ m = re.search(r"CN=(.+?),", proc.stdout.readline().decode())
if not m:
raise Exception("No CN in the certificate subject.")
except Exception as e:
--
2.26.2