当前位置: 首页>>代码示例>>Python>>正文


Python remote.wait_for_login函数代码示例

本文整理汇总了Python中virttest.remote.wait_for_login函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for_login函数的具体用法?Python wait_for_login怎么用?Python wait_for_login使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wait_for_login函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: migration_scenario

        def migration_scenario(self):
            sync = SyncData(self.master_id(), self.hostid, self.hosts,
                            self.id, self.sync_server)
            self.vm = params.get("vms").split()[0]
            address_cache = env.get("address_cache")

            if (self.hostid == self.master_id()):
                utils.run("dd if=/dev/urandom of=%s bs=1M"
                          " count=%s" % (host_path, file_size))

                self.vm_addr = self._prepare_vm(self.vm).get_address()

                end_event = threading.Event()
                bg = utils.InterruptedThread(self._copy_until_end,
                                             (end_event,))

                self._hosts_barrier(self.hosts, self.id, "befor_mig", 120)
                sync.sync(address_cache, timeout=120)
                error.context("ping-pong between host and guest while"
                              " migrating", logging.info)
                self._run_and_migrate(bg, end_event, sync, migrate_count)

                # Check if guest lives.
                remote.wait_for_login(shell_client, self.vm_addr,
                                           shell_port, guest_root,
                                           guest_pass, shell_prompt)
                self._hosts_barrier(self.hosts, self.id, "After_check", 120)

                error.context("comparing hashes", logging.info)
                orig_hash = client_utils.hash_file(host_path)
                returned_hash = client_utils.hash_file(host_path_returned)

                #Check all check sum
                wrong_check_sum = False
                for i in range(len(self.file_check_sums)):
                    check_sum = self.file_check_sums[i]
                    if check_sum != orig_hash:
                        wrong_check_sum = True
                        logging.error("Checksum in transfer number"
                                      " %d if wrong." % (i))
                if wrong_check_sum:
                    raise error.TestFail("Returned file hash (%s) differs from"
                                         " original one (%s)" % (returned_hash,
                                                                 orig_hash))
                else:
                    #clean temp
                    utils.run("rm -rf %s" % (host_path))
                    utils.run("rm -rf %s" % (returned_hash))

                error.context()
            else:
                self._hosts_barrier(self.hosts, self.id, "befor_mig", 260)
                address_cache.update(sync.sync(timeout=120)[self.master_id()])
                logging.debug("Address cache updated to %s" % address_cache)
                self._slave_migrate(sync)

                #Wait for check if guest lives.
                self._hosts_barrier(self.hosts, self.id, "After_check", 120)
开发者ID:vi-patel,项目名称:virt-test,代码行数:58,代码来源:migration_multi_host_with_file_transfer.py

示例2: hugepage_assign

    def hugepage_assign(hp_num, target_ip='', node='', hp_size='', user='',
                        password=''):
        """
        Allocates hugepages for src and dst machines

        :param hp_num: number of hugepages
        :param target_ip: ip address of destination machine
        :param node: numa node to which HP have to be allocated
        :param hp_size: hugepage size
        :param user: remote machine's username
        :param password: remote machine's password
        """
        command = ""
        if node == '':
            if target_ip == '':
                utils_memory.set_num_huge_pages(int(hp_num))
            else:
                command = "echo %s > /proc/sys/vm/nr_hugepages" % (hp_num)
        else:
            command = "echo %s > /sys/devices/system/node/node" % (hp_num)
            command += "%s/hugepages/hugepages-%skB/" % (str(node), hp_size)
            command += "nr_hugepages"
        if command != "":
            if target_ip != "":
                server_session = remote.wait_for_login('ssh', target_ip, '22',
                                                       user, password,
                                                       r"[\#\$]\s*$")
                cmd_output = server_session.cmd_status_output(command)
                server_session.close()
                if (cmd_output[0] != 0):
                    raise error.TestNAError("HP not supported/configured")
            else:
                process.system_output(command, verbose=True, shell=True)
