• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python env_process.process函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test

        def test(self):
            error.context("Preparing migration env and cdroms.", logging.info)
            mig_protocol = params.get("mig_protocol", "tcp")
            self.mig_type = migration.MultihostMigration
            if mig_protocol == "fd":
                self.mig_type = migration.MultihostMigrationFd
            if mig_protocol == "exec":
                self.mig_type = migration.MultihostMigrationExec
            if "rdma" in mig_protocol:
                self.mig_type = migration.MultihostMigrationRdma

            self.vms = params.get("vms").split(" ")
            self.srchost = params.get("hosts")[0]
            self.dsthost = params.get("hosts")[1]
            self.is_src = params.get("hostid") == self.srchost
            self.mig = self.mig_type(test, params, env, False)
            self.cdrom_size = int(params.get("cdrom_size", 10))
            cdrom = params.objects("cdroms")[-1]
            self.serial_num = params.get("drive_serial_%s" % cdrom)

            if self.is_src:
                self.cdrom_orig = create_iso_image(params, "orig", file_size=self.cdrom_size)
                self.cdrom_dir = os.path.dirname(self.cdrom_orig)
                vm = env.get_vm(self.vms[0])
                vm.destroy()
                params["start_vm"] = "yes"
                env_process.process(test, params, env, env_process.preprocess_image, env_process.preprocess_vm)
                vm = env.get_vm(self.vms[0])
                vm.wait_for_login(timeout=login_timeout)
            else:
                self.cdrom_orig = create_iso_image(params, "orig", False)
                self.cdrom_dir = os.path.dirname(self.cdrom_orig)
开发者ID:CongLi,项目名称:tp-qemu,代码行数:32,代码来源:cdrom.py


示例2: setup

    def setup(self, under_fs0):
        """
        Pre-process for uefishell environment, launch vm from the
        UefiShell.iso, and setup a serial session for uefishell

        :param under_fs0: most uefi command executed under fs0:\
        """
        params = self.params
        self.var_copy()
        for cdrom in params.objects("cdroms"):
            boot_index = params.get("boot_index_%s" % cdrom)
            if boot_index is not None:
                params["boot_index_%s" % cdrom] = int(boot_index) + 1
        for image in params.objects("images"):
            params["image_boot_%s" % image] = "no"
        params["cdroms"] = "%s %s" % ("uefishell", params["cdroms"])
        params["cdrom_uefishell"] = self.copy_uefishell()
        params["bootindex_uefishell"] = "0"
        params["start_vm"] = "yes"
        params["shell_prompt"] = r"(Shell|FS\d:\\.*)>"
        params["shell_linesep"] = r"\r\n"
        env_process.process(self.test, params, self.env,
                            env_process.preprocess_image,
                            env_process.preprocess_vm)
        vm = self.env.get_vm(params["main_vm"])
        self.session = vm.wait_for_serial_login()
        if under_fs0 == "yes":
            self.send_command("fs0:")
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:28,代码来源:uefishell.py


示例3: test

        def test(self):
            error.context("Preparing migration env and floppies.")
            mig_protocol = params.get("mig_protocol", "tcp")
            self.mig_type = utils_test.qemu.MultihostMigration
            if mig_protocol == "fd":
                self.mig_type = utils_test.qemu.MultihostMigrationFd
            if mig_protocol == "exec":
                self.mig_type = utils_test.qemu.MultihostMigrationExec

            self.vms = params.get("vms").split(" ")
            self.srchost = params["hosts"][0]
            self.dsthost = params["hosts"][1]
            self.is_src = params["hostid"] == self.srchost
            self.mig = self.mig_type(test, params, env, False, )

            if self.is_src:
                self.floppy = create_floppy(params)
                self.floppy_dir = os.path.dirname(self.floppy)
                params["start_vm"] = "yes"
                env_process.process(test, params, env,
                                    env_process.preprocess_image,
                                    env_process.preprocess_vm)
                vm = env.get_vm(self.vms[0])
                vm.wait_for_login(timeout=login_timeout)
            else:
                self.floppy = create_floppy(params, False)
                self.floppy_dir = os.path.dirname(self.floppy)
