mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Reload VM
This commit is contained in:
parent
b01d974f91
commit
6c11ad5fa6
@ -131,6 +131,13 @@ class VM:
|
|||||||
"""
|
"""
|
||||||
yield from self.post("/suspend")
|
yield from self.post("/suspend")
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def reload(self):
|
||||||
|
"""
|
||||||
|
Suspend a VM
|
||||||
|
"""
|
||||||
|
yield from self.post("/suspend")
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def post(self, path, data=None):
|
def post(self, path, data=None):
|
||||||
"""
|
"""
|
||||||
|
@ -110,3 +110,24 @@ class VMHandler:
|
|||||||
yield from vm.suspend()
|
yield from vm.suspend()
|
||||||
response.set_status(201)
|
response.set_status(201)
|
||||||
response.json(vm)
|
response.json(vm)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@Route.post(
|
||||||
|
r"/projects/{project_id}/vms/{vm_id}/reload",
|
||||||
|
parameters={
|
||||||
|
"project_id": "UUID for the project",
|
||||||
|
"vm_id": "UUID for the VM"
|
||||||
|
},
|
||||||
|
status_codes={
|
||||||
|
201: "Instance created",
|
||||||
|
400: "Invalid request"
|
||||||
|
},
|
||||||
|
description="Reload a VM instance",
|
||||||
|
output=VM_OBJECT_SCHEMA)
|
||||||
|
def reload(request, response):
|
||||||
|
|
||||||
|
project = Controller.instance().getProject(request.match_info["project_id"])
|
||||||
|
vm = project.getVM(request.match_info["vm_id"])
|
||||||
|
yield from vm.reload()
|
||||||
|
response.set_status(201)
|
||||||
|
response.json(vm)
|
||||||
|
@ -110,6 +110,14 @@ def test_suspend(vm, compute, project, async_run):
|
|||||||
compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/suspend".format(vm.project.id, vm.id))
|
compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/suspend".format(vm.project.id, vm.id))
|
||||||
|
|
||||||
|
|
||||||
|
def test_reload(vm, compute, project, async_run):
|
||||||
|
|
||||||
|
compute.post = AsyncioMagicMock()
|
||||||
|
|
||||||
|
async_run(vm.reload())
|
||||||
|
compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/reload".format(vm.project.id, vm.id))
|
||||||
|
|
||||||
|
|
||||||
def test_create_without_console(vm, compute, project, async_run):
|
def test_create_without_console(vm, compute, project, async_run):
|
||||||
"""
|
"""
|
||||||
None properties should be send. Because it can mean the emulator doesn"t support it
|
None properties should be send. Because it can mean the emulator doesn"t support it
|
||||||
|
@ -97,3 +97,12 @@ def test_suspend_vm(http_controller, tmpdir, project, compute, vm):
|
|||||||
response = http_controller.post("/projects/{}/vms/{}/suspend".format(project.id, vm.id), example=True)
|
response = http_controller.post("/projects/{}/vms/{}/suspend".format(project.id, vm.id), example=True)
|
||||||
assert response.status == 201
|
assert response.status == 201
|
||||||
assert response.json["name"] == vm.name
|
assert response.json["name"] == vm.name
|
||||||
|
|
||||||
|
|
||||||
|
def test_reload_vm(http_controller, tmpdir, project, compute, vm):
|
||||||
|
response = MagicMock()
|
||||||
|
compute.post = AsyncioMagicMock()
|
||||||
|
|
||||||
|
response = http_controller.post("/projects/{}/vms/{}/reload".format(project.id, vm.id), example=True)
|
||||||
|
assert response.status == 201
|
||||||
|
assert response.json["name"] == vm.name
|
||||||
|
Loading…
Reference in New Issue
Block a user