本文整理匯總了Python中gns3server.controller.node.Node._ports方法的典型用法代碼示例。如果您正苦於以下問題:Python Node._ports方法的具體用法?Python Node._ports怎麽用?Python Node._ports使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gns3server.controller.node.Node
的用法示例。
在下文中一共展示了Node._ports方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_capture
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_capture(async_run, project):
compute1 = MagicMock()
node_vpcs = Node(project, compute1, "V1", node_type="vpcs")
node_vpcs._status = "started"
node_vpcs._ports = [EthernetPort("E0", 0, 0, 4)]
node_iou = Node(project, compute1, "I1", node_type="iou")
node_iou._ports = [EthernetPort("E0", 0, 3, 1)]
link = UDPLink(project)
link.create = AsyncioMagicMock()
async_run(link.add_node(node_vpcs, 0, 4))
async_run(link.add_node(node_iou, 3, 1))
capture = async_run(link.start_capture())
assert link.capturing
compute1.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/start_capture".format(project.id, node_vpcs.id), data={
"capture_file_name": link.default_capture_file_name(),
"data_link_type": "DLT_EN10MB"
})
capture = async_run(link.stop_capture())
assert link.capturing is False
compute1.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/stop_capture".format(project.id, node_vpcs.id))
示例2: test_update_filters
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_update_filters(async_run, project, compute):
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
link = Link(project)
link.create = AsyncioMagicMock()
link._project.emit_notification = MagicMock()
project.dump = AsyncioMagicMock()
async_run(link.add_node(node1, 0, 4))
node2 = Node(project, compute, "node2", node_type="qemu")
node2._ports = [EthernetPort("E0", 0, 0, 4)]
async_run(link.add_node(node2, 0, 4))
link.update = AsyncioMagicMock()
assert link._created
async_run(link.update_filters({
"packet_loss": [10],
"delay": [50, 10],
"frequency_drop": [0],
"bpf": [" \n "]
}))
assert link.filters == {
"packet_loss": [10],
"delay": [50, 10]
}
assert link.update.called
示例3: test_create
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_create(async_run, project):
compute1 = MagicMock()
compute2 = MagicMock()
node1 = Node(project, compute1, "node1", node_type="vpcs")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
node2 = Node(project, compute2, "node2", node_type="vpcs")
node2._ports = [EthernetPort("E0", 0, 3, 1)]
@asyncio.coroutine
def subnet_callback(compute2):
"""
Fake subnet callback
"""
return ("192.168.1.1", "192.168.1.2")
compute1.get_ip_on_same_subnet.side_effect = subnet_callback
link = UDPLink(project)
async_run(link.add_node(node1, 0, 4))
@asyncio.coroutine
def compute1_callback(path, data={}, **kwargs):
"""
Fake server
"""
if "/ports/udp" in path:
response = MagicMock()
response.json = {"udp_port": 1024}
return response
@asyncio.coroutine
def compute2_callback(path, data={}, **kwargs):
"""
Fake server
"""
if "/ports/udp" in path:
response = MagicMock()
response.json = {"udp_port": 2048}
return response
compute1.post.side_effect = compute1_callback
compute1.host = "example.com"
compute2.post.side_effect = compute2_callback
compute2.host = "example.org"
async_run(link.add_node(node2, 3, 1))
compute1.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/nio".format(project.id, node1.id), data={
"lport": 1024,
"rhost": "192.168.1.2",
"rport": 2048,
"type": "nio_udp"
}, timeout=120)
compute2.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/3/ports/1/nio".format(project.id, node2.id), data={
"lport": 2048,
"rhost": "192.168.1.1",
"rport": 1024,
"type": "nio_udp"
}, timeout=120)
示例4: test_json_serial_link
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_json_serial_link(async_run, project, compute, link):
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [SerialPort("S0", 0, 0, 4)]
node2 = Node(project, compute, "node2", node_type="qemu")
node2._ports = [SerialPort("S0", 0, 1, 3)]
link = Link(project)
link.create = AsyncioMagicMock()
async_run(link.add_node(node1, 0, 4))
async_run(link.add_node(node2, 1, 3))
assert link.__json__()["link_type"] == "serial"
示例5: test_default_capture_file_name
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_default_capture_file_name(project, compute, async_run):
node1 = Node(project, compute, "[email protected]", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
node2 = Node(project, compute, "w0.rld", node_type="qemu")
node2._ports = [EthernetPort("E0", 0, 1, 3)]
link = Link(project)
link.create = AsyncioMagicMock()
async_run(link.add_node(node1, 0, 4))
async_run(link.add_node(node2, 1, 3))
assert link.default_capture_file_name() == "Hello_0-4_to_w0rld_1-3.pcap"
示例6: link
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def link(async_run, project, compute):
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
node2 = Node(project, compute, "node2", node_type="qemu")
node2._ports = [EthernetPort("E0", 0, 1, 3)]
link = Link(project)
link.create = AsyncioMagicMock()
async_run(link.add_node(node1, 0, 4))
async_run(link.add_node(node2, 1, 3))
return link
示例7: test_add_node_cloud
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_add_node_cloud(async_run, project, compute):
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
node2 = Node(project, compute, "node2", node_type="cloud")
node2._ports = [EthernetPort("E0", 0, 0, 4)]
link = Link(project)
link.create = AsyncioMagicMock()
link._project.controller.notification.emit = MagicMock()
async_run(link.add_node(node1, 0, 4))
async_run(link.add_node(node2, 0, 4))
示例8: test_available_filters
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_available_filters(async_run, project, compute):
node1 = Node(project, compute, "node1", node_type="ethernet_switch")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
link = Link(project)
link.create = AsyncioMagicMock()
assert link.available_filters() == []
# Ethernet switch is not supported should return 0 filters
async_run(link.add_node(node1, 0, 4))
assert link.available_filters() == []
node2 = Node(project, compute, "node2", node_type="vpcs")
node2._ports = [EthernetPort("E0", 0, 0, 4)]
async_run(link.add_node(node2, 0, 4))
assert len(link.available_filters()) > 0
示例9: test_add_node_cloud_to_cloud
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_add_node_cloud_to_cloud(async_run, project, compute):
"""
Cloud to cloud connection is not allowed
"""
node1 = Node(project, compute, "node1", node_type="cloud")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
node2 = Node(project, compute, "node2", node_type="cloud")
node2._ports = [EthernetPort("E0", 0, 0, 4)]
link = Link(project)
link.create = AsyncioMagicMock()
link._project.emit_notification = MagicMock()
async_run(link.add_node(node1, 0, 4))
with pytest.raises(aiohttp.web.HTTPConflict):
async_run(link.add_node(node2, 0, 4))
示例10: test_add_node_serial_to_ethernet
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_add_node_serial_to_ethernet(async_run, project, compute):
"""
Serial to ethernet connection is not allowed
"""
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
node2 = Node(project, compute, "node2", node_type="qemu")
node2._ports = [SerialPort("E0", 0, 0, 4)]
link = Link(project)
link.create = AsyncioMagicMock()
link._project.controller.notification.emit = MagicMock()
async_run(link.add_node(node1, 0, 4))
with pytest.raises(aiohttp.web.HTTPConflict):
async_run(link.add_node(node2, 0, 4))
示例11: test_delete
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_delete(async_run, project, compute):
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
link = Link(project)
link.create = AsyncioMagicMock()
link._project.controller.notification.emit = MagicMock()
project.dump = AsyncioMagicMock()
async_run(link.add_node(node1, 0, 4))
node2 = Node(project, compute, "node2", node_type="qemu")
node2._ports = [EthernetPort("E0", 0, 0, 4)]
async_run(link.add_node(node2, 0, 4))
assert link in node2.link
async_run(link.delete())
assert link not in node2.link
示例12: test_delete
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_delete(async_run, project):
compute1 = MagicMock()
compute2 = MagicMock()
node1 = Node(project, compute1, "node1", node_type="vpcs")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
node2 = Node(project, compute2, "node2", node_type="vpcs")
node2._ports = [EthernetPort("E0", 0, 3, 1)]
link = UDPLink(project)
link.create = AsyncioMagicMock()
async_run(link.add_node(node1, 0, 4))
async_run(link.add_node(node2, 3, 1))
async_run(link.delete())
compute1.delete.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/nio".format(project.id, node1.id), timeout=120)
compute2.delete.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/3/ports/1/nio".format(project.id, node2.id), timeout=120)
示例13: test_read_pcap_from_source
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_read_pcap_from_source(project, async_run):
compute1 = MagicMock()
node_vpcs = Node(project, compute1, "V1", node_type="vpcs")
node_vpcs._status = "started"
node_vpcs._ports = [EthernetPort("E0", 0, 0, 4)]
node_iou = Node(project, compute1, "I1", node_type="iou")
node_iou._ports = [EthernetPort("E0", 0, 3, 1)]
link = UDPLink(project)
link.create = AsyncioMagicMock()
async_run(link.add_node(node_vpcs, 0, 4))
async_run(link.add_node(node_iou, 3, 1))
capture = async_run(link.start_capture())
assert link._capture_node is not None
async_run(link.read_pcap_from_source())
link._capture_node["node"].compute.stream_file.assert_called_with(project, "tmp/captures/" + link._capture_file_name)
示例14: test_add_node_already_connected
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_add_node_already_connected(async_run, project, compute):
"""
Raise an error if we try to use an already connected port
"""
project.dump = AsyncioMagicMock()
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
link = Link(project)
link.create = AsyncioMagicMock()
link._project.controller.notification.emit = MagicMock()
async_run(link.add_node(node1, 0, 4))
node2 = Node(project, compute, "node2", node_type="qemu")
node2._ports = [EthernetPort("E0", 0, 0, 4)]
async_run(link.add_node(node2, 0, 4))
assert link.create.called
link2 = Link(project)
link2.create = AsyncioMagicMock()
with pytest.raises(aiohttp.web.HTTPConflict):
async_run(link2.add_node(node1, 0, 4))
示例15: test_add_node_same_node
# 需要導入模塊: from gns3server.controller.node import Node [as 別名]
# 或者: from gns3server.controller.node.Node import _ports [as 別名]
def test_add_node_same_node(async_run, project, compute):
"""
Connection to the same node is not allowed
"""
node1 = Node(project, compute, "node1", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4), EthernetPort("E1", 0, 0, 5)]
link = Link(project)
link.create = AsyncioMagicMock()
link._project.controller.notification.emit = MagicMock()
async_run(link.add_node(node1, 0, 4))
with pytest.raises(aiohttp.web.HTTPConflict):
async_run(link.add_node(node1, 0, 5))