Skip to content
Snippets Groups Projects
Commit 4c98b915 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rapi: Add /2/instances/[instance_name]/replace-disks resource


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 73086975
No related branches found
No related tags found
No related merge requests found
......@@ -334,6 +334,22 @@ instance if even if secondary disks are failing.
It supports the ``dry-run`` argument.
``/2/instances/[instance_name]/replace-disks``
++++++++++++++++++++++++++++++++++++++++++++++
Replaces disks on an instance.
It supports the following commands: ``POST``.
``POST``
~~~~~~~~
Takes the parameters ``mode`` (one of ``replace_on_primary``,
``replace_on_secondary``, ``replace_new_secondary`` or ``replace_auto``),
``disks`` (comma separated list of disk indexes), ``remote_node`` and
``iallocator``.
``/2/instances/[instance_name]/tags``
+++++++++++++++++++++++++++++++++++++
......
......@@ -170,6 +170,8 @@ CONNECTOR.update({
rlib2.R_2_instances_name_reboot,
re.compile(r'^/2/instances/([\w\._-]+)/reinstall$'):
rlib2.R_2_instances_name_reinstall,
re.compile(r'^/2/instances/([\w\._-]+)/replace-disks$'):
rlib2.R_2_instances_name_replace_disks,
re.compile(r'^/2/instances/([\w\._-]+)/shutdown$'):
rlib2.R_2_instances_name_shutdown,
re.compile(r'^/2/instances/([\w\._-]+)/startup$'):
......
......@@ -550,6 +550,37 @@ class R_2_instances_name_reinstall(baserlib.R_Generic):
return baserlib.SubmitJob(ops)
class R_2_instances_name_replace_disks(baserlib.R_Generic):
"""/2/instances/[instance_name]/replace-disks resource.
"""
def POST(self):
"""Replaces disks on an instance.
"""
instance_name = self.items[0]
remote_node = self._checkStringVariable("remote_node", default=None)
mode = self._checkStringVariable("mode", default=None)
raw_disks = self._checkStringVariable("disks", default=None)
iallocator = self._checkStringVariable("iallocator", default=None)
if raw_disks:
try:
disks = [int(part) for part in raw_disks.split(",")]
except ValueError, err:
raise http.HttpBadRequest("Invalid disk index passed: %s" % str(err))
else:
disks = []
op = opcodes.OpReplaceDisks(instance_name=instance_name,
remote_node=remote_node,
mode=mode,
disks=disks,
iallocator=iallocator)
return baserlib.SubmitJob([op])
class _R_Tags(baserlib.R_Generic):
""" Quasiclass for tagging resources
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment