Convert export_info rpc to new style result
authorIustin Pop <iustin@google.com>
Tue, 9 Jun 2009 09:50:00 +0000 (11:50 +0200)
committerIustin Pop <iustin@google.com>
Mon, 15 Jun 2009 16:37:33 +0000 (18:37 +0200)
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
lib/backend.py
lib/cmdlib.py
lib/rpc.py

index 1367f22..96a642b 100755 (executable)
@@ -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):
index 2983399..82011a0 100644 (file)
@@ -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):
index 0394126..d2d433e 100644 (file)
@@ -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")
 
index 9e50a0a..7d6b266 100644 (file)
@@ -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):