Commit 73452f12 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rapi: Add /2/[node_name]/evacuate resource



This can be used to evacuate a node.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent a392a6b8
......@@ -464,6 +464,22 @@ Example::
...
]
``/2/nodes/[node_name]/evacuate``
+++++++++++++++++++++++++++++++++
Evacuates all secondary instances off a node.
It supports the following commands: ``POST``.
``POST``
~~~~~~~~
To evacuate a node, either one of the ``iallocator`` or ``remote_node``
parameters must be passed:
evacuate?iallocator=[iallocator]
evacuate?remote_node=[nodeX.example.com]
``/2/nodes/[node_name]/role``
+++++++++++++++++++++++++++++
......
......@@ -155,6 +155,8 @@ CONNECTOR.update({
re.compile(r'^/2/nodes/([\w\._-]+)$'): rlib2.R_2_nodes_name,
re.compile(r'^/2/nodes/([\w\._-]+)/tags$'): rlib2.R_2_nodes_name_tags,
re.compile(r'^/2/nodes/([\w\._-]+)/role$'): rlib2.R_2_nodes_name_role,
re.compile(r'^/2/nodes/([\w\._-]+)/evacuate$'):
rlib2.R_2_nodes_name_evacuate,
"/2/instances": rlib2.R_2_instances,
re.compile(r'^/2/instances/([\w\._-]+)$'): rlib2.R_2_instances_name,
re.compile(r'^/2/instances/([\w\._-]+)/tags$'): rlib2.R_2_instances_name_tags,
......
......@@ -261,6 +261,25 @@ class R_2_nodes_name_role(baserlib.R_Generic):
return baserlib.SubmitJob([op])
class R_2_nodes_name_evacuate(baserlib.R_Generic):
"""/2/nodes/[node_name]/evacuate resource.
"""
def POST(self):
"""Evacuate all secondary instances off a node.
"""
node_name = self.items[0]
remote_node = self._checkStringVariable("remote_node", default=None)
iallocator = self._checkStringVariable("iallocator", default=None)
op = opcodes.OpEvacuateNode(node_name=node_name,
remote_node=remote_node,
iallocator=iallocator)
return baserlib.SubmitJob([op])
class R_2_instances(baserlib.R_Generic):
"""/2/instances resource.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment