commit 3ad780e4daf8d3bca0d6eecc144a35cfc9db6277
Author: Dimitris Aragiorgis <dimara@grnet.gr>
Date:   Wed Jan 8 06:36:07 2014 +0200

    (2.10) Include target node in hooks nodes for migration
    
    In case of DRBD, hooks run on both primary (source) and secondary
    (target) nodes. To get the same behavior for DTS_EXT_MIRROR, where we
    do not have secondary node, we should explicitly add target node to
    hooks nodes during instance migration/failover.
    
    CheckPrereq() of TLMigrateInstance runs before BuildHooksManager(),
    thus target_node calculated by Iallocator is available under
    self._migrater.target_node. Use this value instead of
    self.op.target_node which can be None.
    
    Update related doc entries.
    
    Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

diff --git a/doc/hooks.rst b/doc/hooks.rst
index 4961414..6a1a0e7 100644
--- a/doc/hooks.rst
+++ b/doc/hooks.rst
@@ -389,8 +389,8 @@ and secondary before failover.
 
 :directory: instance-failover
 :env. vars: IGNORE_CONSISTENCY, SHUTDOWN_TIMEOUT, OLD_PRIMARY, OLD_SECONDARY, NEW_PRIMARY, NEW_SECONDARY
-:pre-execution: master node, secondary node
-:post-execution: master node, primary and secondary nodes
+:pre-execution: master node, secondary (target) node
+:post-execution: master node, primary (source) and secondary (target) nodes
 
 OP_INSTANCE_MIGRATE
 ++++++++++++++++++++
@@ -401,8 +401,8 @@ and secondary before migration.
 
 :directory: instance-migrate
 :env. vars: MIGRATE_LIVE, MIGRATE_CLEANUP, OLD_PRIMARY, OLD_SECONDARY, NEW_PRIMARY, NEW_SECONDARY
-:pre-execution: master node, primary and secondary nodes
-:post-execution: master node, primary and secondary nodes
+:pre-execution: master node, primary (source) and secondary (target) nodes
+:post-execution: master node, primary (source) and secondary (target) nodes
 
 
 OP_INSTANCE_REMOVE
diff --git a/lib/cmdlib/instance_migration.py b/lib/cmdlib/instance_migration.py
index a5cbf4d..7cd9dd6 100644
--- a/lib/cmdlib/instance_migration.py
+++ b/lib/cmdlib/instance_migration.py
@@ -134,7 +134,7 @@ class LUInstanceFailover(LogicalUnit):
     """
     instance = self._migrater.instance
     source_node = instance.primary_node
-    target_node = self.op.target_node
+    target_node = self._migrater.target_node
     env = {
       "IGNORE_CONSISTENCY": self.op.ignore_consistency,
       "SHUTDOWN_TIMEOUT": self.op.shutdown_timeout,
@@ -159,6 +159,7 @@ class LUInstanceFailover(LogicalUnit):
     """
     instance = self._migrater.instance
     nl = [self.cfg.GetMasterNode()] + list(instance.secondary_nodes)
+    nl.append(self._migrater.target_node)
     return (nl, nl + [instance.primary_node])
 
 
@@ -197,7 +198,7 @@ class LUInstanceMigrate(LogicalUnit):
     """
     instance = self._migrater.instance
     source_node = instance.primary_node
-    target_node = self.op.target_node
+    target_node = self._migrater.target_node
     env = BuildInstanceHookEnvByObject(self, instance)
     env.update({
       "MIGRATE_LIVE": self._migrater.live,
@@ -211,7 +212,7 @@ class LUInstanceMigrate(LogicalUnit):
       env["OLD_SECONDARY"] = target_node
       env["NEW_SECONDARY"] = source_node
     else:
-      env["OLD_SECONDARY"] = env["NEW_SECONDARY"] = None
+      env["OLD_SECONDARY"] = env["NEW_SECONDARY"] = ""
 
     return env
 
@@ -222,6 +223,7 @@ class LUInstanceMigrate(LogicalUnit):
     instance = self._migrater.instance
     snodes = list(instance.secondary_nodes)
     nl = [self.cfg.GetMasterNode(), instance.primary_node] + snodes
+    nl.append(self._migrater.target_node)
     return (nl, nl)
 
 
@@ -346,7 +348,7 @@ class TLMigrateInstance(Tasklet):
         raise errors.ConfigurationError("No secondary node but using"
                                         " %s disk template" %
                                         instance.disk_template)
-      target_node = secondary_nodes[0]
+      self.target_node = target_node = secondary_nodes[0]
       if self.lu.op.iallocator or (self.lu.op.target_node and
                                    self.lu.op.target_node != target_node):
         if self.failover:
