diff --git a/doc/source/usage.rst b/doc/source/usage.rst index 1951e38..1e86cd9 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -15,9 +15,9 @@ VMTP Usage [--mongod-server ] [--json ] [--tp-tool ] [--availability_zone ] [--hypervisor [:] - ] [--inter-node-only] [--protocols ] - [--bandwidth ] [--tcpbuf ] - [--udpbuf ] + ] [--inter-node-only] [--same-network-only] + [--protocols ] [--bandwidth ] + [--tcpbuf ] [--udpbuf ] [--reuse_network_name ] [--os-dataplane-network ] [--delete-image-after-run] [--no-env] @@ -56,6 +56,7 @@ VMTP Usage --hypervisor [:] hypervisor to use (1 per arg, up to 2 args) --inter-node-only only measure inter-node + --same-network-only only measure same network --protocols protocols T(TCP), U(UDP), I(ICMP) - default=TUI (all) --bandwidth the bandwidth limit for TCP/UDP flows in K/M/Gbps, diff --git a/vmtp/network.py b/vmtp/network.py index 4907412..51bfe5d 100644 --- a/vmtp/network.py +++ b/vmtp/network.py @@ -114,6 +114,8 @@ class Network(object): config.dns_nameservers, subnet_v6, cidr_v6, config.ipv6_mode) self.vm_int_net.append(int_net) + if config.same_network_only: + break else: for (net, subnet, cidr) in zip(config.internal_network_name, config.internal_subnet_name, @@ -121,6 +123,8 @@ class Network(object): int_net = self.create_net(net, subnet, cidr, config.dns_nameservers) self.vm_int_net.append(int_net) + if config.same_network_only: + break # Add both internal networks to router interface to enable # network to network connectivity diff --git a/vmtp/vmtp.py b/vmtp/vmtp.py index bdcbc5e..4091123 100755 --- a/vmtp/vmtp.py +++ b/vmtp/vmtp.py @@ -309,8 +309,11 @@ class VmtpTest(object): client.buginf('SSH connected') client.create() FlowPrinter.print_desc('External-VM (upload/download)') + target_ip = self.server.ssh_access.host + if self.config.same_network_only: + target_ip = self.server.internal_ip res = client.run_client('External-VM', - self.server.ssh_access.host, + target_ip, self.server, bandwidth=self.config.vm_bandwidth, bidirectional=True) @@ -370,7 +373,7 @@ class VmtpTest(object): self.server.internal_ip) self.client.dispose() self.client = None - if not self.config.reuse_network_name: + if not self.config.reuse_network_name and not self.config.same_network_only: # Different network self.create_flow_client(client_az, self.net.vm_int_net[1]) @@ -741,6 +744,11 @@ def parse_opts_from_cli(): action='store_true', help='only measure inter-node') + parser.add_argument('--same-network-only', dest='same_network_only', + default=False, + action='store_true', + help='only measure same network') + parser.add_argument('--protocols', dest='protocols', action='store', default='TUI', @@ -850,6 +858,7 @@ def merge_opts_to_configs(opts): config.debug = opts.debug config.stop_on_error = opts.stop_on_error config.inter_node_only = opts.inter_node_only + config.same_network_only = opts.same_network_only if config.public_key_file and not os.path.isfile(config.public_key_file): print('Warning: invalid public_key_file:' + config.public_key_file)