开发者ID:QiuMike,项目名称:tp-qemu,代码行数:27,代码来源:floppy.py


示例4: test

        def test(self):
            error.context("Preparing migration env and cdroms.")
            mig_protocol = params.get("mig_protocol", "tcp")
            self.mig_type = utils_test.qemu.MultihostMigration
            if mig_protocol == "fd":
                self.mig_type = utils_test.qemu.MultihostMigrationFd
            if mig_protocol == "exec":
                self.mig_type = utils_test.qemu.MultihostMigrationExec

            self.vms = params.get("vms").split(" ")
            self.srchost = params.get("hosts")[0]
            self.dsthost = params.get("hosts")[1]
            self.is_src = params.get("hostid") == self.srchost
            self.mig = self.mig_type(test, params, env, False, )
            self.cdrom_size = int(params.get("cdrom_size", 10))

            if self.is_src:
                self.cdrom_orig = create_iso_image(params, "orig",
                                                   file_size=self.cdrom_size)
                self.cdrom_dir = os.path.dirname(self.cdrom_orig)
                params["start_vm"] = "yes"
                env_process.process(test, params, env,
                                    env_process.preprocess_image,
                                    env_process.preprocess_vm)
                vm = env.get_vm(self.vms[0])
                vm.wait_for_login(timeout=login_timeout)
            else:
                self.cdrom_orig = create_iso_image(params, "orig", False)
                self.cdrom_dir = os.path.dirname(self.cdrom_orig)
开发者ID:QiuMike,项目名称:tp-qemu,代码行数:29,代码来源:cdrom.py


示例5: run

def run(test, params, env):
    """
    Qemu cpu test:

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
###plan:
####1.Can add loop to catch any test point method ,if so ,you can add the snario by add testcase cmdline
####but it need generate cfg file dynamically
####2.Cover the max matrix as soon as possible,and can test diff case or say snario by loop file 

    error_context.context("Vm boot up successful", logging.info)
    vm = QemuTest(test, params, env) 
    #id = params.get("id")
    #config = re.findall(r"qemu.(.+?).s2",id)[0]
    #with open("/home/id", 'r+') as file:
    #    file_id = file.read()
    #    if file_id != config:
    #        file.write(config)
    #        params.setdefault("kill_vm_gracefully", "yes")
    for i in range(1, 10):
        if i == 1:
            if params.get("not_preprocess") == "yes":
                error_prompt = params.get("error_prompt")
                error_context.context(("Check if have error prompt:[%s] " %
                                      error_prompt), logging.info)
                try:
                    env_process.process(test, params, env,
                                        env_process.preprocess_image,
                                        env_process.preprocess_vm)
                except virt_vm.VMCreateError as e:
                    if error_prompt not in e.output:
                        test.fail("There is no error prompt:[%s]" % error_prompt)
            continue 
        fp_group_var = "fp_group_s%s" % i
        fp_type = "fp_type_s%s" % i
        if params.get("not_preprocess") == "no":
            os = OsTest(test, params, env) 
            if params.get(fp_group_var):
                fp_group = params.get(fp_group_var)
                if params.get(fp_type) == "vm":
                    func = getattr(vm, params.get(fp_group))
                else:
                    func = getattr(os, params.get(fp_group))
                st = "s%s" % i      
                func(st)
                if "down" in func.__name__:
                    return
    os.dmesg()
开发者ID:maxujun,项目名称:test,代码行数:51,代码来源:new.py


示例6: run

def run(test, params, env):
    """
    Check the usb devices.

    1) Boot up guest with usb devices
    2) verify usb devices in monitor
    3) verify usb devices in guest

    :param test:   QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env:    Dictionary with test environment.
    """
    def _check_test_step_result(result, output):
        if result:
            logging.info(output)
        else:
            test.fail(output)

    # parse the usb topology from cfg
    parsed_devs = parse_usb_topology(params)

    logging.info("starting vm according to the usb topology")
    env_process.process(test, params, env,
                        env_process.preprocess_image,
                        env_process.preprocess_vm)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    # collect usb dev information for qemu check
    devs = collect_usb_dev(params, vm, parsed_devs, "for_qemu")

    error_context.context("verify usb devices information in qemu...",
                          logging.info)
    result, output = verify_usb_device_in_monitor_qtree(vm, devs)
    _check_test_step_result(result, output)

    # collect usb dev information for guest check
    devs = collect_usb_dev(params, vm, parsed_devs, "for_guest")
    login_timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=login_timeout)

    error_context.context("verify usb devices information in guest...",
                          logging.info)
    result, output = verify_usb_device_in_guest(params, session, devs)
    _check_test_step_result(result, output)

    session.close()
开发者ID:Zhengtong,项目名称:tp-qemu,代码行数:47,代码来源:usb_device_check.py


示例7: run

def run(test, params, env):
    """
    Qemu cpu test:

    :param test: QEMU test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