开发者ID:dzhengfy,项目名称:tp-libvirt,代码行数:33,代码来源:virsh_migrate.py

示例3: __init__

 def __init__(self, test, params, env):
     """
     Initialize the object and set a few attributes.
     """
     self.test = test
     self.server_hostname = None
     self.server_ip = params.get("remote_ip")
     if self.server_ip.count("REMOTE"):
         self.test.cancel("Please set server ip!")
     self.server_user = params.get("remote_user")
     self.server_password = params.get("remote_pwd")
     self.local_clock = params.get("local_clock")
     self.net_range = params.get("net_range")
     self.mask = params.get("mask", "255.255.255.0")
     self.restrict_option = params.get("restrict_option")
     self.vm_name = params.get("main_vm")
     self.ntpdate_sleep = int(params.get("ntpdate_sleep", "0"))
     self.ntpd_sleep = int(params.get("ntpd_sleep", "0"))
     self.long_sleep = int(params.get("long_sleep", "0"))
     self.vm = env.get_vm(self.vm_name)
     try:
         self.server_session = remote.wait_for_login('ssh',
                                                     self.server_ip, "22",
                                                     self.server_user,
                                                     self.server_password,
                                                     r"[\$#]\s*$")
         self.session = self.vm.wait_for_login()
     except remote.LoginTimeoutError as detail:
         self.test.cancel(str(detail))
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:29,代码来源:ntpd.py

示例4: service_libvirtd_control

def service_libvirtd_control(action, remote_ip=None,
                             remote_pwd=None, remote_user='root',
                             libvirtd=LIBVIRTD):
    """
    Libvirtd control by action, if cmd executes successfully,
    return True, otherwise raise LibvirtActionError.

    If the action is status, return True when it's running,
    otherwise return False.

    @ param action: start|stop|status|restart|condrestart|
      reload|force-reload|try-restart
    @ raise LibvirtdActionUnknownError: Action is not supported.
    @ raise LibvirtdActionError: Take the action on libvirtd Failed.
    """
    service_cmd = ('service %s %s' % (libvirtd, action))

    actions = ['start', 'stop', 'restart', 'condrestart', 'reload',
               'force-reload', 'try-restart']

    session = None
    if remote_ip:
        try:
            session = remote.wait_for_login('ssh', remote_ip, '22',
                                            remote_user, remote_pwd,
                                            r"[\#\$]\s*$")
        except remote.LoginError, detail:
            raise LibvirtdActionError(action, detail)
开发者ID:LeiCui,项目名称:virt-test,代码行数:28,代码来源:utils_libvirtd.py

示例5: _new_session

    def _new_session(self):
        """
        Build a new server session.
        """
        port = self.port
        prompt = self.prompt
        host = self.server_ip
        client = self.client
        username = self.server_user
        password = self.server_pwd

        try:
            session = remote.wait_for_login(client, host, port,
                                            username, password, prompt)
        except remote.LoginTimeoutError:
            raise exceptions.TestError(
                "Got a timeout error when login to server.")
        except remote.LoginAuthenticationError:
            raise exceptions.TestError(
                "Authentication failed to login to server.")
        except remote.LoginProcessTerminatedError:
            raise exceptions.TestError(
                "Host terminates during login to server.")
        except remote.LoginError:
            raise exceptions.TestError(
                "Some error occurs login to client server.")
        return session
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:27,代码来源:utils_sasl.py

示例6: conn_recover

    def conn_recover(self):
        """
        Do the clean up work.

        (1).initialize variables.
        (2).Delete remote file.
        (3).Restart libvirtd on server.
        """
        # initialize variables
        server_ip = self.server_ip
        server_user = self.server_user
        server_pwd = self.server_pwd

        del self.client_hosts
        del self.server_syslibvirtd
        del self.server_libvirtdconf
        # restart libvirtd service on server
        try:
            session = remote.wait_for_login('ssh', server_ip, '22',
                                            server_user, server_pwd,
                                            r"[\#\$]\s*$")
            libvirtd_service = utils_libvirtd.Libvirtd(session=session)
            libvirtd_service.restart()
        except (remote.LoginError, aexpect.ShellError), detail:
            raise ConnServerRestartError(detail)
