From 7df43a7638efc05a12aac4f57a219e903daa24d5 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 12 Nov 2007 03:56:03 +0000
Subject: [PATCH] Relax replace_disks_all meaning for drbd8

In order to make the replace secondary action to be done via the same
opcode parameters for both remote_raid1 and drbd, we must allow the
LUReplaceDisks to change replace_disks_all for drbd with non-empty
remote_node into replace_disks_sec.

This fixes gnt-node evacuate and also allows gnt-instace replace-disks
to have the same syntax for both remote_raid1 and drbd (when replacing
the secondary).

Reviewed-by: ultrotter
---
 lib/cmdlib.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 3cb115645..f338da5f9 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -3329,6 +3329,7 @@ class LUReplaceDisks(LogicalUnit):
       raise errors.OpPrereqError("Instance '%s' not known" %
                                  self.op.instance_name)
     self.instance = instance
+    self.op.instance_name = instance.name
 
     if instance.disk_template not in constants.DTS_NET_MIRROR:
       raise errors.OpPrereqError("Instance's disk layout is not"
@@ -3367,6 +3368,11 @@ class LUReplaceDisks(LogicalUnit):
       raise errors.OpPrereqError("Template 'remote_raid1' only allows all"
                                  " disks replacement, not individual ones")
     if instance.disk_template == constants.DT_DRBD8:
+      if (self.op.mode == constants.REPLACE_DISK_ALL and
+          remote_node is not None):
+        # switch to replace secondary mode
+        self.op.mode = constants.REPLACE_DISK_SEC
+
       if self.op.mode == constants.REPLACE_DISK_ALL:
         raise errors.OpPrereqError("Template 'drbd8' only allows primary or"
                                    " secondary disk replacement, not"
-- 
GitLab