From 6e7f6a94ecc442f82d6f403e157efb0099f9f50b Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 5 Sep 2016 16:55:38 +0200 Subject: [PATCH] Suspend for VPCS == stop Fix #1465 --- gns3server/controller/compute.py | 2 +- .../handlers/api/compute/vpcs_handler.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 865ceb5d..7aff7a83 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -452,7 +452,7 @@ class Compute: elif response.status == 403: raise aiohttp.web.HTTPForbidden(text=msg) elif response.status == 404: - raise aiohttp.web.HTTPNotFound(text=msg) + raise aiohttp.web.HTTPNotFound(text="{} {} not found".format(method, path)) elif response.status == 409: try: raise ComputeConflict(json.loads(body)) diff --git a/gns3server/handlers/api/compute/vpcs_handler.py b/gns3server/handlers/api/compute/vpcs_handler.py index 779a3bbb..32746c58 100644 --- a/gns3server/handlers/api/compute/vpcs_handler.py +++ b/gns3server/handlers/api/compute/vpcs_handler.py @@ -159,6 +159,25 @@ class VPCSHandler: yield from vm.stop() response.set_status(204) + @Route.post( + r"/projects/{project_id}/vpcs/nodes/{node_id}/suspend", + parameters={ + "project_id": "Project UUID", + "node_id": "Node UUID" + }, + status_codes={ + 204: "Instance stopped", + 400: "Invalid request", + 404: "Instance doesn't exist" + }, + description="Suspend a VPCS instance (stop it)") + def stop(request, response): + + vpcs_manager = VPCS.instance() + vm = vpcs_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) + yield from vm.stop() + response.set_status(204) + @Route.post( r"/projects/{project_id}/vpcs/nodes/{node_id}/reload", parameters={