From 0be973f2c59d7df98903227db94cf04351dc06b6 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 26 Jul 2016 21:40:11 +0200 Subject: [PATCH] Support Host node from 1.X topologies Fix #626 --- gns3server/controller/topology.py | 8 ++- tests/topologies/1_5_host/after/1_5_host.gns3 | 52 ++++++++++++++ .../topologies/1_5_host/before/1_5_host.gns3 | 68 +++++++++++++++++++ 3 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 tests/topologies/1_5_host/after/1_5_host.gns3 create mode 100644 tests/topologies/1_5_host/before/1_5_host.gns3 diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py index ab090d1d..bf6eb7f6 100644 --- a/gns3server/controller/topology.py +++ b/gns3server/controller/topology.py @@ -230,7 +230,9 @@ def _convert_1_3_later(topo, topo_path): elif old_node["type"] == "IOUDevice": node["node_type"] = "iou" elif old_node["type"] == "Cloud": - _create_cloud(node, old_node) + _create_cloud(node, old_node, ":/symbols/cloud.svg") + elif old_node["type"] == "Host": + _create_cloud(node, old_node, ":/symbols/computer.svg") else: raise NotImplementedError("Conversion of {} is not supported".format(old_node["type"])) @@ -418,9 +420,9 @@ def _convert_label(label): } -def _create_cloud(node, old_node): +def _create_cloud(node, old_node, icon): node["node_type"] = "cloud" - node["symbol"] = ":/symbols/cloud.svg" + node["symbol"] = icon node["console_type"] = None node["console"] = None del old_node["properties"]["nios"] diff --git a/tests/topologies/1_5_host/after/1_5_host.gns3 b/tests/topologies/1_5_host/after/1_5_host.gns3 new file mode 100644 index 00000000..5e2c72eb --- /dev/null +++ b/tests/topologies/1_5_host/after/1_5_host.gns3 @@ -0,0 +1,52 @@ +{ + "auto_start": false, + "name": "1_5_host", + "project_id": "ce17e635-bc1b-44df-946c-149e938dedc4", + "revision": 5, + "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, + "label": { + "rotation": 0, + "style": "font-family: TypeWriter;font-size: 10;font-weight: bold;fill: #000000;fill-opacity: 1.0;", + "text": "Host 1", + "x": 13, + "y": -25 + }, + "name": "Host 1", + "node_id": "ANYUUID", + "node_type": "cloud", + "properties": { + "interfaces": [ + ], + "ports": [ + {"interface": "bridge0", "port_number": 1, "type": "ethernet", "name": "bridge0"}, + {"interface": "en0", "port_number": 2, "type": "ethernet", "name": "en0"}, + {"interface": "en1", "port_number": 3, "type": "ethernet", "name": "en1"}, + {"interface": "en2", "port_number": 4, "type": "ethernet", "name": "en2"} + ] + }, + "symbol": ":/symbols/computer.svg", + "x": -69, + "y": -82, + "z": 1 + } + ] + }, + "type": "topology", + "version": "ANYSTR" +} diff --git a/tests/topologies/1_5_host/before/1_5_host.gns3 b/tests/topologies/1_5_host/before/1_5_host.gns3 new file mode 100644 index 00000000..bcc39e5c --- /dev/null +++ b/tests/topologies/1_5_host/before/1_5_host.gns3 @@ -0,0 +1,68 @@ +{ + "auto_start": false, + "name": "1_5_host", + "project_id": "ce17e635-bc1b-44df-946c-149e938dedc4", + "revision": 4, + "topology": { + "nodes": [ + { + "description": "Host", + "id": 1, + "label": { + "color": "#ff000000", + "font": "TypeWriter,10,-1,5,75,0,0,0,0,0", + "text": "Host 1", + "x": 13.2734375, + "y": -25.0 + }, + "ports": [ + { + "id": 1, + "name": "nio_gen_eth:bridge0", + "stub": true + }, + { + "id": 2, + "name": "nio_gen_eth:en0", + "stub": true + }, + { + "id": 3, + "name": "nio_gen_eth:en1", + "stub": true + }, + { + "id": 4, + "name": "nio_gen_eth:en2", + "stub": true + } + ], + "properties": { + "name": "Host 1", + "nios": [ + "nio_gen_eth:bridge0", + "nio_gen_eth:en0", + "nio_gen_eth:en1", + "nio_gen_eth:en2" + ] + }, + "server_id": 1, + "type": "Host", + "x": -69.5, + "y": -82.5 + } + ], + "servers": [ + { + "host": "127.0.0.1", + "id": 1, + "local": true, + "port": 3080, + "protocol": "http", + "vm": false + } + ] + }, + "type": "topology", + "version": "1.5.1" +}