开发者ID:brownman,项目名称:virt-test,代码行数:25,代码来源:utils_conn.py

示例7: network_restart

def network_restart(test, params):
    """
    Restart remote network
    """
    time_out = int(params.get('time_out'))
    remote_ip = params.get('remote_ip')
    remote_user = params.get('remote_user')
    remote_pwd = params.get('remote_pwd')
    session = remote.remote_login("ssh", remote_ip, "22", remote_user,
                                  remote_pwd, "#")
    runner = remote.RemoteRunner(session=session)
    net_service = service.Factory.create_service("network", runner.run)
    net_service.restart()
    session.close()
    try:
        remote.wait_for_login("ssh", remote_ip, "22", remote_user,
                              remote_pwd, "#", timeout=time_out)
    except remote.LoginTimeoutError as detail:
        test.error(str(detail))
开发者ID:balamuruhans,项目名称:tp-libvirt,代码行数:19,代码来源:resource_abnormal.py

示例8: service_libvirtd_control

def service_libvirtd_control(action, remote_ip=None, remote_pwd=None,
                             remote_user='root'):
    deprecation_warning()
    session = None
    if remote_ip:
        session = remote.wait_for_login('ssh', remote_ip, '22',
                                        remote_user, remote_pwd,
                                        r"[\#\$]\s*$")
        libvirtd_instance = Libvirtd(session)
    else:
        libvirtd_instance = Libvirtd()

    getattr(libvirtd_instance, action)()
开发者ID:jferlan,项目名称:virt-test,代码行数:13,代码来源:utils_libvirtd.py

示例9: create_destroy_pool_on_remote

def create_destroy_pool_on_remote(test, action, params):
    """
    This is to create or destroy a specified pool on remote.

    :param action: "create" or "destory"
    :type str
    :param params: a dict for parameters
    :type dict

    :return: True if successful, otherwise False
    :rtype: Boolean
    """
    remote_ip = params.get("migrate_dest_host")
    remote_user = params.get("migrate_dest_user", "root")
    remote_pwd = params.get("migrate_dest_pwd")
    virsh_dargs = {'remote_ip': remote_ip, 'remote_user': remote_user,
                   'remote_pwd': remote_pwd, 'unprivileged_user': None,
                   'ssh_remote_auth': True}

    new_session = virsh.VirshPersistent(**virsh_dargs)
    pool_name = params.get("precreation_pool_name", "tmp_pool_1")
    timeout = params.get("timeout", 60)
    prompt = params.get("prompt", r"[\#\$]\s*$")

    if action == 'create':
        # Firstly check if the pool already exists
        all_pools = new_session.pool_list(option="--all")
        logging.debug("Pools on remote host:\n%s", all_pools)
        if all_pools.stdout.find(pool_name) >= 0:
            logging.debug("The pool %s already exists and skip "
                          "to create it.", pool_name)
            new_session.close_session()
            return True

        pool_type = params.get("precreation_pool_type", "dir")
        pool_target = params.get("precreation_pool_target")
        cmd = "mkdir -p %s" % pool_target
        session = remote.wait_for_login("ssh", remote_ip, 22,
                                        remote_user, remote_pwd, prompt)
        status, output = session.cmd_status_output(cmd, timeout)
        session.close()
        if status:
            new_session.close_session()
            test.fail("Run '%s' on remote host '%s' failed: %s."
                      % (cmd, remote_ip, output))
        ret = new_session.pool_create_as(pool_name, pool_type, pool_target)
    else:  # suppose it is to destroy
        ret = new_session.pool_destroy(pool_name)

    new_session.close_session()
    return ret
