diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py index bb5c1987..a6bd4a00 100644 --- a/gns3server/controller/topology.py +++ b/gns3server/controller/topology.py @@ -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 diff --git a/tests/topologies/1_5_cloud_udp/after/1_5_cloud_udp.gns3 b/tests/topologies/1_5_cloud_udp/after/1_5_cloud_udp.gns3 new file mode 100644 index 00000000..d04f3af8 --- /dev/null +++ b/tests/topologies/1_5_cloud_udp/after/1_5_cloud_udp.gns3 @@ -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" +} diff --git a/tests/topologies/1_5_cloud_udp/before/1_5_cloud_udp.gns3 b/tests/topologies/1_5_cloud_udp/before/1_5_cloud_udp.gns3 new file mode 100644 index 00000000..44047709 --- /dev/null +++ b/tests/topologies/1_5_cloud_udp/before/1_5_cloud_udp.gns3 @@ -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" +}