Start, stop, suspend and reload endpoints for all nodes belonging to a project. Fixes #1212.

This commit is contained in:
grossmj
2016-05-13 19:26:50 -06:00
parent 6cea6c9162
commit f1bc2f22c3
3 changed files with 112 additions and 0 deletions

View File

@ -88,6 +88,84 @@ class NodeHandler:
response.set_status(200)
response.json(node)
@Route.post(
r"/projects/{project_id}/nodes/start",
parameters={
"project_id": "Project UUID"
},
status_codes={
204: "All nodes successfully started",
400: "Invalid request",
404: "Instance doesn't exist"
},
description="Start all nodes belonging to the project",
output=NODE_OBJECT_SCHEMA)
def start_all(request, response):
project = Controller.instance().get_project(request.match_info["project_id"])
for node in project.nodes.values():
yield from node.start()
response.set_status(204)
@Route.post(
r"/projects/{project_id}/nodes/stop",
parameters={
"project_id": "Project UUID"
},
status_codes={
204: "All nodes successfully stopped",
400: "Invalid request",
404: "Instance doesn't exist"
},
description="Stop all nodes belonging to the project",
output=NODE_OBJECT_SCHEMA)
def stop_all(request, response):
project = Controller.instance().get_project(request.match_info["project_id"])
for node in project.nodes.values():
yield from node.stop()
response.set_status(204)
@Route.post(
r"/projects/{project_id}/nodes/suspend",
parameters={
"project_id": "Project UUID"
},
status_codes={
204: "All nodes successfully suspended",
400: "Invalid request",
404: "Instance doesn't exist"
},
description="Suspend all nodes belonging to the project",
output=NODE_OBJECT_SCHEMA)
def suspend_all(request, response):
project = Controller.instance().get_project(request.match_info["project_id"])
for node in project.nodes.values():
yield from node.suspend()
response.set_status(204)
@Route.post(
r"/projects/{project_id}/nodes/reload",
parameters={
"project_id": "Project UUID"
},
status_codes={
204: "All nodes successfully reloaded",
400: "Invalid request",
404: "Instance doesn't exist"
},
description="Reload all nodes belonging to the project",
output=NODE_OBJECT_SCHEMA)
def reload_all(request, response):
project = Controller.instance().get_project(request.match_info["project_id"])
for node in project.nodes.values():
yield from node.stop()
for node in project.nodes.values():
yield from node.start()
response.set_status(204)
@Route.post(
r"/projects/{project_id}/nodes/{node_id}/start",
parameters={