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


Python VPCS.instance方法代码示例

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


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

示例1: test_start_0_6_1

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_start_0_6_1(loop, vm):
    """
    Version 0.6.1 doesn't have the -R options. It's not require
    because GNS3 provide a patch for this.
    """
    process = MagicMock()
    process.returncode = None
    queue = vm.project.get_listen_queue()
    vm._vpcs_version = parse_version("0.6.1")

    with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
        with asyncio_patch("asyncio.create_subprocess_exec", return_value=process) as mock_exec:
            nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
            vm.port_add_nio_binding(0, nio)
            loop.run_until_complete(asyncio.async(vm.start()))
            assert mock_exec.call_args[0] == (vm.vpcs_path,
                                              '-p',
                                              str(vm.console),
                                              '-m', '1',
                                              '-i',
                                              '1',
                                              '-F',
                                              '-s',
                                              '4242',
                                              '-c',
                                              '4243',
                                              '-t',
                                              '127.0.0.1')
            assert vm.is_running()
    (action, event) = queue.get_nowait()
    assert action == "vm.started"
    assert event == vm
开发者ID:ravirajsdeshmukh,项目名称:gns3-server,代码行数:34,代码来源:test_vpcs_vm.py

示例2: test_port_remove_nio_binding

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_port_remove_nio_binding(vm):
    nio = VPCS.instance().create_nio(
        vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"}
    )
    vm.port_add_nio_binding(0, nio)
    vm.port_remove_nio_binding(0)
    assert vm._ethernet_adapter.ports[0] is None
开发者ID:DenerThiago21,项目名称:gns3-server,代码行数:9,代码来源:test_vpcs_vm.py

示例3: test_start

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_start(loop, vm):
    process = MagicMock()
    process.returncode = None
    queue = vm.project.get_listen_queue()

    with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
        with asyncio_patch("asyncio.create_subprocess_exec", return_value=process) as mock_exec:
            nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
            vm.port_add_nio_binding(0, nio)
            loop.run_until_complete(asyncio.async(vm.start()))
            assert mock_exec.call_args[0] == (vm.vpcs_path,
                                              '-p',
                                              str(vm.console),
                                              '-m', '1',
                                              '-i',
                                              '1',
                                              '-F',
                                              '-R',
                                              '-s',
                                              '4242',
                                              '-c',
                                              '4243',
                                              '-t',
                                              '127.0.0.1')
            assert vm.is_running()
            assert vm.command_line == ' '.join(mock_exec.call_args[0])
    (action, event) = queue.get_nowait()
    assert action == "vm.started"
    assert event == vm
开发者ID:ravirajsdeshmukh,项目名称:gns3-server,代码行数:31,代码来源:test_vpcs_vm.py

示例4: test_stop

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

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

    with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
        with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
            nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
            vm.port_add_nio_binding(0, nio)

            loop.run_until_complete(asyncio.async(vm.start()))
            assert vm.is_running()

            with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
                loop.run_until_complete(asyncio.async(vm.stop()))
            assert vm.is_running() is False

            if sys.platform.startswith("win"):
                process.send_signal.assert_called_with(1)
            else:
                process.terminate.assert_called_with()
开发者ID:astoffel,项目名称:gns3-server,代码行数:27,代码来源:test_vpcs_vm.py

示例5: test_start

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_start(loop, vm):
    process = MagicMock()
    process.returncode = None

    with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
        with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
            nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
            vm.port_add_nio_binding(0, nio)
            loop.run_until_complete(asyncio.async(vm.start()))
            assert vm.is_running()
开发者ID:bluca,项目名称:gns3-server,代码行数:12,代码来源:test_vpcs_vm.py

示例6: test_get_mac_id_no_id_available

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_get_mac_id_no_id_available(loop, project, port_manager):
    # Cleanup the VPCS object
    VPCS._instance = None
    vpcs = VPCS.instance()
    vpcs.port_manager = port_manager
    with pytest.raises(VPCSError):
        for i in range(0, 256):
            vm_id = str(uuid.uuid4())
            loop.run_until_complete(vpcs.create_vm("PC {}".format(i), project.id, vm_id))
            assert vpcs.get_mac_id(vm_id) == i
