On 12/08/2014 05:50 PM, 'Klaus Aehlig' via ganeti-devel wrote:
....by just modifying the configuration and not changing
anythis in the real world.

anythis -> anything ?

Signed-off-by: Klaus Aehlig <aeh...@google.com>
---
  lib/cmdlib/instance_storage.py | 34 +++++++++++++++++++++++++++++++---
  1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/lib/cmdlib/instance_storage.py b/lib/cmdlib/instance_storage.py
index 6469b52..959207a 100644
--- a/lib/cmdlib/instance_storage.py
+++ b/lib/cmdlib/instance_storage.py
@@ -1899,7 +1899,7 @@ class LUInstanceReplaceDisks(LogicalUnit):
                                   " secondary node", errors.ECODE_INVAL)

    def ExpandNames(self):
-    self._ExpandAndLockInstance()
+    self._ExpandAndLockInstance(allow_forthcoming=True)

      assert locking.LEVEL_NODE not in self.needed_locks
      assert locking.LEVEL_NODE_RES not in self.needed_locks
@@ -2449,7 +2449,7 @@ class TLReplaceDisks(Tasklet):
      activate_disks = not self.instance.disks_active

      # Activate the instance disks if we're replacing them on a down instance

Maybe this comment can be extended by something like

  # Forthcoming instances have to real disks that could be activated.

-    if activate_disks:
+    if activate_disks and not self.instance.forthcoming:
        StartInstanceDisks(self.lu, self.instance, True)
        # Re-read the instance object modified by the previous call
        self.instance = self.cfg.GetInstanceInfo(self.instance.uuid)
@@ -2465,7 +2465,7 @@ class TLReplaceDisks(Tasklet):
      finally:
        # Deactivate the instance disks if we're replacing them on a
        # down instance
-      if activate_disks:
+      if activate_disks and not self.instance.forthcoming:
          _SafeShutdownInstanceDisks(self.lu, self.instance,
                                     req_states=INSTANCE_NOT_RUNNING)

@@ -2637,6 +2637,10 @@ class TLReplaceDisks(Tasklet):
      """
      steps_total = 6

+    if self.instance.forthcoming:
+      feedback_fn("Instance forthcoming, not touching disks")
+      return
+
      # Step: check device activation
      self.lu.LogStep(1, steps_total, "Check device existence")
      self._CheckDisksExistence([self.other_node_uuid, self.target_node_uuid])
@@ -2791,6 +2795,30 @@ class TLReplaceDisks(Tasklet):
      Failures are not very well handled.

      """
+    if self.instance.forthcoming:
+      feedback_fn("Instance fortcoming, will only update the configuration")
+      inst_disks = self.cfg.GetInstanceDisks(self.instance.uuid)
+      minors = self.cfg.AllocateDRBDMinor([self.new_node_uuid
+                                           for _ in inst_disks],
+                                          self.instance.uuid)
+      logging.debug("Allocated minors %r", minors)
+      iv_names = {}
+      for idx, (dev, new_minor) in enumerate(zip(inst_disks, minors)):
+        (o_node1, o_node2, o_port, o_minor1, o_minor2, o_secret) = \

o_node2 seems not used, maybe we can leave it away

+            dev.logical_id
+        if self.instance.primary_node == o_node1:
+          p_minor = o_minor1
+        else:
+          p_minor = o_minor2
+        new_net_id = (self.instance.primary_node, self.new_node_uuid, o_port,
+                      p_minor, new_minor, o_secret)
+        iv_names[idx] = (dev, dev.children, new_net_id)
+        logging.debug("Allocated new_minor: %s, new_logical_id: %s", new_minor,
+                      new_net_id)
+      self._UpdateDisksSecondary(iv_names, feedback_fn)
+      ReleaseLocks(self.lu, locking.LEVEL_NODE)
+      return
+
      steps_total = 6

      pnode = self.instance.primary_node


LGTM, no need to resend.

--
Niklas Hambüchen
Google Germany GmbH, Dienerstr. 12, 80331 Muenchen
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores

Reply via email to