From 3eccac065bcf2c81cc83a9d580fd16c48cee60d1 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 9 Jun 2009 11:50:00 +0200 Subject: [PATCH] Convert export_info rpc to new style result This also removes some code from ganeti-noded and rpc.py, which should not do such processing of data (and be simply glue code). (Or alternatively they could, if we had better infrastructure). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- daemons/ganeti-noded | 5 +---- lib/backend.py | 4 ++-- lib/cmdlib.py | 9 +++++---- lib/rpc.py | 5 +---- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 1367f226e..96a642bd3 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -310,10 +310,7 @@ class NodeHttpServer(http.server.HttpServer): """ path = params[0] - einfo = backend.ExportInfo(path) - if einfo is None: - return einfo - return einfo.Dumps() + return backend.ExportInfo(path) @staticmethod def perspective_export_list(params): diff --git a/lib/backend.py b/lib/backend.py index 298339916..82011a0ee 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1900,9 +1900,9 @@ def ExportInfo(dest): if (not config.has_section(constants.INISECT_EXP) or not config.has_section(constants.INISECT_INS)): - return None + _Fail("Export info file doesn't have the required fields") - return config + return True, config.Dumps() def ImportOSIntoInstance(instance, src_node, src_images, cluster_name): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 0394126a0..d2d433efa 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -4688,11 +4688,12 @@ class LUCreateInstance(LogicalUnit): _CheckNodeOnline(self, src_node) result = self.rpc.call_export_info(src_node, src_path) - result.Raise() - if not result.data: - raise errors.OpPrereqError("No export found in dir %s" % src_path) + msg = result.RemoteFailMsg() + if msg: + raise errors.OpPrereqError("No export or invalid export found in" + " dir %s: %s" % (src_path, msg)) - export_info = result.data + export_info = objects.SerializableConfigParser.Loads(str(result.payload)) if not export_info.has_section(constants.INISECT_EXP): raise errors.ProgrammerError("Corrupted export config") diff --git a/lib/rpc.py b/lib/rpc.py index 9e50a0ac4..7d6b26614 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -974,10 +974,7 @@ class RpcRunner(object): This is a single-node call. """ - result = self._SingleNodeCall(node, "export_info", [path]) - if not result.failed and result.data: - result.data = objects.SerializableConfigParser.Loads(str(result.data)) - return result + return self._SingleNodeCall(node, "export_info", [path]) def call_instance_os_import(self, node, inst, src_node, src_images, cluster_name): -- GitLab