From 9f0e6b373fd74397d25ad6ff71cee7ef413ba9b1 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 7 Oct 2008 11:39:50 +0000
Subject: [PATCH] rpc.call_instance_migrate: pass the whole instance

Currently the call_instance_migrate call only passes the instance name;
we need to pass the whole object for the hypervisor_type changes (all
the other individual instance rpc calls already pass the instance
object).

Reviewed-by: imsnah
---
 daemons/ganeti-noded |  1 +
 lib/backend.py       | 14 +++++++++++++-
 lib/rpc.py           | 14 ++++++++++++--
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index 495b65c21..6c5831182 100755
--- a/daemons/ganeti-noded
+++ b/daemons/ganeti-noded
@@ -362,6 +362,7 @@ class NodeDaemonRequestHandler(http.HTTPRequestHandler):
 
     """
     instance, target, live = params
+    instance = objects.Instance.FromDict(instance)
     return backend.MigrateInstance(instance, target, live)
 
   @staticmethod
diff --git a/lib/backend.py b/lib/backend.py
index 7dbce0c6c..5e11fcb0a 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -771,11 +771,23 @@ def RebootInstance(instance, reboot_type, extra_args):
 def MigrateInstance(instance, target, live):
   """Migrates an instance to another node.
 
+  @type instance: C{objects.Instance}
+  @param instance: the instance definition
+  @type target: string
+  @param target: the target node name
+  @type live: boolean
+  @param live: whether the migration should be done live or not (the
+      interpretation of this parameter is left to the hypervisor)
+  @rtype: tuple
+  @return: a tuple of (success, msg) where:
+      - succes is a boolean denoting the success/failure of the operation
+      - msg is a string with details in case of failure
+
   """
   hyper = hypervisor.GetHypervisor(_GetConfig())
 
   try:
-    hyper.MigrateInstance(instance, target, live)
+    hyper.MigrateInstance(instance.name, target, live)
   except errors.HypervisorError, err:
     msg = "Failed to migrate instance: %s" % str(err)
     logging.error(msg)
diff --git a/lib/rpc.py b/lib/rpc.py
index 14a618580..2a8e98bd3 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -209,8 +209,18 @@ def call_instance_migrate(node, instance, target, live):
 
   This is a single-node call.
 
-  """
-  c = Client("instance_migrate", [instance.name, target, live])
+  @type node: string
+  @param node: the node on which the instance is currently running
+  @type instance: instance object
+  @param instance: the instance definition
+  @type target: string
+  @param target: the target node name
+  @type live: boolean
+  @param live: whether the migration should be done live or not (the
+      interpretation of this parameter is left to the hypervisor)
+
+  """
+  c = Client("instance_migrate", [instance.ToDict(), target, live])
   c.connect(node)
   c.run()
   return c.getresult().get(node, False)
-- 
GitLab