From 7160f14a507b0d80cbc5aa54819101b78d2e05ff Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 21 Feb 2013 14:58:27 +0100 Subject: [PATCH] qa_utils: Support virtual cluster for backup files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit βqa_utils.BackupFileβ is always called with the path for a normal node. In virtual clusters the node prefix path must be added. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Bernardo Dal Seno <bdalseno@google.com> --- qa/qa_utils.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/qa/qa_utils.py b/qa/qa_utils.py index d9389edbc..e842b1571 100644 --- a/qa/qa_utils.py +++ b/qa/qa_utils.py @@ -403,13 +403,19 @@ def BackupFile(node, path): anymore. """ + vpath = MakeNodePath(node, path) + cmd = ("tmp=$(tempfile --prefix .gnt --directory=$(dirname %s)) && " "[[ -f \"$tmp\" ]] && " "cp %s $tmp && " - "echo $tmp") % (utils.ShellQuote(path), utils.ShellQuote(path)) + "echo $tmp") % (utils.ShellQuote(vpath), utils.ShellQuote(vpath)) # Return temporary filename - return GetCommandOutput(node, cmd).strip() + result = GetCommandOutput(node, cmd).strip() + + print "Backup filename: %s" % result + + return result def _ResolveName(cmd, key): @@ -746,3 +752,26 @@ def GetNonexistentEntityNames(count, name_config, name_prefix): (count, name_config)) return candidates + + +def MakeNodePath(node, path): + """Builds an absolute path for a virtual node. + + @type node: string or L{qa_config._QaNode} + @param node: Node + @type path: string + @param path: Path without node-specific prefix + + """ + (_, basedir) = qa_config.GetVclusterSettings() + + if isinstance(node, basestring): + name = node + else: + name = node.primary + + if basedir: + assert path.startswith("/") + return "%s%s" % (vcluster.MakeNodeRoot(basedir, name), path) + else: + return path -- GitLab