diff --git a/gns3server/modules/dynamips/backends/vm.py b/gns3server/modules/dynamips/backends/vm.py index 6a471620..091ed607 100644 --- a/gns3server/modules/dynamips/backends/vm.py +++ b/gns3server/modules/dynamips/backends/vm.py @@ -18,6 +18,7 @@ import os import base64 from gns3server.modules import IModule +from gns3dms.cloud.rackspace_ctrl import get_provider from ..dynamips_error import DynamipsError from ..nodes.c1700 import C1700 @@ -138,9 +139,18 @@ class VM(object): chassis = request.get("chassis") router_id = request.get("router_id") + # Locate the image updated_image_path = os.path.join(self.images_directory, image) if os.path.isfile(updated_image_path): image = updated_image_path + else: + if request.get("cloud_path", None): + # Download the image from cloud files + cloud_path = request.get("cloud_path") + full_cloud_path = "/".join((cloud_path, image)) + + provider = get_provider(self.cloud_settings) + provider.download_file(full_cloud_path, updated_image_path) try: diff --git a/gns3server/modules/dynamips/schemas/vm.py b/gns3server/modules/dynamips/schemas/vm.py index 328a10db..f00f39b1 100644 --- a/gns3server/modules/dynamips/schemas/vm.py +++ b/gns3server/modules/dynamips/schemas/vm.py @@ -67,6 +67,10 @@ VM_CREATE_SCHEMA = { "type": "string", "minLength": 1, "pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$" + }, + "cloud_path": { + "description": "Path to the image in the cloud object store", + "type": "string", } }, "additionalProperties": False,