From 03e31a2cb95b708f2d28f8b1935d31c8d55d86c6 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 31 Aug 2016 09:42:05 +0200 Subject: [PATCH] Fix crash when loading a topology without project id --- gns3server/controller/topology.py | 2 +- .../topologies/1_0_empty/after/1_0_empty.gns3 | 22 +++++++++++++++++++ .../1_0_empty/before/1_0_empty.gns3 | 16 ++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/topologies/1_0_empty/after/1_0_empty.gns3 create mode 100644 tests/topologies/1_0_empty/before/1_0_empty.gns3 diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py index df39dda7..7bf629c6 100644 --- a/gns3server/controller/topology.py +++ b/gns3server/controller/topology.py @@ -122,7 +122,7 @@ def _convert_1_3_later(topo, topo_path): "version": __version__, "auto_start": topo.get("auto_start", False), "name": topo["name"], - "project_id": topo["project_id"], + "project_id": topo.get("project_id"), "topology": { "links": [], "drawings": [], diff --git a/tests/topologies/1_0_empty/after/1_0_empty.gns3 b/tests/topologies/1_0_empty/after/1_0_empty.gns3 new file mode 100644 index 00000000..0b6c0312 --- /dev/null +++ b/tests/topologies/1_0_empty/after/1_0_empty.gns3 @@ -0,0 +1,22 @@ +{ + "version" : "ANYSTR", + "name" : "Downloads", + "topology" : { + "links" : [], + "drawings" : [], + "nodes" : [], + "computes" : [ + { + "protocol" : "http", + "name" : "Local", + "compute_id" : "local", + "port" : 8000, + "host" : "127.0.0.1" + } + ] + }, + "revision" : 5, + "project_id" : "ANYUUID", + "type" : "topology", + "auto_start" : false +} diff --git a/tests/topologies/1_0_empty/before/1_0_empty.gns3 b/tests/topologies/1_0_empty/before/1_0_empty.gns3 new file mode 100644 index 00000000..6372f285 --- /dev/null +++ b/tests/topologies/1_0_empty/before/1_0_empty.gns3 @@ -0,0 +1,16 @@ +{ + "name": "Downloads", + "resources_type": "local", + "topology": { + "servers": [ + { + "host": "127.0.0.1", + "id": 1, + "local": true, + "port": 8000 + } + ] + }, + "type": "topology", + "version": "1.0" +} \ No newline at end of file