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


Python utils_misc.generate_random_id函数代码示例

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


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

示例1: device_add_block

    def device_add_block(pci_num, queues=1):
        device_id = pci_type + "-" + utils_misc.generate_random_id()
        pci_info.append([device_id, device_id])

        image_format = params.get("image_format_%s" % img_list[pci_num + 1])
        if not image_format:
            image_format = params.get("image_format", "qcow2")
        image_filename = find_image(pci_num)

        pci_model = params.get("pci_model")
        controller_model = None
        if pci_model == "virtio":
            pci_model = "virtio-blk-pci"

        if pci_model == "scsi" or pci_model == "scsi-hd":
            if pci_model == "scsi":
                pci_model = "scsi-disk"
                if arch.ARCH in ('ppc64', 'ppc64le'):
                    controller_model = "spapr-vscsi"
                else:
                    controller_model = "lsi53c895a"
            if pci_model == "scsi-hd":
                controller_model = "virtio-scsi-pci"
            verify_supported_device(controller_model)
            controller_id = "controller-" + device_id
            if vm.monitor.protocol == "human":
                controller_add_cmd = ("device_add %s,id=%s" %
                                      (controller_model, controller_id))
            else:
                controller_add_cmd = ("device_add driver=%s,id=%s" %
                                      (controller_model, controller_id))
            error.context("Adding SCSI controller.", logging.info)
            vm.monitor.send_args_cmd(controller_add_cmd, convert=False)

        verify_supported_device(pci_model)
        if drive_cmd_type == "drive_add":
            driver_add_cmd = ("%s auto file=%s,if=none,format=%s,id=%s" %
                              (drive_cmd_type, image_filename, image_format,
                               pci_info[pci_num][0]))
        elif drive_cmd_type == "__com.redhat_drive_add":
            driver_add_cmd = ("%s file=%s,format=%s,id=%s" %
                              (drive_cmd_type, image_filename, image_format,
                               pci_info[pci_num][0]))
        # add block device to vm device container
        image_name = img_list[pci_num + 1]
        image_params = params.object_params(image_name)
        image_name = pci_info[pci_num][0]
        blk_insert = vm.devices.images_define_by_params(image_name,
                                                        image_params, 'disk')
        vm.devices.insert(blk_insert)
        env.register_vm(vm.name, vm)

        # add driver.
        error.context("Adding driver.", logging.info)
        vm.monitor.send_args_cmd(driver_add_cmd, convert=False)

        pci_add_cmd = ("device_add id=%s,driver=%s,drive=%s" %
                       (pci_info[pci_num][1], pci_model, pci_info[pci_num][0]))
        return device_add(pci_num, pci_add_cmd)
开发者ID:Chenditang,项目名称:tp-qemu,代码行数:59,代码来源:pci_hotplug.py

示例2: device_add_nic

    def device_add_nic(pci_num):
        device_id = pci_type + "-" + utils_misc.generate_random_id()
        pci_info.append([device_id, device_id])

        pci_model = params.get("pci_model")
        if pci_model == "virtio":
            pci_model = "virtio-net-pci"
        verify_supported_device(pci_model)
        pci_add_cmd = "device_add id=%s,driver=%s" % (pci_info[pci_num][1],
                                                      pci_model)
        return device_add(pci_num, pci_add_cmd)
开发者ID:FengYang,项目名称:virt-test,代码行数:11,代码来源:pci_hotplug.py

示例3: make_device_add_cmd

 def make_device_add_cmd(pa_pci_id, pci_addr=None):
     device_id = "%s" % pci_model + "-" + utils_misc.generate_random_id()
     pci_add_cmd = "device_add id=%s,driver=pci-assign,host=%s" % (device_id, pa_pci_id)
     if pci_addr is not None:
         pci_add_cmd += ",addr=%s" % pci_addr
     if params.get("hotplug_params"):
         assign_param = params.get("hotplug_params").split()
         for param in assign_param:
             value = params.get(param)
             if value:
                 pci_add_cmd += ",%s=%s" % (param, value)
     return pci_add_cmd
开发者ID:nloopa,项目名称:virt-test,代码行数:12,代码来源:sr_iov_hotplug_negative.py

示例4: device_add_iov

 def device_add_iov(pci_num):
     device_id = "%s" % pci_model + "-" + utils_misc.generate_random_id()
     pci_info.append([device_id])
     driver = params.get("device_driver", "pci-assign")
     check_support_device(driver)
     pci_add_cmd = "device_add id=%s,driver=%s,host=%s" % (pci_info[pci_num][0], driver, pa_pci_ids[pci_num])
     if params.get("hotplug_params"):
         assign_param = params.get("hotplug_params").split()
         for param in assign_param:
             value = params.get(param)
             if value:
                 pci_add_cmd += ",%s=%s" % (param, value)
     return device_add(pci_num, pci_add_cmd)
