Commit 7160f14a authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

qa_utils: Support virtual cluster for backup files



“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: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
parent 50eaa5da
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment