From c0cbdc6779380c34780d18ede90afd8751915f77 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Tue, 2 Dec 2008 10:19:16 +0000 Subject: [PATCH] LUCreateInstance: handle import without src_node If we get called with no source node we'll thread src_path as an instance name exported in EXPORT_DIR in one of the nodes and look for it with the export_list rpc call. Reviewed-by: iustinp --- lib/cmdlib.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index ae5055245..7e6fe7851 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3746,6 +3746,21 @@ class LUCreateInstance(LogicalUnit): src_node = self.op.src_node src_path = self.op.src_path + if src_node is None: + exp_list = self.rpc.call_export_list( + self.acquired_locks[locking.LEVEL_NODE]) + found = False + for node in exp_list: + if src_path in exp_list[node]: + found = True + self.op.src_node = src_node = node + self.op.src_path = src_path = os.path.join(constants.EXPORT_DIR, + src_path) + break + if not found: + raise errors.OpPrereqError("No export found for relative path %s" % + src_path) + export_info = self.rpc.call_export_info(src_node, src_path) if not export_info: -- GitLab