开发者ID:uni-peter-zheng,项目名称:tp-qemu,代码行数:13,代码来源:sr_iov_hotplug.py

示例5: device_add_block

    def device_add_block(pci_num, queues=1, pci_id=None):
        if pci_id is not None:
            device_id = pci_type + "-" + pci_id
        else:
            device_id = pci_type + "-" + utils_misc.generate_random_id()
            pci_info.append([device_id, device_id])

        image_format = params.get("image_format_%s" % img_list[pci_num + 1])
        if not image_format:
            image_format = params.get("image_format", "qcow2")
        image_filename = find_image(pci_num)

        pci_model = params.get("pci_model")
        controller_model = None
        if pci_model == "virtio":
            pci_model = "virtio-blk-pci"

        if pci_model == "scsi":
            pci_model = "scsi-disk"
            if arch.ARCH in ('ppc64', 'ppc64le'):
                controller_model = "spapr-vscsi"
            else:
                controller_model = "lsi53c895a"
            verify_supported_device(controller_model)
            controller_id = "controller-" + device_id
            controller_add_cmd = ("device_add %s,id=%s" %
                                  (controller_model, controller_id))
            error.context("Adding SCSI controller.")
            vm.monitor.send_args_cmd(controller_add_cmd)

        verify_supported_device(pci_model)
        if drive_cmd_type == "drive_add":
            driver_add_cmd = ("%s auto file=%s,if=none,format=%s,id=%s" %
                              (drive_cmd_type, image_filename, image_format,
                               pci_info[pci_num][0]))
        elif drive_cmd_type == "__com.redhat_drive_add":
            driver_add_cmd = ("%s file=%s,format=%s,id=%s" %
                              (drive_cmd_type, image_filename, image_format,
                               pci_info[pci_num][0]))
        # add driver.
        error.context("Adding driver.")
        vm.monitor.send_args_cmd(driver_add_cmd, convert=False)

        pci_add_cmd = ("device_add id=%s,driver=%s,drive=%s" %
                       (pci_info[pci_num][1],
                        pci_model,
                        pci_info[pci_num][0])
                       )
        return device_add(pci_num, pci_add_cmd, pci_id=pci_id)
开发者ID:CongLi,项目名称:tp-qemu,代码行数:49,代码来源:pci_hotplug_check.py

示例6: run


#.........这里部分代码省略.........
            for line in e.output.splitlines():
                logging.error(line)
            step_failures.append(step3)

        step4 = "client_run"
        try:
            session_server.cmd("cd /usr/local/autotest/client")
            session_server.cmd("./autotest-local run sleeptest",
                               timeout=pylint_run_timeout)
            session_server.cmd("rm -rf results/default")
        except aexpect.ShellCmdError as e:
            for line in e.output.splitlines():
                logging.error(line)
            step_failures.append(step4)

        if has_client_vm:
            step5 = "server_run"
            try:
                session_client.cmd("iptables -F")
                session_server.cmd("cd /usr/local/autotest")
                session_server.cmd("server/autotest-remote -m %s --ssh-user root "
                                   "--ssh-pass %s "
                                   "-c client/tests/sleeptest/control" %
                                   (client_ip, password),
                                   timeout=pylint_run_timeout)
                session_server.cmd("rm -rf results-*")
            except aexpect.ShellCmdError as e:
                for line in e.output.splitlines():
                    logging.error(line)
                step_failures.append(step5)

            step6 = "registering_client_cli"
            try:
                label_name = "label-%s" % utils_misc.generate_random_id()
                create_label_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
                                    "label create -t %s -w %s" %
                                    (label_name, server_ip))
                session_server.cmd(create_label_cmd)

                list_labels_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
                                   "label list -a -w %s" % server_ip)
                list_labels_output = session_server.cmd(list_labels_cmd)
                for line in list_labels_output.splitlines():
                    logging.debug(line)
                if label_name not in list_labels_output:
                    raise ValueError("No label %s in the output of %s" %
                                     (label_name, list_labels_cmd))

                create_host_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
                                   "host create -t %s %s -w %s" %
                                   (label_name, client_ip, server_ip))
                session_server.cmd(create_host_cmd)

                list_hosts_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
                                  "host list -w %s" % server_ip)
                list_hosts_output = session_server.cmd(list_hosts_cmd)
                for line in list_hosts_output.splitlines():
                    logging.debug(line)
                if client_ip not in list_hosts_output:
                    raise ValueError("No client %s in the output of %s" %
                                     (client_ip, create_label_cmd))
                if label_name not in list_hosts_output:
                    raise ValueError("No label %s in the output of %s" %
                                     (label_name, create_label_cmd))

            except (aexpect.ShellCmdError, ValueError) as e:
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:67,代码来源:autotest_regression.py

示例7: run_pci_hotplug

