mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Suspend and resume for VirtualBox.
This commit is contained in:
parent
87bd0d1869
commit
3b7d08a80e
@ -87,3 +87,41 @@ class VirtualBoxHandler:
|
||||
vm = vbox_manager.get_vm(request.match_info["uuid"])
|
||||
yield from vm.stop()
|
||||
response.set_status(204)
|
||||
|
||||
@classmethod
|
||||
@Route.post(
|
||||
r"/virtualbox/{uuid}/suspend",
|
||||
parameters={
|
||||
"uuid": "VirtualBox VM instance UUID"
|
||||
},
|
||||
status_codes={
|
||||
204: "VirtualBox VM instance suspended",
|
||||
400: "Invalid VirtualBox VM instance UUID",
|
||||
404: "VirtualBox VM instance doesn't exist"
|
||||
},
|
||||
description="Suspend a VirtualBox VM instance")
|
||||
def suspend(request, response):
|
||||
|
||||
vbox_manager = VirtualBox.instance()
|
||||
vm = vbox_manager.get_vm(request.match_info["uuid"])
|
||||
yield from vm.suspend()
|
||||
response.set_status(204)
|
||||
|
||||
@classmethod
|
||||
@Route.post(
|
||||
r"/virtualbox/{uuid}/resume",
|
||||
parameters={
|
||||
"uuid": "VirtualBox VM instance UUID"
|
||||
},
|
||||
status_codes={
|
||||
204: "VirtualBox VM instance resumed",
|
||||
400: "Invalid VirtualBox VM instance UUID",
|
||||
404: "VirtualBox VM instance doesn't exist"
|
||||
},
|
||||
description="Resume a suspended VirtualBox VM instance")
|
||||
def suspend(request, response):
|
||||
|
||||
vbox_manager = VirtualBox.instance()
|
||||
vm = vbox_manager.get_vm(request.match_info["uuid"])
|
||||
yield from vm.resume()
|
||||
response.set_status(204)
|
||||
|
@ -75,14 +75,12 @@ class Project:
|
||||
:param vm_uuid: VM UUID
|
||||
"""
|
||||
|
||||
p = os.path.join(self._path, module, vm_uuid)
|
||||
workdir = os.path.join(self._path, module, vm_uuid)
|
||||
try:
|
||||
os.makedirs(p, exist_ok=True)
|
||||
except FileExistsError:
|
||||
pass
|
||||
os.makedirs(workdir, exist_ok=True)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPInternalServerError(text="Could not create VM working directory: {}".format(e))
|
||||
return p
|
||||
return workdir
|
||||
|
||||
def __json__(self):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user