Allow to send the iourc when starting the VM

Ref https://github.com/GNS3/gns3-server/issues/255
This commit is contained in:
Julien Duponchelle committed 2015-07-09 16:06:52 +02:00
1 parent dd6c377b15
commit a461cb71c6
3 files changed
+40 -3

No files matched your search

+9
View File
@@ -21,6 +21,7 @@ from aiohttp.web import HTTPConflict
from ...web.route import Route
from ...schemas.nio import NIO_SCHEMA
from ...schemas.iou import IOU_CREATE_SCHEMA
from ...schemas.iou import IOU_START_SCHEMA
from ...schemas.iou import IOU_UPDATE_SCHEMA
from ...schemas.iou import IOU_OBJECT_SCHEMA
from ...schemas.iou import IOU_CAPTURE_SCHEMA
@@ -151,11 +152,19 @@ class IOUHandler:
400: "Invalid request",
404: "Instance doesn't exist"
},
input=IOU_START_SCHEMA,
description="Start a IOU instance")
def start(request, response):
iou_manager = IOU.instance()
vm = iou_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
for name, value in request.json.items():
if hasattr(vm, name) and getattr(vm, name) != value:
setattr(vm, name, value)
print(name)
print(vm.iourc_path)
yield from vm.start()
response.set_status(204)
+16 -2
View File
@@ -91,7 +91,7 @@ IOU_CREATE_SCHEMA = {
"type": ["string", "null"]
},
"iourc_content": {
"description": "Content of the iourc file, if a file exist on servers this variable is ignored. It's mostly for compatibility with < 1.3 releases",
"description": "Content of the iourc file. Ignored if Null",
"type": ["string", "null"]
}
},
@@ -156,13 +156,27 @@ IOU_UPDATE_SCHEMA = {
"type": ["boolean", "null"]
},
"iourc_content": {
"description": "Content of the iourc file, if a file exist on servers this variable is ignored. It's mostly for compatibility with < 1.3 releases",
"description": "Content of the iourc file. Ignored if Null",
"type": ["string", "null"]
}
},
"additionalProperties": False,
}
IOU_START_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Request validation to start an IOU instance",
"type": "object",
"properties": {
"iourc_content": {
"description": "Content of the iourc file. Ignored if Null",
"type": ["string", "null"]
}
}
}
IOU_OBJECT_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "IOU instance",