###plan:
####1.Can add loop to catch any test point method ,if so ,you can add the snario by add testcase cmdline
####but it need generate cfg file dynamically
####2.Cover the max matrix as soon as possible,and can test diff case or say snario by loop file 

    error_context.context("Vm boot up successful", logging.info)
    vm = QemuTest(test, params, env) 
    for i in range(1, 10):
        if i == 1:
            if params.get("not_preprocess") == "yes":
                error_prompt = params.get("error_prompt")
                error_context.context(("Check if have error prompt:[%s] " %
                                      error_prompt), logging.info)
                try:
                    env_process.process(test, params, env,
                                        env_process.preprocess_image,
                                        env_process.preprocess_vm)
                except virt_vm.VMCreateError as e:
                    if error_prompt not in e.output:
                        test.fail("There is no error prompt:[%s]" % error_prompt)
            continue 
        fp_group_var = "fp_group_s%s" % i
        fp_type = "fp_type_s%s" % i
        if params.get("not_preprocess") == "no":
            os = OsTest(test, params, env) 
            if params.get(fp_group_var):
                fp_group = params.get(fp_group_var)
                if params.get(fp_type) == "vm":
                    func = getattr(vm, params.get(fp_group))
                else:
                    func = getattr(os, params.get(fp_group))
                st = "s%s" % i      
                func(st)
    vm.serial_output()
开发者ID:maxujun,项目名称:test,代码行数:42,代码来源:new.py


示例8: _prepare_vm

        def _prepare_vm(self, vm_name):
            """
            Prepare, start vm and return vm.

            @param vm_name: Class with data necessary for migration.

            @return: Started VM.
            """
            new_params = self.params.copy()

            new_params['migration_mode'] = None
            new_params['start_vm'] = 'yes'
            self.vm_lock.acquire()
            env_process.process(self.test, new_params, self.env,
                                     env_process.preprocess_image,
                                     env_process.preprocess_vm)
            self.vm_lock.release()
            vm = self.env.get_vm(vm_name)
            vm.wait_for_login(timeout=self.login_timeout)
            return vm
开发者ID:vi-patel,项目名称:virt-test,代码行数:20,代码来源:migration_multi_host_with_file_transfer.py


示例9: test

        def test(self):
            super(test_multihost_ejecting, self).test()

            if self.is_src:  # Starts in source
                self.cdrom_new = create_iso_image(params, "new")
                serial_num = generate_serial_num()
                cdrom = params.get("cdroms", "").split()[-1]
                params["drive_serial_%s" % cdrom] = serial_num
                params["start_vm"] = "yes"
                env_process.process(test, params, env,
                                    env_process.preprocess_image,
                                    env_process.preprocess_vm)
                vm = env.get_vm(self.vms[0])
                session = vm.wait_for_login(timeout=login_timeout)
                cdrom_dev_list = list_guest_cdroms(session)
                logging.debug("cdrom_dev_list: %s", cdrom_dev_list)
                device = get_device(vm, self.cdrom_orig)
                cdrom = get_testing_cdrom_device(session, cdrom_dev_list,
                                                 serial_num)

                error.context("Eject cdrom.")
                session.cmd(params["eject_cdrom_cmd"] % cdrom)
                vm.eject_cdrom(device)
                time.sleep(2)
                if get_cdrom_file(vm, device) is not None:
                    raise error.TestFail("Device %s was not ejected" % (cdrom))

                cdrom = self.cdrom_new

                error.context("Change cdrom.")
                vm.change_media(device, cdrom)
                if get_cdrom_file(vm, device) != cdrom:
                    raise error.TestFail("It wasn't possible to change "
                                         "cdrom %s" % (cdrom))
                time.sleep(workaround_eject_time)

            self.mig._hosts_barrier(self.mig.hosts, self.mig.hosts,
                                    'cdrom_dev', cdrom_prepare_timeout)

            self.mig.migrate_wait([self.vms[0]], self.srchost, self.dsthost)
