Use user@host:pwd for --hypervisor --external-host
Change-Id: I5b6bdeddb0d5731c1a3448357b4fb6224f230656
This commit is contained in:
parent
d0a728db38
commit
d07d11b426
@ -87,3 +87,7 @@ VMTP will display the results to stdout with the following data:
|
|||||||
| | | average, min, max and stddev round trip time in ms
|
| | | average, min, max and stddev round trip time in ms
|
||||||
|
|
||||||
Detailed results can also be stored in a file in JSON format using the *--json* command line argument.
|
Detailed results can also be stored in a file in JSON format using the *--json* command line argument.
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
For more information, see the `VMTP online documentation <http://vmtp.readthedocs.org>`_
|
@ -66,7 +66,7 @@ class NuttcpTool(PerfTool):
|
|||||||
|
|
||||||
# For UDP reverse direction we need to start the server on self.instance
|
# For UDP reverse direction we need to start the server on self.instance
|
||||||
# and run the client on target_instance
|
# and run the client on target_instance
|
||||||
if bidirectional:
|
if bidirectional and 'U' in self.instance.config.protocols:
|
||||||
# Start the server on the client (this tool instance)
|
# Start the server on the client (this tool instance)
|
||||||
self.instance.display('Start UDP server for reverse dir')
|
self.instance.display('Start UDP server for reverse dir')
|
||||||
if self.start_server():
|
if self.start_server():
|
||||||
|
@ -71,7 +71,7 @@ class PerfInstance(Instance):
|
|||||||
ping_res = None
|
ping_res = None
|
||||||
|
|
||||||
# TCP/UDP throughput with tp_tool, returns a list of dict
|
# TCP/UDP throughput with tp_tool, returns a list of dict
|
||||||
if self.tp_tool and 'error' not in ping_res:
|
if self.tp_tool and (not ping_res or 'error' not in ping_res):
|
||||||
tp_tool_res = self.tp_tool.run_client(dest_ip,
|
tp_tool_res = self.tp_tool.run_client(dest_ip,
|
||||||
target_instance,
|
target_instance,
|
||||||
mss=mss,
|
mss=mss,
|
||||||
|
104
vmtp.py
104
vmtp.py
@ -14,7 +14,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import ast
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@ -42,8 +41,6 @@ from novaclient.client import Client
|
|||||||
__version__ = '2.0.0'
|
__version__ = '2.0.0'
|
||||||
|
|
||||||
from perf_instance import PerfInstance as PerfInstance
|
from perf_instance import PerfInstance as PerfInstance
|
||||||
# Global external host info
|
|
||||||
ext_host_list = []
|
|
||||||
|
|
||||||
# Check IPv4 address syntax - not completely fool proof but will catch
|
# Check IPv4 address syntax - not completely fool proof but will catch
|
||||||
# some invalid formats
|
# some invalid formats
|
||||||
@ -111,36 +108,32 @@ class ResultsCollector(object):
|
|||||||
def pprint(self, res):
|
def pprint(self, res):
|
||||||
self.ppr.pprint(res)
|
self.ppr.pprint(res)
|
||||||
|
|
||||||
def save(self, cfg):
|
def get_controller_info(self, cfg):
|
||||||
'''Save results in json format file.'''
|
if cfg.ctrl_username and cfg.ctrl_host:
|
||||||
if cfg.access_username and cfg.access_host:
|
|
||||||
print 'Fetching OpenStack deployment details...'
|
print 'Fetching OpenStack deployment details...'
|
||||||
sshcon = sshutils.SSH(cfg.access_username,
|
if cfg.ctrl_password:
|
||||||
cfg.access_host,
|
sshcon = sshutils.SSH(cfg.ctrl_username,
|
||||||
password=cfg.access_password)
|
cfg.ctrl_host,
|
||||||
|
password=cfg.ctrl_password)
|
||||||
|
else:
|
||||||
|
sshcon = sshutils.SSH(cfg.ctrl_username,
|
||||||
|
cfg.ctrl_host,
|
||||||
|
key_filename=cfg.private_key_file,
|
||||||
|
connect_retry_count=cfg.ssh_retry_count)
|
||||||
if sshcon is not None:
|
if sshcon is not None:
|
||||||
self.results['distro'] = sshcon.get_host_os_version()
|
self.results['distro'] = sshcon.get_host_os_version()
|
||||||
self.results['openstack_version'] = sshcon.check_openstack_version()
|
self.results['openstack_version'] = sshcon.check_openstack_version()
|
||||||
else:
|
else:
|
||||||
print 'ERROR: Cannot connect to the controlloer node.'
|
print 'ERROR: Cannot connect to the controller node.'
|
||||||
|
|
||||||
|
def save(self, cfg):
|
||||||
|
'''Save results in json format file.'''
|
||||||
print('Saving results in json file: ' + cfg.json_file + "...")
|
print('Saving results in json file: ' + cfg.json_file + "...")
|
||||||
with open(cfg.json_file, 'w') as jfp:
|
with open(cfg.json_file, 'w') as jfp:
|
||||||
json.dump(self.results, jfp, indent=4, sort_keys=True)
|
json.dump(self.results, jfp, indent=4, sort_keys=True)
|
||||||
|
|
||||||
def save_to_db(self, cfg):
|
def save_to_db(self, cfg):
|
||||||
'''Save resutls to MongoDB database.'''
|
'''Save results to MongoDB database.'''
|
||||||
if cfg.access_username and cfg.access_host:
|
|
||||||
print 'Fetching OpenStack deployment details...'
|
|
||||||
sshcon = sshutils.SSH(cfg.access_username,
|
|
||||||
cfg.access_host,
|
|
||||||
password=cfg.access_password)
|
|
||||||
if sshcon is not None:
|
|
||||||
self.results['distro'] = sshcon.get_host_os_version()
|
|
||||||
self.results['openstack_version'] = sshcon.check_openstack_version()
|
|
||||||
else:
|
|
||||||
print 'ERROR: Cannot connect to the controlloer node.'
|
|
||||||
|
|
||||||
print "Saving results to MongoDB database..."
|
print "Saving results to MongoDB database..."
|
||||||
post_id = pns_mongo.\
|
post_id = pns_mongo.\
|
||||||
pns_add_test_result_to_mongod(cfg.pns_mongod_ip,
|
pns_add_test_result_to_mongod(cfg.pns_mongod_ip,
|
||||||
@ -465,6 +458,28 @@ def test_native_tp(nhosts):
|
|||||||
client.dispose()
|
client.dispose()
|
||||||
server.dispose()
|
server.dispose()
|
||||||
|
|
||||||
|
def extract_user_host_pwd(user_host_pwd):
|
||||||
|
'''
|
||||||
|
splits user@host[:pwd] into a 3 element tuple
|
||||||
|
'hugo@1.1.1.1:secret' -> ('hugo', '1.1.1.1', 'secret')
|
||||||
|
'huggy@2.2.2.2' -> ('huggy', '2.2.2.2', None)
|
||||||
|
None ->(None, None, None)
|
||||||
|
Examples of fatal errors (will call exit):
|
||||||
|
'hutch@q.1.1.1' (invalid IP)
|
||||||
|
'@3.3.3.3' (missing username)
|
||||||
|
'hiro@' or 'buggy' (missing host IP)
|
||||||
|
'''
|
||||||
|
if not user_host_pwd:
|
||||||
|
return (None, None, None)
|
||||||
|
match = re.search(r'^([^@]+)@([0-9\.]+):?(.*)$', user_host_pwd)
|
||||||
|
if not match:
|
||||||
|
print('Invalid argument: ' + user_host_pwd)
|
||||||
|
sys.exit(3)
|
||||||
|
if not is_ipv4(match.group(2)):
|
||||||
|
print 'Invalid IPv4 address ' + match.group(2)
|
||||||
|
sys.exit(4)
|
||||||
|
return match.groups()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
fpr = FlowPrinter()
|
fpr = FlowPrinter()
|
||||||
@ -504,13 +519,13 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
parser.add_argument('--external-host', dest='ext_host',
|
parser.add_argument('--external-host', dest='ext_host',
|
||||||
action='store',
|
action='store',
|
||||||
help='external-VM throughput (target requires ssh key)',
|
help='external-VM throughput (host requires public key if no password)',
|
||||||
metavar='<user>@<ext_host_ssh_ip>')
|
metavar='<user>@<host_ssh_ip>[:password>]')
|
||||||
|
|
||||||
parser.add_argument('--access_info', dest='access_info',
|
parser.add_argument('--controller-node', dest='controller_node',
|
||||||
action='store',
|
action='store',
|
||||||
help='access info for the controller node',
|
help='controller node ssh (host requires public key if no password)',
|
||||||
metavar='\'{"host":"<hostip>", "user":"<user>", "password":"<pass>"}\'')
|
metavar='<user>@<host_ssh_ip>[:<password>]')
|
||||||
|
|
||||||
parser.add_argument('--mongod_server', dest='mongod_server',
|
parser.add_argument('--mongod_server', dest='mongod_server',
|
||||||
action='store',
|
action='store',
|
||||||
@ -528,10 +543,12 @@ if __name__ == '__main__':
|
|||||||
help='transport perf tool to use (default=nuttcp)',
|
help='transport perf tool to use (default=nuttcp)',
|
||||||
metavar='nuttcp|iperf')
|
metavar='nuttcp|iperf')
|
||||||
|
|
||||||
|
# note there is a bug in argparse that causes an AssertionError
|
||||||
|
# when the metavar is set to '[<az>:]<hostname>', hence had to insert a space
|
||||||
parser.add_argument('--hypervisor', dest='hypervisors',
|
parser.add_argument('--hypervisor', dest='hypervisors',
|
||||||
action='append',
|
action='append',
|
||||||
help='hypervisor to use (1 per arg, up to 2 args)',
|
help='hypervisor to use (1 per arg, up to 2 args)',
|
||||||
metavar='[az:]hostname')
|
metavar='[<az>:] <hostname>')
|
||||||
|
|
||||||
parser.add_argument('--inter-node-only', dest='inter_node_only',
|
parser.add_argument('--inter-node-only', dest='inter_node_only',
|
||||||
default=False,
|
default=False,
|
||||||
@ -590,6 +607,7 @@ if __name__ == '__main__':
|
|||||||
help='URL to a Linux image in qcow2 format that can be downloaded from',
|
help='URL to a Linux image in qcow2 format that can be downloaded from',
|
||||||
metavar='<url_to_image>')
|
metavar='<url_to_image>')
|
||||||
|
|
||||||
|
|
||||||
(opts, args) = parser.parse_known_args()
|
(opts, args) = parser.parse_known_args()
|
||||||
|
|
||||||
default_cfg_file = get_absolute_path_for_file("cfg.default.yaml")
|
default_cfg_file = get_absolute_path_for_file("cfg.default.yaml")
|
||||||
@ -622,21 +640,16 @@ if __name__ == '__main__':
|
|||||||
config.json_file = None
|
config.json_file = None
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
# Access info for the server to collect metadata for
|
# controller node ssh access to collect metadata for
|
||||||
# the run.
|
# the run.
|
||||||
###################################################
|
###################################################
|
||||||
if opts.access_info:
|
(config.ctrl_username, config.ctrl_host, config.ctrl_password) = \
|
||||||
access_info = ast.literal_eval(opts.access_info)
|
extract_user_host_pwd(opts.controller_node)
|
||||||
config.access_host = access_info['host']
|
# Add the external host info to a list
|
||||||
config.access_username = access_info['user']
|
ext_host_list = list(extract_user_host_pwd(opts.ext_host))
|
||||||
config.access_password = access_info['password']
|
|
||||||
else:
|
|
||||||
config.access_host = None
|
|
||||||
config.access_username = None
|
|
||||||
config.access_password = None
|
|
||||||
|
|
||||||
###################################################
|
###################################################
|
||||||
# Cloud Image URL
|
# VM Image URL
|
||||||
###################################################
|
###################################################
|
||||||
if opts.vm_image_url:
|
if opts.vm_image_url:
|
||||||
config.vm_image_url = opts.vm_image_url
|
config.vm_image_url = opts.vm_image_url
|
||||||
@ -761,17 +774,6 @@ if __name__ == '__main__':
|
|||||||
native_hosts.append(elem_list)
|
native_hosts.append(elem_list)
|
||||||
test_native_tp(native_hosts)
|
test_native_tp(native_hosts)
|
||||||
|
|
||||||
# Add the external host info to a list
|
|
||||||
# if username is not given assume root as user
|
|
||||||
if opts.ext_host:
|
|
||||||
elem_list = opts.ext_host.split("@")
|
|
||||||
if len(elem_list) == 1:
|
|
||||||
elem_list.insert(0, 'root')
|
|
||||||
if not is_ipv4(elem_list[1]):
|
|
||||||
print 'Invalid IPv4 address ' + elem_list[1]
|
|
||||||
sys.exit(1)
|
|
||||||
ext_host_list = elem_list[:]
|
|
||||||
|
|
||||||
cred = credentials.Credentials(opts.rc, opts.pwd, opts.no_env)
|
cred = credentials.Credentials(opts.rc, opts.pwd, opts.no_env)
|
||||||
|
|
||||||
# replace all command line arguments (after the prog name) with
|
# replace all command line arguments (after the prog name) with
|
||||||
@ -786,6 +788,8 @@ if __name__ == '__main__':
|
|||||||
vmtp = VmtpTest()
|
vmtp = VmtpTest()
|
||||||
vmtp.run()
|
vmtp.run()
|
||||||
|
|
||||||
|
rescol.get_controller_info(config)
|
||||||
|
|
||||||
if config.json_file:
|
if config.json_file:
|
||||||
rescol.save(config)
|
rescol.save(config)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user