Change the compute id to the GNS3 VM if it's not a Linux host

This commit is contained in:
Julien Duponchelle committed 2016-07-22 13:50:15 +02:00
1 parent eff6a9154d
commit ce557ecd23
4 files changed
+101 -4

No files matched your search

+2 -3
View File
@@ -123,7 +123,7 @@ def _export_project_file(project, path, z, include_images):
if node["node_type"] in ["virtualbox", "vmware", "cloud"]:
raise aiohttp.web.HTTPConflict(text="Topology with a {} could not be exported".format(node["node_type"]))
node["compute_id"] = "local" # To make project portable all node by default run on local
node["compute_id"] = "local" # To make project portable all node by default run on local
if "properties" in node and node["node_type"] != "Docker":
for prop, value in node["properties"].items():
@@ -133,12 +133,11 @@ def _export_project_file(project, path, z, include_images):
images.add(value)
if "topology" in topology:
topology["topology"]["computes"] = [] # Strip compute informations because could contain secret info like password
topology["topology"]["computes"] = [] # Strip compute informations because could contain secret info like password
for image in images:
_export_images(project, image, z)
z.writestr("project.gns3", json.dumps(topology).encode())
+7
View File
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import json
import uuid
import shutil
@@ -63,6 +64,12 @@ def import_project(controller, project_id, stream):
topology = load_topology(os.path.join(path, "project.gns3"))
topology["name"] = project_name
# For some VM type we move them to the GNS3 VM if it's not a Linux host
if not sys.platform.startswith("linux"):
for node in topology["topology"]["nodes"]:
if node["node_type"] in ("docker", "qemu", "iou"):
node["compute_id"] = "vm"
dot_gns3_path = os.path.join(path, project_name + ".gns3")
# We change the project_id to avoid erasing the project
topology["project_id"] = project_id