开发者ID:AshokVardhn,项目名称:gns3-server,代码行数:12,代码来源:test_vpcs_manager.py

示例7: test_get_mac_id

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_get_mac_id(loop, project, port_manager):
    # Cleanup the VPCS object
    VPCS._instance = None
    vpcs = VPCS.instance()
    vpcs.port_manager = port_manager
    vm1_id = str(uuid.uuid4())
    vm2_id = str(uuid.uuid4())
    vm3_id = str(uuid.uuid4())
    loop.run_until_complete(vpcs.create_vm("PC 1", project.id, vm1_id))
    loop.run_until_complete(vpcs.create_vm("PC 2", project.id, vm2_id))
    assert vpcs.get_mac_id(vm1_id) == 0
    assert vpcs.get_mac_id(vm1_id) == 0
    assert vpcs.get_mac_id(vm2_id) == 1
    loop.run_until_complete(vpcs.delete_vm(vm1_id))
    loop.run_until_complete(vpcs.create_vm("PC 3", project.id, vm3_id))
    assert vpcs.get_mac_id(vm3_id) == 0
开发者ID:AshokVardhn,项目名称:gns3-server,代码行数:18,代码来源:test_vpcs_manager.py

示例8: test_get_mac_id_multiple_project

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_get_mac_id_multiple_project(loop, port_manager):
    # Cleanup the VPCS object
    VPCS._instance = None
    vpcs = VPCS.instance()
    vpcs.port_manager = port_manager
    vm1_id = str(uuid.uuid4())
    vm2_id = str(uuid.uuid4())
    vm3_id = str(uuid.uuid4())
    project1 = ProjectManager.instance().create_project()
    project2 = ProjectManager.instance().create_project()
    loop.run_until_complete(vpcs.create_vm("PC 1", project1.id, vm1_id))
    loop.run_until_complete(vpcs.create_vm("PC 2", project1.id, vm2_id))
    loop.run_until_complete(vpcs.create_vm("PC 2", project2.id, vm3_id))
    assert vpcs.get_mac_id(vm1_id) == 0
    assert vpcs.get_mac_id(vm2_id) == 1
    assert vpcs.get_mac_id(vm3_id) == 0
开发者ID:AshokVardhn,项目名称:gns3-server,代码行数:18,代码来源:test_vpcs_manager.py

示例9: vpcs

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

示例10: manager

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

示例11: test_add_nio_binding_tap_no_privileged_access

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_add_nio_binding_tap_no_privileged_access(vm):
    with patch("gns3server.modules.base_manager.BaseManager._has_privileged_access", return_value=False):
        with pytest.raises(aiohttp.web.HTTPForbidden):
            nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_tap", "tap_device": "test"})
            vm.port_add_nio_binding(0, nio)
    assert vm._ethernet_adapter.ports[0] is None
开发者ID:bluca,项目名称:gns3-server,代码行数:8,代码来源:test_vpcs_vm.py

示例12: test_add_nio_binding_tap

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_add_nio_binding_tap(vm):
    with patch("gns3server.modules.base_manager.BaseManager._has_privileged_access", return_value=True):
        nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_tap", "tap_device": "test"})
        vm.port_add_nio_binding(0, nio)
        assert nio.tap_device == "test"
开发者ID:bluca,项目名称:gns3-server,代码行数:7,代码来源:test_vpcs_vm.py

示例13: test_add_nio_binding_udp

# 需要导入模块: from gns3server.modules.vpcs import VPCS [as 别名]
# 或者: from gns3server.modules.vpcs.VPCS import instance [as 别名]
def test_add_nio_binding_udp(vm):
    nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
    vm.port_add_nio_binding(0, nio)
    assert nio.lport == 4242
开发者ID:bluca,项目名称:gns3-server,代码行数:6,代码来源:test_vpcs_vm.py


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