Support IOU devices on cloud instances

This commit is contained in:
Jerry Seutter 2014-11-06 15:50:46 -07:00
parent 31db1a4e84
commit 0b0830976f
3 changed files with 21 additions and 0 deletions

View File

@ -155,6 +155,7 @@ class VM(object):
provider = get_provider(self._cloud_settings)
provider.download_file(full_cloud_path, updated_image_path)
image = updated_image_path
try:
if platform not in PLATFORMS:

View File

@ -21,12 +21,14 @@ IOU server module.
import os
import base64
import stat
import tempfile
import socket
import shutil
from gns3server.modules import IModule
from gns3server.config import Config
from gns3dms.cloud.rackspace_ctrl import get_provider
from .iou_device import IOUDevice
from .iou_error import IOUError
from .nios.nio_udp import NIO_UDP
@ -298,6 +300,20 @@ class IOU(IModule):
updated_iou_path = os.path.join(self.images_directory, iou_path)
if os.path.isfile(updated_iou_path):
iou_path = updated_iou_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, iou_path))
provider = get_provider(self._cloud_settings)
provider.download_file(full_cloud_path, updated_iou_path)
# Make file executable
st = os.stat(updated_iou_path)
os.chmod(updated_iou_path, st.st_mode | stat.S_IEXEC)
iou_path = updated_iou_path
try:
iou_instance = IOUDevice(name,

View File

@ -40,6 +40,10 @@ IOU_CREATE_SCHEMA = {
"description": "path to the IOU executable",
"type": "string",
"minLength": 1,
},
"cloud_path": {
"description": "Path to the image in the cloud object store",
"type": "string",
}
},
"additionalProperties": False,