mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-18 23:43:48 +02:00
Make the server download images from cloud files
This commit is contained in:
parent
a833925497
commit
c08e1011ed
@ -18,6 +18,7 @@
|
|||||||
import os
|
import os
|
||||||
import base64
|
import base64
|
||||||
from gns3server.modules import IModule
|
from gns3server.modules import IModule
|
||||||
|
from gns3dms.cloud.rackspace_ctrl import get_provider
|
||||||
from ..dynamips_error import DynamipsError
|
from ..dynamips_error import DynamipsError
|
||||||
|
|
||||||
from ..nodes.c1700 import C1700
|
from ..nodes.c1700 import C1700
|
||||||
@ -138,9 +139,18 @@ class VM(object):
|
|||||||
chassis = request.get("chassis")
|
chassis = request.get("chassis")
|
||||||
router_id = request.get("router_id")
|
router_id = request.get("router_id")
|
||||||
|
|
||||||
|
# Locate the image
|
||||||
updated_image_path = os.path.join(self.images_directory, image)
|
updated_image_path = os.path.join(self.images_directory, image)
|
||||||
if os.path.isfile(updated_image_path):
|
if os.path.isfile(updated_image_path):
|
||||||
image = 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:
|
try:
|
||||||
|
|
||||||
|
@ -67,6 +67,10 @@ VM_CREATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
"pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"
|
"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,
|
"additionalProperties": False,
|
||||||
|
Loading…
Reference in New Issue
Block a user