开发者ID:MiriamDeng,项目名称:tp-qemu,代码行数:40,代码来源:cdrom.py


示例10: run

def run(test, params, env):
    """
    Run an gluster test.
    steps:
    1) create gluster brick if there is no one with good name
    2) create volume on brick
    3) create VM image on disk with specific format
    4) install vm on VM image
    5) boot VM
    6) start fio test on booted VM

    :param test: QEMU test object.
    :param params: Dictionary with test parameters.
    :param env: Dictionary with the test environment.
    """
    image_name = params.get("image_name")
    timeout = int(params.get("login_timeout", 360))
    # Workaroud wrong config file order.
    params['image_name_backing_file_snapshot'] = params.get("image_name")
    params['image_format_backing_file_snapshot'] = params.get("image_format")
    params['image_name_snapshot'] = params.get("image_name") + "-snap"

    error_context.context("boot guest over glusterfs", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    vm.wait_for_login(timeout=timeout)
    error_context.context("shutdown VM", logging.info)
    vm.destroy()
    error_context.context("create snapshot of vm disk", logging.info)

    snapshot_params = params.object_params("snapshot")

    base_dir = params.get("images_base_dir", data_dir.get_data_dir())
    image = qemu_storage.QemuImg(snapshot_params, base_dir, image_name)
    image.create(snapshot_params)

    env_process.process(test, snapshot_params, env,
                        env_process.preprocess_image,
                        env_process.preprocess_vm)
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:39,代码来源:gluster_boot_snap_boot.py


示例11: prepare_for_migration

    def prepare_for_migration(self, mig_data, migration_mode):
        """
        Prepare destination of migration for migration.

        :param mig_data: Class with data necessary for migration.
        :param migration_mode: Migration mode for prepare machine.
        """
        new_params = self._prepare_params(mig_data)

        new_params["migration_mode"] = migration_mode
        new_params["start_vm"] = "yes"

        if self.params.get("migration_sync_vms", "no") == "yes":
            if mig_data.is_src():
                self.vm_lock.acquire()
                env_process.process(
                    self.test, new_params, self.env, env_process.preprocess_image, env_process.preprocess_vm
                )
                self.vm_lock.release()
                self._quick_check_vms(mig_data)

                # Send vms configuration to dst host.
                vms = cPickle.dumps([self.env.get_vm(vm_name) for vm_name in mig_data.vms_name])

                self.env.get_vm(mig_data.vms_name[0]).monitor.info("qtree")
                SyncData(self.master_id(), self.hostid, mig_data.hosts, mig_data.mig_id, self.sync_server).sync(
                    vms, timeout=240
                )
            elif mig_data.is_dst():
                # Load vms configuration from src host.
                vms = cPickle.loads(
                    SyncData(self.master_id(), self.hostid, mig_data.hosts, mig_data.mig_id, self.sync_server).sync(
                        timeout=240
                    )[mig_data.src]
                )
                for vm in vms:
                    # Save config to env. Used for create machine.
                    # When reuse_previous_config params is set don't check
                    # machine.
                    vm.address_cache = self.env.get("address_cache")
                    self.env.register_vm(vm.name, vm)

                self.vm_lock.acquire()
                env_process.process(
                    self.test, new_params, self.env, env_process.preprocess_image, env_process.preprocess_vm
                )
                vms[0].monitor.info("qtree")
                self.vm_lock.release()
                self._quick_check_vms(mig_data)
        else:
            self.vm_lock.acquire()
            env_process.process(
                self.test, new_params, self.env, env_process.preprocess_image, env_process.preprocess_vm
            )
            self.vm_lock.release()
            self._quick_check_vms(mig_data)

        self._check_vms(mig_data)
开发者ID:tjamrisk,项目名称:virt-test,代码行数:58,代码来源:qemu.py


示例12: run

def run(test, params, env):
    """
    The usb devices negative test

    1) Boot guest with invalid usb devices
    2) Verify QEMU error info

    :param test:   QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env:    Dictionary with test environment.
    """
    # parse the usb topology from cfg
    parse_usb_topology(params)
    logging.info("starting vm according to the usb topology")
    error_info = params["error_info"]
    error_context.context(("verify [%s] is reported by QEMU..." %
                          error_info), logging.info)
    try:
        env_process.process(test, params, env,
                            env_process.preprocess_image,
                            env_process.preprocess_vm)
    except virt_vm.VMCreateError, e:
        if error_info not in e.output:
            test.fail("%s is not reported by QEMU" % error_info)
开发者ID:Zhengtong,项目名称:tp-qemu,代码行数:24,代码来源:usb_device_check_negative.py


示例13: run

def run(test, params, env):
    """
    Verify SLOF info by user interface.

    Step:
     Scenario 1:
      1.1 Boot a guest with at least two blocks, with "-boot menu=on",
          Press "F12" in the guest desktop at the early stage of booting
          process.
      1.2 Check the boot menu info whether are match with guest info.
      1.3 Select one of valid device to boot up the guest.
      1.4 Check whether errors in SLOF.
      1.5 Log in guest successfully.
      1.6 Ping external host ip successfully.

     Scenario 2:
      2.1. Boot the guest with spapr-vty and press 's' immediately when
           the guest boot up.
      2.2. Check the output of console, whether is stopped enter kernel.
      2.3. Type "boot" or "reset-all".
      2.4. Check guest whether boot up successfully.
      2.5. Log in guest successfully.

    :param test: Qemu test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    STOP, F12 = range(2)
    enter_key = {STOP: 's', F12: 'f12'}

    def _send_custom_key(keystr):
        """ Send custom keyword to SLOF's user interface. """
        logging.info('Sending \"%s\" to SLOF user interface.' % keystr)
        for key in keystr:
            key = 'minus' if key == '-' else key
            vm.send_key(key)
        vm.send_key('ret')

    def _send_key(key, custom=True, sleep=0.0):
        """ Send keywords to SLOF's user interface. """
        obj_name = 'select' if re.search(r'^\d+$', key) else key
        k_params = params.object_params(obj_name.replace('-', '_'))
        if custom:
            _send_custom_key(key)
        else:
            vm.send_key(key)
        time.sleep(sleep)
        content, _ = slof.get_boot_content(vm, 0, k_params['start'], k_params['end'])
        if content:
            logging.info('Output of SLOF:\n%s' % ''.join(content))
            return ''.join(content)
        return None

    def _check_menu_info(menu_info):
        """ Check the menu info by each items. """
        bootable_num = ''
        for i in range(1, int(params['boot_dev_num']) + 1):
            option = params['menu_option%d' % i]
            logging.info('Checking the device(%s) if is included in menu list.'
                         % '->'.join(option.split()))

            dev_type, hba_type, child_bus, addr = option.split()
            addr = re.sub(r'^0x0?', '', addr)
            pattern = re.compile(r'(\d+)\)\s+%s(\d+)?\s+:\s+/%s(\S+)?/%[email protected]%s' %
                                 (dev_type, hba_type, child_bus, addr), re.M)
            searched = pattern.search(menu_info)
            if not searched:
                test.fail('No such item(%s) in boot menu list.' %
                          '->'.join(option.split()))
            if i == int(params['bootable_index']):
                bootable_num = searched.group(1)
        return bootable_num

    def _enter_user_interface(mode):
        """ Enter user interface. """
        o = utils_misc.wait_for(
            lambda: _send_key(enter_key[mode], False), ack_timeout, step=0.0)
        if not o:
            test.fail('Failed to enter user interface in %s sec.' % ack_timeout)
        return o

    def _f12_user_interface_test():
        """ Test f12 user interface. """
        menu_list = _enter_user_interface(F12)
        actual_num = len(re.findall(r'\d+\)', menu_list))
        dev_num = params['boot_dev_num']
        if actual_num != int(dev_num):
            test.fail(
                'The number of boot devices is not %s in menu list.' % dev_num)
        if not utils_misc.wait_for(
                lambda: _send_key(
                    _check_menu_info(menu_list), False), ack_timeout, step=0.0):
            test.fail('Failed to load after selecting boot device '
                      'in %s sec.' % ack_timeout)

    def _load_user_interface_test():
        """ Test boot/reset-all user interface. """
        _enter_user_interface(STOP)
        if not utils_misc.wait_for(
                lambda: _send_key(keys, True, 3), ack_timeout, step=0.0):
#.........这里部分代码省略.........
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:101,代码来源:slof_user_interface.py


示例14: run

def run(test, params, env):
    """
    PCI Devices test
    1) print outs the used setup
    2) boots the defined VM
    3) verifies monitor "info qtree" vs. autotest representation
    4) verifies guest "lspci" vs. info qtree (Linux only)
    :note: Only PCI device properties are checked

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment
    """
    error.context("Creating early names representation")
    env_process.preprocess_vm(test, params, env, params["main_vm"])
    vm = env.get_vm(params["main_vm"])
    qdev = vm.make_create_command()    # parse params into qdev

    error.context("Getting main PCI bus info")

    error.context("Processing test params")
    test_params = params['test_setup']
    test_devices = params['test_devices']
    test_device_type = params['test_device_type']
    if not params.get('pci_controllers'):
        params['pci_controllers'] = ''
    _lasts = [PCIBusInfo(qdev.get_by_properties({'aobject': 'pci.0'})[0])]
    _lasts[0].first = 7     # first 6 slots might be already occupied on pci.0
    _lasts[0].last -= 1     # last port is usually used by the VM
    use_buses = []
    names = {}
    logging.info("Test setup")
    for line in test_params.split('\\n'):
        _idx = 0
        out = ""
        for device in line.split('->'):
            device = device.strip()
            if device:
                if device == 'devices':
                    use_buses.append(_lasts[_idx])
                    out += "->(test_devices)"
                    break
                idx = names.get(device, 0) + 1
                name = "pci_%s%d" % (device, idx)
                names[device] = idx
                params, bus = add_bus(qdev, params, device, name, _lasts[_idx])
                # we inserted a device, increase the upper bus first idx
                _lasts[_idx].first += 1
                out += "->%s" % (name)
                _idx += 1
                if len(_lasts) > _idx:
                    _lasts = _lasts[:_idx]
                _lasts.append(bus)
            else:
                _idx += 1
                out += " " * (len(_lasts[_idx].name) + 2)
        logging.info(out)

    add_devices = {'first': add_devices_first,
                   'all': add_devices_all}.get(test_devices,
                                               add_devices_random)
    add_device = {'uhci': add_device_usb_uhci,
                  'ehci': add_device_usb_ehci,
                  'xhci': add_device_usb_xhci,
                  'virtio_disk': add_virtio_disk,
                  }.get(test_device_type, add_device_random)
    name_idxs = {}
    for bus in use_buses:
        params, name_idxs = add_devices(params, name_idxs, bus, add_device)
    params['start_vm'] = 'yes'
    env_process.process(test, params, env, env_process.preprocess_image,
                        env_process.preprocess_vm)
    vm = env.get_vm(params["main_vm"])

    # PCI devices are initialized by firmware, which might require some time
    # to setup. Wait 10s before getting the qtree.
    time.sleep(10)
    qtree = qemu_qtree.QtreeContainer()

    error.context("Verify qtree vs. qemu devices", logging.info)
    _info_qtree = vm.monitor.info('qtree', False)
    qtree.parse_info_qtree(_info_qtree)
    info_qdev = process_qdev(vm.devices)
    info_qtree = process_qtree(qtree)
    errors = ""
    err = verify_qdev_vs_qtree(info_qdev, info_qtree)
    if err:
        logging.error(_info_qtree)
        logging.error(qtree.get_qtree().str_qtree())
        logging.error(vm.devices.str_bus_long())
        logging.error(err)
        errors += "qdev vs. qtree, "

    error.context("Verify VM booted properly.", logging.info)
    session = vm.wait_for_login()

    error.context("Verify lspci vs. qtree", logging.info)
    if params.get('lspci_cmd'):
        _info_lspci = session.cmd_output(params['lspci_cmd'])
        info_lspci = process_lspci(_info_lspci)
#.........这里部分代码省略.........
开发者ID:CongLi,项目名称:tp-qemu,代码行数:101,代码来源:pci_devices.py


示例15: run

def run(test, params, env):
    """
    Verify the boot order from SLOF.

    Step:
     Scenario 1:
      1.1 Boot a guest with an empty disk, cdrom and nic, and don't
          specify disk bootindex=0, then set "order=cdn,once=n,menu=off,
          strict=off" for boot options.
      1.2 Check the boot order which should be nic->disk->cdrom->nic.
     Scenario 2:
      2.1 Boot a guest with an empty disk and nic, and don't specify
          this device bootindex=0, then set "order=cdn,once=n, menu=off,
          strict=off" for boot options.
      2.2 Check the boot order which should be nic->disk->nic.
     Scenario 3:
      3.1 Boot a guest with an empty disk, specify this device
          bootindex=0, then set "order=cdn,once=n,menu=off,strict=on" for
          boot options.
      3.2 Check the boot order which should be just disk.
     Scenario 4:
      4.1 Boot a guest with an empty disk and nic, specify this device
          bootindex=0, then set "order=cdn,once=n,menu=off,strict=off" for
          boot options.
      4.2 Check the boot order which should be disk->nic.

    :param test: Qemu test object.
    :param params: Dictionary with the test .
    :param env: Dictionary with test environment.
    """
    def _send_custom_key():
        """ Send custom keyword to SLOF's user interface. """
        logging.info('Sending \"%s\" to SLOF user interface.' % send_key)
        for key in send_key:
            key = 'minus' if key == '-' else key
            vm.send_key(key)
        vm.send_key('ret')

    def _verify_boot_order(order):
        """ Verify the order of booted devices. """
        for index, dev in enumerate(order.split()):
            args = device_map[dev]
            details = 'The device({}@{}) is not the {} bootable device.'.format(
                args[1], args[2], index)
            if not slof.verify_boot_device(
                    content, args[0], args[1], args[2], position=index):
                test.fail('Fail: ' + details)
            logging.info('Pass: ' + details)

    parent_bus = params.get('parent_bus')
    child_bus = params.get('child_bus')
    parent_bus_nic = params.get('parent_bus_nic')
    child_bus_nic = params.get('child_bus_nic')
    send_key = params.get('send_key')
    device_map = {'c': (parent_bus, child_bus, params.get('disk_addr')),
                  'd': (parent_bus, child_bus, params.get('cdrom_addr')),
                  'n': (parent_bus_nic, child_bus_nic, params.get('nic_addr'))}
    env_process.process(
        test, params, env, env_process.preprocess_image, env_process.preprocess_vm)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    content, next_pos = slof.wait_for_loaded(vm, test, end_str='0 >')
    _verify_boot_order(params['order_before_send_key'])
    if send_key in ('reset-all', 'boot'):
        error_context.context("Reboot guest by sending key.", logging.info)
        _send_custom_key()
        content, _ = slof.wait_for_loaded(vm, test, next_pos, end_str='0 >')
        _verify_boot_order(params['order_after_send_key'])
开发者ID:ldoktor,项目名称:tp-qemu,代码行数:69,代码来源:slof_order.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python error_context.context函数代码示例发布时间:2022-05-26
下一篇:
Python env_process.preprocess_vm函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap