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
15 import functest.utils.functest_logger as ft_logger
19 class VPingUserdata(vping_base.VPingBase):
21 def __init__(self, case_name='vping_userdata'):
22 super(VPingUserdata, self).__init__(case_name)
23 self.logger = ft_logger.Logger(self.case_name).getLogger()
25 def boot_vm_preparation(self, config, vmname, test_ip):
26 config['config_drive'] = True
27 if vmname == self.vm2_name:
30 " ping -c 1 %s 2>&1 >/dev/null\n"
32 " if [ \"Z$RES\" = \"Z0\" ] ; then\n"
40 config['userdata'] = u
42 def do_vping(self, vm, test_ip):
43 self.logger.info("Waiting for ping...")
50 p_console = vm.get_console_output()
51 if "vPing OK" in p_console:
52 self.logger.info("vPing detected!")
55 elif "failed to read iid from metadata" in p_console or tries > 5:
58 elif sec == self.ping_timeout:
59 self.logger.info("Timeout reached.")
62 if "request failed" in p_console:
63 self.logger.debug("It seems userdata is not supported "
64 "in nova boot. Waiting a bit...")
67 self.logger.debug("Pinging %s. Waiting for response..."
74 if __name__ == '__main__':
75 args_parser = argparse.ArgumentParser()
76 args_parser.add_argument("-r", "--report",
77 help="Create json result file",
79 args = vars(args_parser.parse_args())
81 sys.exit(vping_base.VPingMain(VPingUserdata).main(**args))