3 # Copyright (c) 2015 All rights reserved
4 # This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # 0.1: This script boots the VM1 and allocates IP address from Nova
11 # Later, the VM2 boots then execute cloud-init to ping VM1.
12 # After successful ping, both the VMs are deleted.
13 # 0.2: measure test duration and publish results under json format
14 # 0.3: adapt push 2 DB after Test API refacroting
21 import functest.utils.functest_logger as ft_logger
23 import vping_util as util
25 parser = argparse.ArgumentParser()
26 parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
27 parser.add_argument("-r", "--report",
28 help="Create json result file",
30 parser.add_argument("-m", "--mode", default='ssh',
31 help="vPing mode: userdata or ssh",
34 args = parser.parse_args()
38 if args.mode == 'ssh':
41 case = 'vping_userdata'
43 logger = ft_logger.Logger(case).getLogger()
47 util.check_repo_exist()
49 vmname_1 = util.get_vmname_1()
50 vmname_2 = util.get_vmname_2()
52 image_id = util.create_image()
54 flavor = util.get_flavor()
56 network_id = util.create_network_full()
58 sg_id = util.create_security_group()
60 util.delete_exist_vms()
62 start_time = time.time()
63 logger.info("vPing Start Time:'%s'" % (
64 datetime.datetime.fromtimestamp(start_time).strftime(
65 '%Y-%m-%d %H:%M:%S')))
67 vm1 = util.boot_vm(case,
74 test_ip = util.get_test_ip(vm1)
75 vm2 = util.boot_vm(case,
83 EXIT_CODE, stop_time = util.do_vping(case, vm2, test_ip)
84 details = util.check_result(EXIT_CODE,
87 util.push_result(args.report,
96 if __name__ == '__main__':