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


Python qemu.Qemu类代码示例

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


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

示例1: test_get_kvm_archs_kvm_ok

def test_get_kvm_archs_kvm_ok(loop):

    with patch("os.path.exists", return_value=True):
        archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
        if platform.machine() == 'x86_64':
            assert archs == ['x86_64', 'i386']
        else:
            assert archs == [platform.machine()]

    with patch("os.path.exists", return_value=False):
        archs = loop.run_until_complete(asyncio.async(Qemu.get_kvm_archs()))
        assert archs == []
开发者ID:athmane,项目名称:gns3-server,代码行数:12,代码来源:test_qemu_manager.py

示例2: delete_nio

    async def delete_nio(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
        adapter_number = int(request.match_info["adapter_number"])
        await vm.adapter_remove_nio_binding(adapter_number)
        response.set_status(204)
开发者ID:GNS3,项目名称:gns3-server,代码行数:7,代码来源:qemu_handler.py

示例3: stop_capture

    async def stop_capture(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
        adapter_number = int(request.match_info["adapter_number"])
        await vm.stop_capture(adapter_number)
        response.set_status(204)
开发者ID:GNS3,项目名称:gns3-server,代码行数:7,代码来源:qemu_handler.py

示例4: stream_pcap_file

    async def stream_pcap_file(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
        adapter_number = int(request.match_info["adapter_number"])
        nio = vm.get_nio(adapter_number)
        await qemu_manager.stream_pcap_file(nio, vm.project.id, request, response)
开发者ID:GNS3,项目名称:gns3-server,代码行数:7,代码来源:qemu_handler.py

示例5: test_create_image_abs_path

def test_create_image_abs_path(loop, tmpdir, fake_qemu_img_binary):
    options = {
        "format": "qcow2",
        "preallocation": "metadata",
        "cluster_size": 64,
        "refcount_bits": 12,
        "lazy_refcounts": "off",
        "size": 100
    }
    with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
        loop.run_until_complete(asyncio.async(Qemu.instance().create_disk(fake_qemu_img_binary, str(tmpdir / "hda.qcow2"), options)))
        args, kwargs = process.call_args
        assert args == (
            fake_qemu_img_binary,
            "create",
            "-f",
            "qcow2",
            "-o",
            "cluster_size=64",
            "-o",
            "lazy_refcounts=off",
            "-o",
            "preallocation=metadata",
            "-o",
            "refcount_bits=12",
            str(tmpdir / "hda.qcow2"),
            "100M"
        )
开发者ID:athmane,项目名称:gns3-server,代码行数:28,代码来源:test_qemu_manager.py

示例6: start_capture

    async def start_capture(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
        adapter_number = int(request.match_info["adapter_number"])
        pcap_file_path = os.path.join(vm.project.capture_working_directory(), request.json["capture_file_name"])
        await vm.start_capture(adapter_number, pcap_file_path)
        response.json({"pcap_file_path": pcap_file_path})
开发者ID:GNS3,项目名称:gns3-server,代码行数:8,代码来源:qemu_handler.py

示例7: duplicate

    def duplicate(request, response):

        new_node = yield from Qemu.instance().duplicate_node(
            request.match_info["node_id"],
            request.json["destination_node_id"]
        )
        response.set_status(201)
        response.json(new_node)
开发者ID:athmane,项目名称:gns3-server,代码行数:8,代码来源:qemu_handler.py

示例8: test_get_qemu_version

def test_get_qemu_version(loop):

    with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard") as mock:
        version = loop.run_until_complete(asyncio.async(Qemu.get_qemu_version("/tmp/qemu-test")))
        if sys.platform.startswith("win"):
            assert version == ""
        else:
            assert version == "2.2.0"
开发者ID:athmane,项目名称:gns3-server,代码行数:8,代码来源:test_qemu_manager.py

示例9: update_nio

    def update_nio(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
        nio = vm.ethernet_adapters[int(request.match_info["adapter_number"])]
        if "filters" in request.json and nio:
            nio.filters = request.json["filters"]
        yield from vm.adapter_update_nio_binding(int(request.match_info["adapter_number"]), nio)
        response.set_status(201)
        response.json(request.json)
开发者ID:athmane,项目名称:gns3-server,代码行数:10,代码来源:qemu_handler.py

示例10: start

    def start(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
        if sys.platform.startswith("linux") and qemu_manager.config.get_section_config("Qemu").getboolean("enable_kvm", True) and "-no-kvm" not in vm.options:
            pm = ProjectManager.instance()
            if pm.check_hardware_virtualization(vm) is False:
                raise aiohttp.web.HTTPConflict(text="Cannot start VM with KVM enabled because hardware virtualization (VT-x/AMD-V) is already used by another software like VMware or VirtualBox")
        yield from vm.start()
        response.json(vm)
开发者ID:athmane,项目名称:gns3-server,代码行数:10,代码来源:qemu_handler.py

示例11: update

    def update(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])

        for name, value in request.json.items():
            if hasattr(vm, name) and getattr(vm, name) != value:
                setattr(vm, name, value)

        vm.updated()
        response.json(vm)
开发者ID:athmane,项目名称:gns3-server,代码行数:11,代码来源:qemu_handler.py

示例12: download_image

    async def download_image(request, response):
        filename = request.match_info["filename"]

        qemu_manager = Qemu.instance()
        image_path = qemu_manager.get_abs_image_path(filename)

        # Raise error if user try to escape
        if filename[0] == ".":
            raise aiohttp.web.HTTPForbidden()

        await response.stream_file(image_path)
开发者ID:GNS3,项目名称:gns3-server,代码行数:11,代码来源:qemu_handler.py

示例13: create_nio

    async def create_nio(request, response):

        qemu_manager = Qemu.instance()
        vm = qemu_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
        nio_type = request.json["type"]
        if nio_type not in ("nio_udp"):
            raise aiohttp.web.HTTPConflict(text="NIO of type {} is not supported".format(nio_type))
        nio = qemu_manager.create_nio(request.json)
        await vm.adapter_add_nio_binding(int(request.match_info["adapter_number"]), nio)
        response.set_status(201)
        response.json(nio)
开发者ID:GNS3,项目名称:gns3-server,代码行数:11,代码来源:qemu_handler.py

示例14: create_img

    def create_img(request, response):

        qemu_img = request.json.pop("qemu_img")
        path = request.json.pop("path")
        if os.path.isabs(path):
            config = Config.instance()
            if config.get_section_config("Server").getboolean("local", False) is False:
                response.set_status(403)
                return

        yield from Qemu.instance().create_disk(qemu_img, path, request.json)
        response.set_status(201)
开发者ID:athmane,项目名称:gns3-server,代码行数:12,代码来源:qemu_handler.py

示例15: test_create_image_exist

def test_create_image_exist(loop, tmpdir, fake_qemu_img_binary):
    open(str(tmpdir / "hda.qcow2"), "w+").close()

    options = {
        "format": "raw",
        "size": 100
    }
    with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
        with patch("gns3server.compute.qemu.Qemu.get_images_directory", return_value=str(tmpdir)):
            with pytest.raises(QemuError):
                loop.run_until_complete(asyncio.async(Qemu.instance().create_disk(fake_qemu_img_binary, "hda.qcow2", options)))
                assert not process.called
开发者ID:athmane,项目名称:gns3-server,代码行数:12,代码来源:test_qemu_manager.py


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