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


Python Qemu.instance方法代码示例

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


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

示例1: test_create_image_abs_path

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
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:DJdano5,项目名称:gns3-server,代码行数:30,代码来源:test_qemu_manager.py

示例2: test_create_image_exist

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
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.modules.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:DJdano5,项目名称:gns3-server,代码行数:14,代码来源:test_qemu_manager.py

示例3: test_stop

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
def test_stop(loop, vm, running_subprocess_mock):
    process = running_subprocess_mock

    # Wait process kill success
    future = asyncio.Future()
    future.set_result(True)
    process.wait.return_value = future

    with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
        nio = Qemu.instance().create_nio(vm.qemu_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
        vm.adapter_add_nio_binding(0, nio)
        loop.run_until_complete(asyncio.async(vm.start()))
        assert vm.is_running()
        loop.run_until_complete(asyncio.async(vm.stop()))
        assert vm.is_running() is False
        process.terminate.assert_called_with()
开发者ID:ravirajsdeshmukh,项目名称:gns3-server,代码行数:18,代码来源:test_qemu_vm.py

示例4: test_create_image_relative_path

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
def test_create_image_relative_path(loop, tmpdir, fake_qemu_img_binary):
    options = {
        "format": "raw",
        "size": 100
    }
    with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
        with patch("gns3server.modules.qemu.Qemu.get_images_directory", return_value=str(tmpdir)):
            loop.run_until_complete(asyncio.async(Qemu.instance().create_disk(fake_qemu_img_binary, "hda.qcow2", options)))
            args, kwargs = process.call_args
            assert args == (
                fake_qemu_img_binary,
                "create",
                "-f",
                "raw",
                str(tmpdir / "hda.qcow2"),
                "100M"
            )
开发者ID:DJdano5,项目名称:gns3-server,代码行数:19,代码来源:test_qemu_manager.py

示例5: manager

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
def manager(port_manager):
    m = Qemu.instance()
    m.port_manager = port_manager
    return m
开发者ID:ravirajsdeshmukh,项目名称:gns3-server,代码行数:6,代码来源:test_qemu_vm.py

示例6: test_port_remove_nio_binding

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
def test_port_remove_nio_binding(vm, loop):
    nio = Qemu.instance().create_nio(vm.qemu_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
    loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
    loop.run_until_complete(asyncio.async(vm.adapter_remove_nio_binding(0)))
    assert vm._ethernet_adapters[0].ports[0] is None
开发者ID:ravirajsdeshmukh,项目名称:gns3-server,代码行数:7,代码来源:test_qemu_vm.py

示例7: test_add_nio_binding_ethernet

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
def test_add_nio_binding_ethernet(vm, loop, ethernet_device):
    with patch("gns3server.modules.base_manager.BaseManager.has_privileged_access", return_value=True):
        nio = Qemu.instance().create_nio(vm.qemu_path, {"type": "nio_generic_ethernet", "ethernet_device": ethernet_device})
        loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
        assert nio.ethernet_device == ethernet_device
开发者ID:ravirajsdeshmukh,项目名称:gns3-server,代码行数:7,代码来源:test_qemu_vm.py

示例8: test_add_nio_binding_udp

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
def test_add_nio_binding_udp(vm, loop):
    nio = Qemu.instance().create_nio(vm.qemu_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
    loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
    assert nio.lport == 4242
开发者ID:ravirajsdeshmukh,项目名称:gns3-server,代码行数:6,代码来源:test_qemu_vm.py

示例9: qemu

# 需要导入模块: from gns3server.modules.qemu import Qemu [as 别名]
# 或者: from gns3server.modules.qemu.Qemu import instance [as 别名]
def qemu(port_manager):
    Qemu._instance = None
    qemu = Qemu.instance()
    qemu.port_manager = port_manager
    return qemu
开发者ID:DJdano5,项目名称:gns3-server,代码行数:7,代码来源:test_manager.py


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