rapi: Add /2/nodes/[node_name]/storage resource
authorMichael Hanselmann <hansmi@google.com>
Fri, 7 Aug 2009 13:28:47 +0000 (15:28 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 11 Aug 2009 11:55:29 +0000 (13:55 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

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

index 6ec6c6d..09fab7a 100644 (file)
@@ -528,6 +528,19 @@ job id.
 
 It supports the ``force`` argument.
 
+``/2/nodes/[node_name]/storage``
+++++++++++++++++++++++++++++++++
+
+Manages storage units on the node.
+
+``GET``
+~~~~~~~
+
+Requests a list of storage units on a node. Requires the parameters
+``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and
+``output_fields``. The result will be a job id, using which the result can be
+retrieved.
+
 ``/2/nodes/[node_name]/tags``
 +++++++++++++++++++++++++++++
 
index 83c1f2e..80c7aed 100644 (file)
@@ -159,6 +159,8 @@ CONNECTOR.update({
       rlib2.R_2_nodes_name_evacuate,
   re.compile(r'^/2/nodes/([\w\._-]+)/migrate$'):
       rlib2.R_2_nodes_name_migrate,
+  re.compile(r'^/2/nodes/([\w\._-]+)/storage$'):
+      rlib2.R_2_nodes_name_storage,
   "/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 0da39c1..269041f 100644 (file)
@@ -281,7 +281,7 @@ class R_2_nodes_name_evacuate(baserlib.R_Generic):
 
 
 class R_2_nodes_name_migrate(baserlib.R_Generic):
-  """/2/nodes/[node_name]/evacuate migrate.
+  """/2/nodes/[node_name]/migrate resource.
 
   """
   def POST(self):
@@ -296,6 +296,32 @@ class R_2_nodes_name_migrate(baserlib.R_Generic):
     return baserlib.SubmitJob([op])
 
 
+class R_2_nodes_name_storage(baserlib.R_Generic):
+  """/2/nodes/[node_name]/storage ressource.
+
+  """
+  # LUQueryNodeStorage acquires locks, hence restricting access to GET
+  GET_ACCESS = [rapi.RAPI_ACCESS_WRITE]
+
+  def GET(self):
+    node_name = self.items[0]
+
+    storage_type = self._checkStringVariable("storage_type", None)
+    if not storage_type:
+      raise http.HttpBadRequest("Missing the required 'storage_type'"
+                                " parameter")
+
+    output_fields = self._checkStringVariable("output_fields", None)
+    if not output_fields:
+      raise http.HttpBadRequest("Missing the required 'output_fields'"
+                                " parameter")
+
+    op = opcodes.OpQueryNodeStorage(nodes=[node_name],
+                                    storage_type=storage_type,
+                                    output_fields=output_fields.split(","))
+    return baserlib.SubmitJob([op])
+
+
 class R_2_instances(baserlib.R_Generic):
   """/2/instances resource.