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()
36 """ logging configuration """
37 logger = ft_logger.Logger("vping_userdata").getLogger()
41 if args.mode == 'ssh':
44 case = 'vping_userdata'
48 util.check_repo_exist()
50 vmname_1 = util.get_vmname_1()
51 vmname_2 = util.get_vmname_2()
53 image_id = util.create_image()
55 flavor = util.get_flavor()
57 network_id = util.create_network_full()
59 sg_id = util.create_security_group()
61 util.delete_exist_vms()
63 start_time = time.time()
64 logger.info("vPing Start Time:'%s'" % (
65 datetime.datetime.fromtimestamp(start_time).strftime(
66 '%Y-%m-%d %H:%M:%S')))
68 vm1 = util.boot_vm(case,
75 test_ip = util.get_test_ip(vm1)
76 vm2 = util.boot_vm(case,
84 EXIT_CODE, stop_time = util.do_vping(case, vm2, test_ip)
85 details = util.check_result(EXIT_CODE,
88 util.push_result(args.report,
97 if __name__ == '__main__':