rapi: Add /2/[node_name]/evacuate resource
authorMichael Hanselmann <hansmi@google.com>
Thu, 30 Jul 2009 10:46:23 +0000 (12:46 +0200)
committerMichael Hanselmann <hansmi@google.com>
Thu, 30 Jul 2009 11:02:45 +0000 (13:02 +0200)
This can be used to evacuate a node.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

doc/rapi.rst
lib/rapi/connector.py
lib/rapi/rlib2.py

index a913b32..b14b8f2 100644 (file)
@@ -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``
 +++++++++++++++++++++++++++++
 
index c3c12e6..1b9d646 100644 (file)
@@ -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,
index 9c8e2a0..9ef6247 100644 (file)
@@ -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.