开发者ID:nasastry,项目名称:tp-libvirt,代码行数:51,代码来源:virsh_migrate_copy_storage.py

示例10: create_destroy_pool_on_remote

def create_destroy_pool_on_remote(action, params):
    """
    This is to create or destroy a specified pool on remote.

    :param action: "create" or "destory"
    :type str
    :param params: a dict for parameters
    :type dict

    :return: True if successful, otherwise False
    :rtype: Boolean
    """
    remote_ip = params.get("migrate_dest_host")
    remote_user = params.get("migrate_dest_user", "root")
    remote_pwd = params.get("migrate_dest_pwd")
    virsh_dargs = {'remote_ip': remote_ip, 'remote_user': remote_user,
                   'remote_pwd': remote_pwd, 'unprivileged_user': None,
                   'ssh_remote_auth': True}

    new_session = virsh.VirshPersistent(**virsh_dargs)
    pool_name = params.get("precreation_pool_name", "tmp_pool_1")
    timeout = params.get("timeout", 60)
    prompt = params.get("prompt", r"[\#\$]\s*$")

    if action == 'create':
        pool_type = params.get("precreation_pool_type", "dir")
        pool_target = params.get("precreation_pool_target")
        cmd = "mkdir -p %s" % pool_target
        session = remote.wait_for_login("ssh", remote_ip, 22,
                                        remote_user, remote_pwd, prompt)
        status, output = session.cmd_status_output(cmd, timeout)
        session.close()
        if status:
            new_session.close_session()
            raise error.TestFail("Run '%s' on remote host '%s' failed: %s."
                                 % (cmd, remote_ip, output))
        ret = new_session.pool_create_as(pool_name, pool_type, pool_target)
    else:  # suppose it is to destroy
        ret = new_session.pool_destroy(pool_name)

    new_session.close_session()
    return ret
开发者ID:chloerh,项目名称:tp-libvirt,代码行数:42,代码来源:virsh_migrate_copy_storage.py

示例11: remotely_control_libvirtd

def remotely_control_libvirtd(server_ip, server_user, server_pwd,
                              action='restart', status_error='no'):
    """
    Remotely restart libvirt service
    """
    session = None
    try:
        session = remote.wait_for_login('ssh', server_ip, '22',
                                        server_user, server_pwd,
                                        r"[\#\$]\s*$")
        logging.info("%s libvirt daemon\n", action)
        service_libvirtd_control(action, session)
        session.close()
    except (remote.LoginError, aexpect.ShellError, error.CmdError), detail:
        if session:
            session.close()
        if status_error == "no":
            raise error.TestFail("Failed to %s libvirtd service on "
                                 "server: %s\n", action, detail)
        else:
            logging.info("It is an expect %s", detail)
开发者ID:giuseppe,项目名称:virt-test,代码行数:21,代码来源:libvirt.py

示例12: compare_virt_version

def compare_virt_version(server_ip, server_user, server_pwd):
    """
    Make sure libvirt version is different
    """
    client = "ssh"
    port = "22"
    prompt = r"[\#\$]\s*$"
    query_cmd = "rpm -q libvirt"
    # query libvirt version on local host
    status, output_local = commands.getstatusoutput(query_cmd)
    if status:
        raise error.TestError(output_local)
    # query libvirt version on remote host
    session = remote.wait_for_login(client, server_ip, port,
                                    server_user, server_pwd, prompt)
    status, output_remote = session.cmd_status_output(query_cmd)
    if status:
        raise error.TestError(output_remote)
    # compare libvirt version between local and remote host
    if output_local == output_remote.strip():
        raise error.TestNAError("To expect different libvirt version "
                                "<%s>:<%s>", output_local, output_remote)
开发者ID:Hao-Liu,项目名称:tp-libvirt,代码行数:22,代码来源:remote_access.py

