diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py index d57b3c86..01d915ee 100644 --- a/gns3server/controller/topology.py +++ b/gns3server/controller/topology.py @@ -289,6 +289,10 @@ def _convert_1_3_later(topo, topo_path): node["properties"] = {} + # Some old dynamips node don't have type + if "type" not in old_node: + old_node["type"] = old_node["properties"]["platform"].upper() + if old_node["type"] == "VPCSDevice": node["node_type"] = "vpcs" elif old_node["type"] == "QemuVM": @@ -316,7 +320,7 @@ def _convert_1_3_later(topo, topo_path): node["symbol"] = ":/symbols/ethernet_switch.svg" node["console_type"] = None node["properties"]["ports_mapping"] = [] - for port in old_node["ports"]: + for port in old_node.get("ports", []): node["properties"]["ports_mapping"].append({ "name": "Ethernet{}".format(port["port_number"] - 1), "port_number": port["port_number"] - 1, diff --git a/tests/topologies/1_3_dynamips_missing_type/after/1_3_dynamips.gns3 b/tests/topologies/1_3_dynamips_missing_type/after/1_3_dynamips.gns3 new file mode 100644 index 00000000..eb264324 --- /dev/null +++ b/tests/topologies/1_3_dynamips_missing_type/after/1_3_dynamips.gns3 @@ -0,0 +1,77 @@ +{ + "auto_start": false, + "name": "1_3_dynamips", + "project_id": "ba5790e1-2f51-443e-a3cc-1a2eee132888", + "revision": 6, + "topology": { + "computes": [ + { + "compute_id": "local", + "host": "127.0.0.1", + "name": "Local", + "port": 8000, + "protocol": "http" + } + ], + "drawings": [], + "links": [], + "nodes": [ + { + "symbol": ":/symbols/iosv_virl.svg", + "compute_id": "local", + "console": 2001, + "console_type": "telnet", + "label": { + "rotation": 0, + "style": "font-family: TypeWriter;font-size: 10;font-weight: bold;fill: #000000;fill-opacity: 1.0;", + "text": "R1", + "x": 22, + "y": -25 + }, + "name": "R1", + "node_id": "0bce6ad5-c688-4d4d-a425-f21aaf3927e2", + "node_type": "dynamips", + "port_name_format": "Ethernet{0}", + "port_segment_size": 0, + "first_port_name": null, + "properties": { + "dynamips_id": 1, + "auto_delete_disks": true, + "clock_divisor": 4, + "disk0": 0, + "disk1": 0, + "exec_area": 64, + "idlemax": 500, + "idlesleep": 30, + "image": "c7200-adventerprisek9-mz.124-24.T8.image", + "mac_addr": "ca01.2f39.0000", + "midplane": "vxr", + "mmap": true, + "npe": "npe-400", + "nvram": 512, + "platform": "c7200", + "power_supplies": [ + 1, + 1 + ], + "ram": 512, + "sensors": [ + 22, + 22, + 22, + 22 + ], + "slot0": "C7200-IO-FE", + "sparsemem": true, + "startup_config": "configs/i1_startup-config.cfg", + "system_id": "FTX0945W0MY" + }, + "x": -112, + "y": -100, + "z": 1 + } + ] + }, + "type": "topology", + "version": "ANYSTR" +} diff --git a/tests/topologies/1_3_dynamips_missing_type/before/1_3_dynamips.gns3 b/tests/topologies/1_3_dynamips_missing_type/before/1_3_dynamips.gns3 new file mode 100644 index 00000000..14f2f95d --- /dev/null +++ b/tests/topologies/1_3_dynamips_missing_type/before/1_3_dynamips.gns3 @@ -0,0 +1,80 @@ +{ + "auto_start": false, + "name": "1_3_dynamips", + "project_id": "ba5790e1-2f51-443e-a3cc-1a2eee132888", + "revision": 3, + "topology": { + "nodes": [ + { + "default_symbol": ":/symbols/iosv_virl.normal.svg", + "description": "Router c7200", + "dynamips_id": 1, + "hover_symbol": ":/symbols/iosv_virl.selected.svg", + "id": 1, + "label": { + "color": "#000000", + "font": "TypeWriter,10,-1,5,75,0,0,0,0,0", + "text": "R1", + "x": 22.6171875, + "y": -25.0 + }, + "ports": [ + { + "adapter_number": 0, + "id": 1, + "name": "FastEthernet0/0", + "port_number": 0 + } + ], + "properties": { + "auto_delete_disks": true, + "clock_divisor": 4, + "console": 2001, + "disk0": 0, + "disk1": 0, + "exec_area": 64, + "idlemax": 500, + "idlesleep": 30, + "image": "c7200-adventerprisek9-mz.124-24.T8.image", + "mac_addr": "ca01.2f39.0000", + "midplane": "vxr", + "mmap": true, + "name": "R1", + "npe": "npe-400", + "nvram": 512, + "platform": "c7200", + "power_supplies": [ + 1, + 1 + ], + "ram": 512, + "sensors": [ + 22, + 22, + 22, + 22 + ], + "slot0": "C7200-IO-FE", + "sparsemem": true, + "startup_config": "configs/i1_startup-config.cfg", + "system_id": "FTX0945W0MY" + }, + "server_id": 1, + "vm_id": "0bce6ad5-c688-4d4d-a425-f21aaf3927e2", + "x": -112.0, + "y": -100.0 + } + ], + "servers": [ + { + "cloud": false, + "host": "127.0.0.1", + "id": 1, + "local": true, + "port": 8000 + } + ] + }, + "type": "topology", + "version": "1.3.13" +}