From e3ac84064276a4016542295a22c4c2f4886f410e Mon Sep 17 00:00:00 2001
From: Andrea Spadaccini <spadaccio@google.com>
Date: Fri, 28 Oct 2011 14:19:49 +0100
Subject: [PATCH] Add missing get_migration_status RPC definition

Add the instance_get_migration_status RPC definition and the needed
helper.

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/build/rpc_definitions.py | 3 +++
 lib/rpc.py                   | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/lib/build/rpc_definitions.py b/lib/build/rpc_definitions.py
index 79644b42e..1e2254957 100644
--- a/lib/build/rpc_definitions.py
+++ b/lib/build/rpc_definitions.py
@@ -146,6 +146,9 @@ _INSTANCE_CALLS = [
     ("success", None, "Whether the migration succeeded or not"),
     ("live", None, "Whether the user requested a live migration or not"),
     ], None, "Finalize the instance migration on the source node"),
+  ("instance_get_migration_status", SINGLE, TMO_SLOW, [
+    ("instance", INST_TO_DICT, "Instance object"),
+    ], "self._MigrationStatusPostProc", "Report migration status"),
   ("instance_start", SINGLE, TMO_NORMAL, [
     ("instance_hvp_bep", "self._InstDictHvpBep(%s)", None),
     ("startup_paused", None, None),
diff --git a/lib/rpc.py b/lib/rpc.py
index c4efad807..fcead58f9 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -493,6 +493,12 @@ class RpcRunner(_generated_rpc.RpcClientDefault,
 
     return self._proc(node_list, procedure, body, read_timeout=timeout)
 
+  @staticmethod
+  def _MigrationStatusPostProc(result):
+    if not result.fail_msg and result.payload is not None:
+      result.payload = objects.MigrationStatus.FromDict(result.payload)
+    return result
+
   @staticmethod
   def _BlockdevFindPostProc(result):
     if not result.fail_msg and result.payload is not None:
-- 
GitLab