From 1e82bc802a60b2377f3221fdab54eb23098c4e4e Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Tue, 11 Aug 2009 15:49:44 +0200 Subject: [PATCH] rapi: Add /2/nodes/[node_name]/storage/modify resource Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- doc/rapi.rst | 13 +++++++++++++ lib/rapi/connector.py | 2 ++ lib/rapi/rlib2.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/doc/rapi.rst b/doc/rapi.rst index 09fab7a15..9d95c8147 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -541,6 +541,19 @@ Requests a list of storage units on a node. Requires the parameters ``output_fields``. The result will be a job id, using which the result can be retrieved. +``/2/nodes/[node_name]/storage/modify`` ++++++++++++++++++++++++++++++++++++++++ + +Modifies storage units on the node. + +``PUT`` +~~~~~~~ + +Modifies parameters of storage units on the node. Requires the parameters +``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and ``name`` (name +of the storage unit). Parameters can be passed additionally. Currently only +``allocatable`` (bool) is supported. The result will be a job id. + ``/2/nodes/[node_name]/tags`` +++++++++++++++++++++++++++++ diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py index 80c7aed40..59621a9e5 100644 --- a/lib/rapi/connector.py +++ b/lib/rapi/connector.py @@ -161,6 +161,8 @@ CONNECTOR.update({ rlib2.R_2_nodes_name_migrate, re.compile(r'^/2/nodes/([\w\._-]+)/storage$'): rlib2.R_2_nodes_name_storage, + re.compile(r'^/2/nodes/([\w\._-]+)/storage/modify$'): + rlib2.R_2_nodes_name_storage_modify, "/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, diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index ba40b44a6..9b0ac0fe9 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -323,6 +323,36 @@ class R_2_nodes_name_storage(baserlib.R_Generic): return baserlib.SubmitJob([op]) +class R_2_nodes_name_storage_modify(baserlib.R_Generic): + """/2/nodes/[node_name]/storage/modify ressource. + + """ + def PUT(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") + + name = self._checkStringVariable("name", None) + if not name: + raise http.HttpBadRequest("Missing the required 'name'" + " parameter") + + changes = {} + + if "allocatable" in self.queryargs: + changes[constants.SF_ALLOCATABLE] = \ + bool(self._checkIntVariable("allocatable", default=1)) + + op = opcodes.OpModifyNodeStorage(node_name=node_name, + storage_type=storage_type, + name=name, + changes=changes) + return baserlib.SubmitJob([op]) + + class R_2_instances(baserlib.R_Generic): """/2/instances resource. -- GitLab