def run_pci_hotplug(test, params, env):
    """
    Test hotplug of PCI devices.

    (Elements between [] are configurable test parameters)
    1) PCI add a deivce (NIC / block)
    2) Compare output of monitor command 'info pci'.
    3) Compare output of guest command [reference_cmd].
    4) Verify whether pci_model is shown in [pci_find_cmd].
    5) Check whether the newly added PCI device works fine.
    6) PCI delete the device, verify whether could remove the PCI device.

    @param test:   KVM test object.
    @param params: Dictionary with the test parameters.
    @param env:    Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=timeout)

    # Modprobe the module if specified in config file
    module = params.get("modprobe_module")
    if module:
        session.cmd("modprobe %s" % module)

    # Get output of command 'info pci' as reference
    info_pci_ref = vm.monitor.info("pci")

    # Get output of command as reference
    reference = session.cmd_output(params.get("reference_cmd"))

    tested_model = params.get("pci_model")
    test_type = params.get("pci_type")
    image_format = params.get("image_format_stg")

    # Probe qemu to verify what is the supported syntax for PCI hotplug
    cmd_output = vm.monitor.cmd("?")
    if len(re.findall("\ndevice_add", cmd_output)) > 0:
        cmd_type = "device_add"
    elif len(re.findall("\npci_add", cmd_output)) > 0:
        cmd_type = "pci_add"
    else:
        raise error.TestError("Unknow version of qemu")

    # Determine syntax of drive hotplug
    # __com.redhat_drive_add == qemu-kvm-0.12 on RHEL 6
    if len(re.findall("\n__com.redhat_drive_add", cmd_output)) > 0:
        drive_cmd_type = "__com.redhat_drive_add"
    # drive_add == qemu-kvm-0.13 onwards
    elif len(re.findall("\ndrive_add", cmd_output)) > 0:
        drive_cmd_type = "drive_add"
    else:
        raise error.TestError("Unknow version of qemu")

    # Probe qemu for a list of supported devices
    devices_support = vm.monitor.cmd("%s ?" % cmd_type)

    if cmd_type == "pci_add":
        if test_type == "nic":
            pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
        elif test_type == "block":
            image_params = params.object_params("stg")
            image_filename = storage.get_image_filename(image_params,
                                                        data_dir.get_data_dir())
            pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" %
                           (image_filename, tested_model))
        # Execute pci_add (should be replaced by a proper monitor method call)
        add_output = vm.monitor.cmd(pci_add_cmd)
        if not "OK domain" in add_output:
            raise error.TestFail("Add PCI device failed. "
                                 "Monitor command is: %s, Output: %r" %
                                 (pci_add_cmd, add_output))
        after_add = vm.monitor.info("pci")

    elif cmd_type == "device_add":
        driver_id = test_type + "-" + utils_misc.generate_random_id()
        device_id = test_type + "-" + utils_misc.generate_random_id()
        if test_type == "nic":
            if tested_model == "virtio":
                tested_model = "virtio-net-pci"
            pci_add_cmd = "device_add id=%s,driver=%s" % (device_id,
                                                          tested_model)

        elif test_type == "block":
            image_params = params.object_params("stg")
            image_filename = storage.get_image_filename(image_params,
                                                        data_dir.get_data_dir())
            controller_model = None
            if tested_model == "virtio":
                tested_model = "virtio-blk-pci"

            if tested_model == "scsi":
                tested_model = "scsi-disk"
                controller_model = "lsi53c895a"
                if len(re.findall(controller_model, devices_support)) == 0:
                    raise error.TestError("scsi controller device (%s) not "
                                          "supported by qemu" %
                                          controller_model)

#.........这里部分代码省略.........
开发者ID:HeidCloud,项目名称:virt-test,代码行数:101,代码来源:pci_hotplug.py

示例8: ValueError

            session_client.cmd("iptables -F")
            session_server.cmd("cd /usr/local/autotest")
            session_server.cmd("server/autotest-remote -m %s --ssh-user root "
                               "--ssh-pass %s "
                               "-c client/tests/sleeptest/control" %
                               (client_ip, password),
                               timeout=pylint_run_timeout)
            session_server.cmd("rm -rf results-*")
        except aexpect.ShellCmdError, e:
            for line in e.output.splitlines():
                logging.error(line)
            step_failures.append(step5)

        step6 = "registering_client_cli"
        try:
            label_name = "label-%s" % utils_misc.generate_random_id()
            create_label_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
                                "label create -t %s -w %s" %
                                (label_name, server_ip))
            session_server.cmd(create_label_cmd)

            list_labels_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
                               "label list -a -w %s" % server_ip)
            list_labels_output = session_server.cmd(list_labels_cmd)
            for line in list_labels_output.splitlines():
                logging.debug(line)
            if not label_name in list_labels_output:
                raise ValueError("No label %s in the output of %s" %
                                 (label_name, list_labels_cmd))

            create_host_cmd = ("/usr/local/autotest/cli/autotest-rpc-client "
开发者ID:NixSilva,项目名称:virt-test,代码行数:31,代码来源:autotest_regression.py


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