1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-05 07:38:56 +00:00

Make the server download images from cloud files

This commit is contained in:
Jerry Seutter 2014-10-15 15:51:00 -06:00
parent a833925497
commit c08e1011ed
2 changed files with 14 additions and 0 deletions

View File

@ -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:

View File

@ -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,