3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 ovs L3 ping utility allows to do tests between two remote hosts without
17 opening holes in the firewall for the XML RPC control connection. This is
18 achieved by tunneling the control connection inside the tunnel itself.
24 import ovstest.args as args
25 import ovstest.tests as tests
26 import ovstest.util as util
29 def get_packet_sizes(me, he, remote_ip):
31 This function retrieves MTUs from both hosts and returns a list of
32 packet sizes, that are more likely to uncover possible configuration
37 server1 = util.rpc_client(me[0], me[1])
38 server2 = util.rpc_client(he[0], he[1])
39 iface1 = server2.get_interface(remote_ip)
40 iface2 = server1.get_interface_from_routing_decision(remote_ip)
42 mtu_node1 = server2.get_interface_mtu(iface1)
44 mtu_node2 = server1.get_interface_mtu(iface2)
45 return util.get_datagram_sizes(mtu_node1, mtu_node2)
48 if __name__ == '__main__':
51 args = args.l3_initialize_args()
52 tunnel_mode = args.tunnelMode
53 if args.server is not None: # Start in server mode
54 local_server = tests.configure_l3(args.server, tunnel_mode)
56 elif args.client is not None: # Run in client mode
57 bandwidth = args.targetBandwidth
58 interval = args.testInterval
59 me = (util.ip_from_cidr(args.client[1][0]), args.client[1][1],
60 args.client[1][0], args.client[1][2])
61 he = (args.client[2][0], args.client[2][1],
62 args.client[2][0], args.client[2][2])
63 local_server = tests. configure_l3(args.client, tunnel_mode)
64 ps = get_packet_sizes(me, he, args.client[0])
65 tests.do_direct_tests(me, he, bandwidth, interval, ps)
66 except KeyboardInterrupt:
68 except xmlrpclib.Fault:
69 print "Couldn't contact peer"
71 print "Couldn't contact peer"
72 except xmlrpclib.ProtocolError:
73 print "XMLRPC control channel was abruptly terminated"
75 if local_server is not None:
76 local_server.terminate()