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):
22 super(VPingUserdata, self).__init__()
23 self.case_name = 'vping_userdata'
24 self.logger = ft_logger.Logger(self.case_name).getLogger()
26 def boot_vm_preparation(self, config, vmname, test_ip):
27 config['config_drive'] = True
28 if vmname == self.vm2_name:
31 " ping -c 1 %s 2>&1 >/dev/null\n"
33 " if [ \"Z$RES\" = \"Z0\" ] ; then\n"
41 config['userdata'] = u
43 def do_vping(self, vm, test_ip):
44 self.logger.info("Waiting for ping...")
51 p_console = vm.get_console_output()
52 if "vPing OK" in p_console:
53 self.logger.info("vPing detected!")
56 elif "failed to read iid from metadata" in p_console or tries > 5:
59 elif sec == self.ping_timeout:
60 self.logger.info("Timeout reached.")
63 if "request failed" in p_console:
64 self.logger.debug("It seems userdata is not supported "
65 "in nova boot. Waiting a bit...")
68 self.logger.debug("Pinging %s. Waiting for response..."
75 if __name__ == '__main__':
76 args_parser = argparse.ArgumentParser()
77 args_parser.add_argument("-r", "--report",
78 help="Create json result file",
80 args = vars(args_parser.parse_args())
82 sys.exit(vping_base.VPingMain(VPingUserdata).main(**args))