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
19 class VPingUserdata(vping_base.VPingBase):
21 def __init__(self, **kwargs):
22 if "case_name" not in kwargs:
23 kwargs["case_name"] = "vping_userdata"
24 super(VPingUserdata, self).__init__(**kwargs)
25 self.logger = logging.getLogger(__name__)
27 def boot_vm_preparation(self, config, vmname, test_ip):
28 config['config_drive'] = True
29 if vmname == self.vm2_name:
32 " ping -c 1 %s 2>&1 >/dev/null\n"
34 " if [ \"Z$RES\" = \"Z0\" ] ; then\n"
42 config['userdata'] = u
44 def do_vping(self, vm, test_ip):
45 self.logger.info("Waiting for ping...")
52 p_console = vm.get_console_output()
53 if "vPing OK" in p_console:
54 self.logger.info("vPing detected!")
57 elif "failed to read iid from metadata" in p_console or tries > 5:
60 elif sec == self.ping_timeout:
61 self.logger.info("Timeout reached.")
64 if "request failed" in p_console:
65 self.logger.debug("It seems userdata is not supported "
66 "in nova boot. Waiting a bit...")
69 self.logger.debug("Pinging %s. Waiting for response..."
76 if __name__ == '__main__':
78 args_parser = argparse.ArgumentParser()
79 args_parser.add_argument("-r", "--report",
80 help="Create json result file",
82 args = vars(args_parser.parse_args())
84 sys.exit(vping_base.VPingMain(VPingUserdata).main(**args))