1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 00:08:11 +00:00

Support UDP cloud from 1.5

Fix #822
This commit is contained in:
Julien Duponchelle 2016-12-19 09:46:13 +01:00
parent f86358ad71
commit 7ba7c89594
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 134 additions and 6 deletions

View File

@ -485,15 +485,28 @@ def _create_cloud(node, old_node, icon):
port_type = "ethernet"
elif old_port["name"].startswith("nio_tap"):
port_type = "tap"
elif old_port["name"].startswith("nio_udp"):
port_type = "udp"
else:
raise NotImplementedError("The conversion of cloud with {} is not supported".format(old_port["name"]))
port = {
"interface": old_port["name"].split(":")[1],
"name": old_port["name"].split(":")[1],
"port_number": len(ports) + 1,
"type": port_type
}
if port_type == "udp":
_, lport, rhost, rport = old_port["name"].split(":")
port = {
"name": "UDP tunnel {}".format(len(ports) + 1),
"port_number": len(ports) + 1,
"type": port_type,
"lport": int(lport),
"rhost": rhost,
"rport": int(rport)
}
else:
port = {
"interface": old_port["name"].split(":")[1],
"name": old_port["name"].split(":")[1],
"port_number": len(ports) + 1,
"type": port_type
}
ports.append(port)
node["properties"]["ports_mapping"] = ports

View File

@ -0,0 +1,60 @@
{
"auto_start": false,
"name": "untitled",
"project_id": "a22527ce-c976-48d6-afe9-2a04dea47a99",
"revision": 6,
"topology": {
"computes": [
{
"compute_id": "local",
"host": "127.0.0.1",
"name": "Local",
"port": 3080,
"protocol": "http"
}
],
"drawings": [],
"links": [
],
"nodes": [
{
"compute_id": "local",
"console": null,
"console_type": null,
"first_port_name": null,
"label": {
"rotation": 0,
"style": "font-family: TypeWriter;font-size: 10;font-weight: bold;fill: #000000;fill-opacity: 1.0;",
"text": "Cloud 1",
"x": 55,
"y": -25
},
"name": "Cloud 1",
"node_id": "ANYSTR",
"node_type": "cloud",
"port_name_format": "Ethernet{0}",
"port_segment_size": 0,
"properties": {
"interfaces": [
],
"ports_mapping": [
{
"lport": 30000,
"name": "UDP tunnel 1",
"port_number": 1,
"rhost": "127.0.0.1",
"rport": 20000,
"type": "udp"
}
]
},
"symbol": ":/symbols/cloud.svg",
"x": -210,
"y": -167,
"z": 1
}
]
},
"type": "topology",
"version": "ANYSTR"
}

View File

@ -0,0 +1,55 @@
{
"auto_start": false,
"name": "untitled",
"project_id": "a22527ce-c976-48d6-afe9-2a04dea47a99",
"revision": 4,
"topology": {
"links": [
],
"nodes": [
{
"description": "Cloud",
"id": 1,
"label": {
"color": "#ff000000",
"font": "TypeWriter,10,-1,5,75,0,0,0,0,0",
"text": "Cloud 1",
"x": 55.6015625,
"y": -25.0
},
"ports": [
{
"description": "connected to PC1 on port Ethernet0",
"id": 2,
"link_id": 1,
"name": "nio_udp:30000:127.0.0.1:20000",
"nio": "NIO_UDP",
"stub": true
}
],
"properties": {
"name": "Cloud 1",
"nios": [
"nio_udp:30000:127.0.0.1:20000"
]
},
"server_id": 1,
"type": "Cloud",
"x": -210.5,
"y": -167.0
}
],
"servers": [
{
"host": "127.0.0.1",
"id": 1,
"local": true,
"port": 3080,
"protocol": "http",
"vm": false
}
]
},
"type": "topology",
"version": "1.5.1"
}