From fefa83b4e67140f3e136f2fcbcaea3c5035be475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20S=C3=A9chet?= Date: Mon, 15 Feb 2021 17:14:50 +0100 Subject: [PATCH] Add source package --- Makefile.am | 1 - debian/control | 16 +++++++++++++ debian/openvswitch-source.dirs | 1 + debian/openvswitch-source.install | 1 + python/ovstest/rpcserver.py | 16 ++++--------- python/ovstest/tcp.py | 4 ++-- python/ovstest/util.py | 4 +--- python/ovstest/vswitch.py | 5 +++- utilities/ovs-check-dead-ifs.in | 2 ++ utilities/ovs-dpctl-top.in | 8 ++++--- utilities/ovs-l3ping.in | 12 ++++++---- utilities/ovs-parse-backtrace.in | 14 ++++++----- utilities/ovs-tcpdump.in | 2 ++ utilities/ovs-tcpundump.in | 2 ++ utilities/ovs-test.in | 39 +++++++++++++++++-------------- utilities/ovs-vlan-test.in | 25 +++++++++++--------- 16 files changed, 91 insertions(+), 61 deletions(-) create mode 100644 debian/openvswitch-source.dirs create mode 100644 debian/openvswitch-source.install diff --git a/Makefile.am b/Makefile.am index 691a005ad..f20fc94e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -485,7 +485,6 @@ include utilities/automake.mk include tests/automake.mk include include/automake.mk include third-party/automake.mk -include debian/automake.mk include ipsec/automake.mk include vswitchd/automake.mk include ovsdb/automake.mk diff --git a/debian/control b/debian/control index 08aa82f89..38c05a7cc 100644 --- a/debian/control +++ b/debian/control @@ -163,6 +163,22 @@ Description: Open vSwitch public key infrastructure dependency package Open vSwitch switches and controllers, reducing the risk of man-in-the-middle attacks on the Open vSwitch network infrastructure. +Package: openvswitch-source +Architecture: all +Depends: + ${misc:Depends}, +Description: Open vSwitch source code + Open vSwitch is a production quality, multilayer, software-based, + Ethernet virtual switch. It is designed to enable massive network + automation through programmatic extension, while still supporting + standard management interfaces and protocols (e.g. NetFlow, IPFIX, + sFlow, SPAN, RSPAN, CLI, LACP, 802.1ag). In addition, it is designed + to support distribution across multiple physical servers similar to + VMware's vNetwork distributed vswitch or Cisco's Nexus 1000V. + . + This package contains the full Open vSwitch source code to support + use with the Open Virtual Network (OVN) build. + Package: openvswitch-switch Architecture: linux-any Depends: diff --git a/debian/openvswitch-source.dirs b/debian/openvswitch-source.dirs new file mode 100644 index 000000000..564a2ddb8 --- /dev/null +++ b/debian/openvswitch-source.dirs @@ -0,0 +1 @@ +usr/src/openvswitch diff --git a/debian/openvswitch-source.install b/debian/openvswitch-source.install new file mode 100644 index 000000000..9488a1e77 --- /dev/null +++ b/debian/openvswitch-source.install @@ -0,0 +1 @@ +_debian/openvswitch.tar.gz /usr/src/openvswitch diff --git a/python/ovstest/rpcserver.py b/python/ovstest/rpcserver.py index c4aab7020..3cd3e9170 100644 --- a/python/ovstest/rpcserver.py +++ b/python/ovstest/rpcserver.py @@ -16,24 +16,18 @@ rpcserver is an XML RPC server that allows RPC client to initiate tests """ -import sys +from __future__ import absolute_import -import exceptions +import sys import xmlrpc.client -import tcp - from twisted.internet import reactor from twisted.internet.error import CannotListenError from twisted.web import server from twisted.web import xmlrpc -import udp - -import util - -import vswitch +from . import tcp, udp, util, vswitch class TestArena(xmlrpc.XMLRPC): @@ -210,7 +204,7 @@ class TestArena(xmlrpc.XMLRPC): (_, port) = self.__get_handle_resources(handle) port.loseConnection() self.__delete_handle(handle) - except exceptions.KeyError: + except KeyError: return -1 return 0 @@ -222,7 +216,7 @@ class TestArena(xmlrpc.XMLRPC): (_, connector) = self.__get_handle_resources(handle) connector.disconnect() self.__delete_handle(handle) - except exceptions.KeyError: + except KeyError: return -1 return 0 diff --git a/python/ovstest/tcp.py b/python/ovstest/tcp.py index c495717f2..098c6cba3 100644 --- a/python/ovstest/tcp.py +++ b/python/ovstest/tcp.py @@ -21,7 +21,7 @@ import time from twisted.internet import interfaces from twisted.internet.protocol import ClientFactory, Factory, Protocol -from zope.interface import implements +from zope.interface.declarations import implementer class TcpListenerConnection(Protocol): @@ -55,8 +55,8 @@ class TcpListenerFactory(Factory): return str(self.stats) +@implementer(interfaces.IPushProducer) class Producer(object): - implements(interfaces.IPushProducer) """ This producer class generates infinite byte stream for a specified time duration diff --git a/python/ovstest/util.py b/python/ovstest/util.py index 72457158f..270d6a037 100644 --- a/python/ovstest/util.py +++ b/python/ovstest/util.py @@ -26,8 +26,6 @@ import socket import struct import subprocess -import exceptions - import xmlrpc.client @@ -88,7 +86,7 @@ def start_process(args): stderr=subprocess.PIPE) out, err = p.communicate() return (p.returncode, out, err) - except exceptions.OSError: + except OSError: return (-1, None, None) diff --git a/python/ovstest/vswitch.py b/python/ovstest/vswitch.py index 9d5b5cffd..bff59ff10 100644 --- a/python/ovstest/vswitch.py +++ b/python/ovstest/vswitch.py @@ -15,7 +15,10 @@ """ vswitch module allows its callers to interact with OVS DB. """ -import util + +from __future__ import absolute_import + +from . import util def ovs_vsctl_add_bridge(bridge): diff --git a/utilities/ovs-check-dead-ifs.in b/utilities/ovs-check-dead-ifs.in index bf3565758..00ab657ee 100755 --- a/utilities/ovs-check-dead-ifs.in +++ b/utilities/ovs-check-dead-ifs.in @@ -1,5 +1,7 @@ #! @PYTHON3@ +from __future__ import print_function + import os import re import stat diff --git a/utilities/ovs-dpctl-top.in b/utilities/ovs-dpctl-top.in index fbe6e4f56..888188471 100755 --- a/utilities/ovs-dpctl-top.in +++ b/utilities/ovs-dpctl-top.in @@ -131,6 +131,8 @@ $ ovs-dpctl-top --script --flow-file dump-flows.log # pylint: disable-msg=R0913 # pylint: disable-msg=R0914 +from __future__ import print_function + import sys import os try: @@ -419,7 +421,7 @@ def flow_line_iter(line): rc.append(element) element = "" else: - element += ch + element += str(ch) if (paren_count): raise ValueError(line) @@ -468,7 +470,7 @@ def flow_line_split(line): """ - results = re.split(', ', line) + results = re.split(b', ', line) (field, stats, action) = (results[0], results[1:-1], results[-1]) @@ -963,7 +965,7 @@ class FlowDB: if not isinstance(line, str): line = str(line) - line = line.rstrip("\n") + line = line.rstrip(b"\n") (fields, stats, _) = flow_line_split(line) try: diff --git a/utilities/ovs-l3ping.in b/utilities/ovs-l3ping.in index 92d32acb3..5925112aa 100644 --- a/utilities/ovs-l3ping.in +++ b/utilities/ovs-l3ping.in @@ -18,8 +18,10 @@ opening holes in the firewall for the XML RPC control connection. This is achieved by tunneling the control connection inside the tunnel itself. """ +from __future__ import print_function + import socket -import xmlrpclib +from six.moves import xmlrpc_client as xmlrpclib import ovstest.args as args import ovstest.tests as tests @@ -64,13 +66,13 @@ if __name__ == '__main__': ps = get_packet_sizes(me, he, args.client[0]) tests.do_direct_tests(me, he, bandwidth, interval, ps) except KeyboardInterrupt: - print "Terminating" + print("Terminating") except xmlrpclib.Fault: - print "Couldn't contact peer" + print("Couldn't contact peer") except socket.error: - print "Couldn't contact peer" + print("Couldn't contact peer") except xmlrpclib.ProtocolError: - print "XMLRPC control channel was abruptly terminated" + print("XMLRPC control channel was abruptly terminated") finally: if local_server is not None: local_server.terminate() diff --git a/utilities/ovs-parse-backtrace.in b/utilities/ovs-parse-backtrace.in index d5506769a..d3fb0ace1 100755 --- a/utilities/ovs-parse-backtrace.in +++ b/utilities/ovs-parse-backtrace.in @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function + import optparse import os import re @@ -70,7 +72,7 @@ result. Expected usage is for ovs-appctl backtrace to be piped in.""") if os.path.exists(debug): binary = debug - print "Binary: %s\n" % binary + print("Binary: %s\n" % binary) stdin = sys.stdin.read() @@ -88,15 +90,15 @@ result. Expected usage is for ovs-appctl backtrace to be piped in.""") for lines, count in traces: longest = max(len(l) for l in lines) - print "Backtrace Count: %d" % count + print("Backtrace Count: %d" % count) for line in lines: match = re.search(r'\[(0x.*)]', line) if match: - print "%s %s" % (line.ljust(longest), - addr2line(binary, match.group(1))) + print("%s %s" % (line.ljust(longest), + addr2line(binary, match.group(1)))) else: - print line - print + print(line) + print() if __name__ == "__main__": diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in index 5ec02383c..69c0253fe 100755 --- a/utilities/ovs-tcpdump.in +++ b/utilities/ovs-tcpdump.in @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function + import fcntl import os diff --git a/utilities/ovs-tcpundump.in b/utilities/ovs-tcpundump.in index ede5448b4..d36477c09 100755 --- a/utilities/ovs-tcpundump.in +++ b/utilities/ovs-tcpundump.in @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function + import getopt import re import sys diff --git a/utilities/ovs-test.in b/utilities/ovs-test.in index eb712ffe8..c681b8dab 100644 --- a/utilities/ovs-test.in +++ b/utilities/ovs-test.in @@ -16,6 +16,8 @@ ovs test utility that allows to do tests between remote hosts """ +from __future__ import print_function + import fcntl import math import os @@ -25,7 +27,6 @@ import socket import subprocess import sys import time -import xmlrpclib import argparse import twisted @@ -35,6 +36,8 @@ import ovstest.rpcserver as rpcserver import ovstest.tests as tests import ovstest.util as util +from six.moves import xmlrpc_client as xmlrpclib + DEFAULT_TEST_BRIDGE = "ovstestbr0" DEFAULT_TEST_PORT = "ovstestport0" DEFAULT_TEST_TUN = "ovstestport1" @@ -42,7 +45,7 @@ DEFAULT_TEST_TUN = "ovstestport1" def collect_information(node): """Print information about hosts that will do testing""" - print "Node %s:%u " % (node[0], node[1]) + print("Node %s:%u " % (node[0], node[1])) server = util.rpc_client(node[0], node[1]) interface_name = server.get_interface(node[0]) phys_iface = None @@ -50,8 +53,8 @@ def collect_information(node): mtu = 1500 if not interface_name: - print ("Could not find interface that has %s IP address." - "Make sure that you specified correct Outer IP." % (node[0])) + print("Could not find interface that has %s IP address." + "Make sure that you specified correct Outer IP." % (node[0])) else: if server.is_ovs_bridge(interface_name): phys_iface = server.get_iface_from_bridge(interface_name) @@ -62,18 +65,18 @@ def collect_information(node): driver = server.get_driver(phys_iface) mtu = server.get_interface_mtu(phys_iface) - print "Will be using %s (%s) with MTU %u" % (phys_iface, node[0], - mtu) + print("Will be using %s (%s) with MTU %u" % (phys_iface, node[0], + mtu)) if not driver: - print "Unable to get driver information from ethtool." + print("Unable to get driver information from ethtool.") else: - print "On this host %s has %s." % (phys_iface, driver) + print("On this host %s has %s." % (phys_iface, driver)) if not uname: - print "Unable to retrieve kernel information. Is this Linux?" + print("Unable to retrieve kernel information. Is this Linux?") else: - print "Running kernel %s." % uname - print "\n" + print("Running kernel %s." % uname) + print() return mtu @@ -113,29 +116,29 @@ if __name__ == '__main__': tunnel_modes = ovs_args.tunnelModes if direct is not None: - print "Performing direct tests" + print("Performing direct tests") tests.do_direct_tests(node2, node1, bandwidth, interval, ps) if vlan_tag is not None: - print "Performing VLAN tests" + print("Performing VLAN tests") tests.do_vlan_tests(node2, node1, bandwidth, interval, ps, vlan_tag) for tmode in tunnel_modes: - print "Performing", tmode, "tests" + print("Performing", tmode, "tests") tests.do_l3_tests(node2, node1, bandwidth, interval, ps, tmode) except KeyboardInterrupt: pass except xmlrpclib.Fault: - print "Couldn't establish XMLRPC control channel" + print("Couldn't establish XMLRPC control channel") except socket.error: - print "Couldn't establish XMLRPC control channel" + print("Couldn't establish XMLRPC control channel") except xmlrpclib.ProtocolError: - print "XMLRPC control channel was abruptly terminated" + print("XMLRPC control channel was abruptly terminated") except twisted.internet.error.CannotListenError: - print "Couldn't start XMLRPC server on port %u" % ovs_args.port + print("Couldn't start XMLRPC server on port %u" % ovs_args.port) finally: if local_server is not None: local_server.terminate() diff --git a/utilities/ovs-vlan-test.in b/utilities/ovs-vlan-test.in index 154573a9b..ae1c0891e 100755 --- a/utilities/ovs-vlan-test.in +++ b/utilities/ovs-vlan-test.in @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import BaseHTTPServer +from __future__ import print_function + import getopt -import httplib import os import threading import time @@ -24,6 +24,9 @@ import signal #Causes keyboard interrupts to go to the main thread. import socket import sys +from six.moves import BaseHTTPServer +from six.moves import http_client as httplib + print_safe_lock = threading.Lock() def print_safe(s): print_safe_lock.acquire() @@ -84,7 +87,7 @@ class UDPReceiver: try: sock.bind((self.vlan_ip, self.vlan_port)) - except socket.error, e: + except socket.error as e: print_safe('Failed to bind to %s:%d with error: %s' % (self.vlan_ip, self.vlan_port, e)) os._exit(1) #sys.exit only exits the current thread. @@ -95,7 +98,7 @@ class UDPReceiver: data, _ = sock.recvfrom(4096) except socket.timeout: continue - except socket.error, e: + except socket.error as e: print_safe('Failed to receive from %s:%d with error: %s' % (self.vlan_ip, self.vlan_port, e)) os._exit(1) @@ -180,7 +183,7 @@ class VlanServer: for _ in range(send_time * 2): try: send_packet(test_id, size, ip, port) - except socket.error, e: + except socket.error as e: self.set_result(test_id, 'Failure: ' + str(e)) return time.sleep(.5) @@ -196,7 +199,7 @@ class VlanServer: try: BaseHTTPServer.HTTPServer((self.server_ip, self.server_port), VlanServerHandler).serve_forever() - except socket.error, e: + except socket.error as e: print_safe('Failed to start control server: %s' % e) self.udp_recv.stop() @@ -256,7 +259,7 @@ class VlanClient: try: conn = self.request('/start/recv') data = conn.getresponse().read() - except (socket.error, httplib.HTTPException), e: + except (socket.error, httplib.HTTPException) as e: error_msg(e) return False @@ -277,7 +280,7 @@ class VlanClient: send_packet(test_id, size, ip, port) resp = self.request('/result/%d' % test_id).getresponse() data = resp.read() - except (socket.error, httplib.HTTPException), e: + except (socket.error, httplib.HTTPException) as e: error_msg(e) return False @@ -302,7 +305,7 @@ class VlanClient: try: conn = self.request(resource) test_id = conn.getresponse().read() - except (socket.error, httplib.HTTPException), e: + except (socket.error, httplib.HTTPException) as e: error_msg(e) return False @@ -335,7 +338,7 @@ class VlanClient: try: resp = self.request('/ping').getresponse() data = resp.read() - except (socket.error, httplib.HTTPException), e: + except (socket.error, httplib.HTTPException) as e: error_msg(e) return False @@ -383,7 +386,7 @@ def main(): try: options, args = getopt.gnu_getopt(sys.argv[1:], 'hVs', ['help', 'version', 'server']) - except getopt.GetoptError, geo: + except getopt.GetoptError as geo: print_safe('%s: %s\n' % (sys.argv[0], geo.msg)) return 1 -- GitLab