mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge pull request #43 from planctechnologies/dev
Download IOS images from Cloud Files to a cloud instance
This commit is contained in:
commit
89e80fd74b
9 files changed
+270
-40
No files matched your search
@@ -61,6 +61,7 @@ class IModule(multiprocessing.Process):
|
||||
self._current_destination = None
|
||||
self._current_call_id = None
|
||||
self._stopping = False
|
||||
self._cloud_settings = config.cloud_settings()
|
||||
|
||||
def _setup(self):
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ import os
|
||||
import base64
|
||||
import time
|
||||
from gns3server.modules import IModule
|
||||
from gns3dms.cloud.rackspace_ctrl import get_provider
|
||||
from ..dynamips_error import DynamipsError
|
||||
|
||||
from ..nodes.c1700 import C1700
|
||||
@@ -140,12 +141,22 @@ 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 not os.path.exists(self.images_directory):
|
||||
os.mkdir(self.images_directory)
|
||||
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:
|
||||
|
||||
if platform not in PLATFORMS:
|
||||
raise DynamipsError("Unknown router platform: {}".format(platform))
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user