def ssh_command(step, vm_name, user, command): ip = utils.nova_cli.get_instance_ip(vm_name) step_assert(step).assert_true(ip != '') step_assert(step).assert_true(world.saved_root_password is not None) conf.log(conf.get_bash_log_file(),"load world.saved_root_password=%s" % world.saved_root_password) return utils.ssh(ip, command=command, user=user, password=world.saved_root_password)
def start_vm_instance_save_root_pwd(step, name,image, flavor): id_image_list = utils.nova_cli.get_image_id_list(image) assert_equals(len(id_image_list), 1, "There are %s images with name %s: %s" % (len(id_image_list), name, str(id_image_list))) id_flavor_list = utils.nova_cli.get_flavor_id_list(flavor) assert_equals(len(id_flavor_list), 1, "There are %s flavors with name %s: %s" % (len(id_flavor_list), name, str(id_flavor_list))) image_id = id_image_list[0] flavor_id = id_flavor_list[0] assert_true(image_id != '', image_id) assert_true(flavor_id != '', flavor_id) table = utils.nova_cli.start_vm_instance_return_output(name, image_id, flavor_id) assert_true(table is not None) passwords = table.select_values('Value', 'Property', 'adminPass') step_assert(step).assert_equals(len(passwords), 1, "there should be one and only one adminPass") world.saved_root_password = passwords[0] conf.log(conf.get_bash_log_file(),"store world.saved_root_password=%s" % world.saved_root_password)
def check_can_log_via_ssh_using_saved_pwd(step, name, user): ip = utils.nova_cli.get_instance_ip(name) assert_true(ip != '', name) assert_true(world.saved_root_password is not None) conf.log(conf.get_bash_log_file(),"load world.saved_root_password=%s" % world.saved_root_password) step_assert(step).assert_true(utils.ssh(ip, command="/bin/ls -l /", user=user, password=world.saved_root_password).successful())