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())
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), image, 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), flavor, 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 __init__(self, host, command=None, user=None, key=None, password=None):

        options='-q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
        user_prefix = '' if user is None else '%s@' % user

        if key is not None: options += ' -i %s' % key

        cmd = "ssh {options} {user_prefix}{host} {command}".format(options=options,
                                                                   user_prefix=user_prefix,
                                                                   host=host,
                                                                   command=command)

        conf.log(conf.get_bash_log_file(),cmd)

        if password is None:
            super(ssh,self).__init__(bash(cmd).output)
        else:
            super(ssh,self).__init__(self.__use_expect(cmd, password))
Exemple #4
0
    def __init__(self, host, command=None, user=None, key=None, password=None):

        options = '-q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
        user_prefix = '' if user is None else '%s@' % user

        if key is not None: options += ' -i %s' % key

        cmd = "ssh {options} {user_prefix}{host} {command}".format(
            options=options,
            user_prefix=user_prefix,
            host=host,
            command=command)

        conf.log(conf.get_bash_log_file(), cmd)

        if password is None:
            super(ssh, self).__init__(bash(cmd).output)
        else:
            super(ssh, self).__init__(self.__use_expect(cmd, 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), image, 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), flavor, 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 __init__(self, step):
     self.step = step
     conf.log(conf.get_bash_log_file(),"asserting in step: %s" % step.sentence)
 def __init__(self, step):
     self.step = step
     conf.log(conf.get_bash_log_file(),
              "asserting in step: %s" % step.sentence)
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())