diff options
author | Ansis Atteka <aatteka@nicira.com> | 2012-06-28 15:52:40 -0700 |
---|---|---|
committer | Ansis Atteka <aatteka@nicira.com> | 2012-07-02 12:23:49 -0700 |
commit | 2d8bdd8f220848611722bce97b3258600530e95e (patch) | |
tree | c71d0527a65d25c978c7819c274a2b60c574d8c5 /python/ovstest/args.py | |
parent | 969e46a224d433ea60878252c607ad65371bc00d (diff) |
ovs-l3ping: A new test utility that allows to detect L3 tunneling issues
ovs-l3ping is similar to ovs-test, but the main difference
is that it does not require administrator to open firewall
holes for the XML/RPC control connection. This is achieved
by encapsulating the Control Connection over the L3 tunnel
itself.
This tool is not intended as a replacement for ovs-test,
because ovs-test covers much broader set of test cases.
Sample usage:
Node1: ovs-l3ping -s 192.168.122.236,10.1.1.1 -t gre
Node2: ovs-l3ping -c 192.168.122.220,10.1.1.2,10.1.1.1 -t gre
Issue#11791
Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Diffstat (limited to 'python/ovstest/args.py')
-rw-r--r-- | python/ovstest/args.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/python/ovstest/args.py b/python/ovstest/args.py index 8e23a894..e90db2a5 100644 --- a/python/ovstest/args.py +++ b/python/ovstest/args.py @@ -78,6 +78,23 @@ def ip_optional_port(string, default_port, ip_callback): "must be colon-separated") +def ip_optional_port_port(string, default_port1, default_port2, ip_callback): + """Convert a string into IP, Port1, Port2 tuple. If any of ports were + missing, then default ports will be used. The fourth argument is a + callback that verifies whether IP address is given in the expected + format.""" + value = string.split(':') + if len(value) == 1: + return (ip_callback(value[0]), default_port1, default_port2) + elif len(value) == 2: + return (ip_callback(value[0]), port(value[1]), default_port2) + elif len(value) == 3: + return (ip_callback(value[0]), port(value[1]), port(value[2])) + else: + raise argparse.ArgumentTypeError("Expected IP address and at most " + "two colon-separated ports") + + def vlan_tag(string): """ This function verifies whether given string is a correct VLAN tag. @@ -154,6 +171,37 @@ def tunnel_types(string): return string.split(',') +def l3_endpoint_client(string): + """ + This function parses command line argument string in + remoteIP,localInnerIP[/mask][:ControlPort[:TestPort]],remoteInnerIP[: + ControlPort[:TestPort]] format. + """ + try: + remote_ip, me, he = string.split(',') + except ValueError: + raise argparse.ArgumentTypeError("All 3 IP addresses must be comma " + "separated.") + r = (ip_address(remote_ip), + ip_optional_port_port(me, CONTROL_PORT, DATA_PORT, ip_optional_mask), + ip_optional_port_port(he, CONTROL_PORT, DATA_PORT, ip_address)) + return r + + +def l3_endpoint_server(string): + """ + This function parses a command line argument string in + remoteIP,localInnerIP[/mask][:ControlPort] format. + """ + try: + remote_ip, me = string.split(',') + except ValueError: + raise argparse.ArgumentTypeError("Both IP addresses must be comma " + "separated.") + return (ip_address(remote_ip), + ip_optional_port(me, CONTROL_PORT, ip_optional_mask)) + + def ovs_initialize_args(): """ Initialize argument parsing for ovs-test utility. @@ -197,3 +245,37 @@ def ovs_initialize_args(): 'ovs-test server in the client mode by using 127.0.0.1 as ' 'OuterIP.') return parser.parse_args() + +def l3_initialize_args(): + """ + Initialize argument parsing for ovs-l3ping utility. + """ + parser = argparse.ArgumentParser(description='Test L3 tunnel ' + 'connectivity between two Open vSwitch instances.') + + parser.add_argument('-v', '--version', action='version', + version='ovs-l3ping (Open vSwitch) @VERSION@') + + parser.add_argument("-b", "--bandwidth", action='store', + dest="targetBandwidth", default="1M", type=bandwidth, + help='Target bandwidth for UDP tests in bits/second. Use ' + 'postfix M or K to alter unit magnitude.') + parser.add_argument("-i", "--interval", action='store', + dest="testInterval", default=5, type=int, + help='Interval for how long to run each test in seconds.') + + parser.add_argument("-t", "--tunnel-mode", action='store', + dest="tunnelMode", required=True, + help='Do L3 tests with this tunnel type.') + + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument("-s", "--server", action="store", dest="server", + metavar="TUNNELIP,SERVER", + type=l3_endpoint_server, + help='Run in server mode and wait for the client to ' + 'connect.') + group.add_argument('-c', "--client", action="store", dest="client", + metavar="TUNNELIP,CLIENT,SERVER", + type=l3_endpoint_client, + help='Run in client mode and connect to the server.') + return parser.parse_args() |