示例13: compare_virt_version

def compare_virt_version(server_ip, server_user, server_pwd, test):
    """
    Make sure libvirt version is different
    """
    client = "ssh"
    port = "22"
    prompt = r"[\#\$]\s*$"
    query_cmd = "rpm -q libvirt"
    # query libvirt version on local host
    ret = process.run(query_cmd, allow_output_check='combined', shell=True)
    status, output_local = ret.exit_status, ret.stdout_text.strip()
    if status:
        test.error(output_local)
    # query libvirt version on remote host
    session = remote.wait_for_login(client, server_ip, port,
                                    server_user, server_pwd, prompt)
    status, output_remote = session.cmd_status_output(query_cmd)
    if status:
        test.error(output_remote)
    # compare libvirt version between local and remote host
    if output_local == output_remote.strip():
        test.cancel("To expect different libvirt version "
                    "<%s>:<%s>", output_local, output_remote)
开发者ID:balamuruhans,项目名称:tp-libvirt,代码行数:23,代码来源:remote_access.py

示例14: _new_server_session

    def _new_server_session(self):
        """
        Build a new server session.
        """
        transport = 'ssh'
        host = self.server_ip
        port = 22
        username = self.server_user
        password = self.server_pwd
        prompt = r"[\#\$]\s*$"
        try:
            server_session = remote.wait_for_login(transport, host, port,
                                                   username, password, prompt)
        except remote.LoginTimeoutError:
            raise ConnLoginError("Got a timeout error when login to server.")
        except remote.LoginAuthenticationError:
            raise ConnLoginError("Authentication failed to login to server.")
        except remote.LoginProcessTerminatedError:
            raise ConnLoginError("Host terminates during login to server.")
        except remote.LoginError:
            raise ConnLoginError("Some error occurs login to client server.")

        return server_session
开发者ID:Antique,项目名称:virt-test,代码行数:23,代码来源:utils_conn.py

示例15: conn_setup

    def conn_setup(self):
        """
        Enable tcp connect of libvirtd on server.

        (1).initialization for variables.
        (2).edit /etc/sysconfig/libvirtd on server.
        (3).edit /etc/libvirt/libvirtd.conf on server.
        (4).restart libvirtd service on server.
        """
        # initialize variables
        server_ip = self.server_ip
        server_user = self.server_user
        server_pwd = self.server_pwd
        tcp_port = self.tcp_port

        # edit the /etc/sysconfig/libvirtd to add --listen args in libvirtd
        pattern2repl = {r".*LIBVIRTD_ARGS\s*=\s*\"\s*--listen\s*\".*":
                        "LIBVIRTD_ARGS=\"--listen\""}
        self.remote_syslibvirtd.sub_else_add(pattern2repl)

        # edit the /etc/libvirt/libvirtd.conf
        # listen_tcp=1, tcp_port=$tcp_port, auth_tcp="none"
        pattern2repl = {r".*listen_tls\s*=.*": 'listen_tls=0',
                        r".*listen_tcp\s*=.*": 'listen_tcp=1',
                        r".*tcp_port\s*=.*": 'tcp_port="%s"' % (tcp_port),
                        r'.*auth_tcp\s*=.*': 'auth_tcp="none"'}
        self.remote_libvirtdconf.sub_else_add(pattern2repl)

        # restart libvirtd service on server
        try:
            session = remote.wait_for_login('ssh', server_ip, '22',
                                            server_user, server_pwd,
                                            r"[\#\$]\s*$")
            libvirtd_service = utils_libvirtd.Libvirtd(session=session)
            libvirtd_service.restart()
        except (remote.LoginError, aexpect.ShellError), detail:
            raise ConnServerRestartError(detail)
开发者ID:brownman,项目名称:virt-test,代码行数:37,代码来源:utils_conn.py


注:本文中的virttest.remote.wait_for_login函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。