from ganeti import constants
from ganeti import ht
from ganeti import pathutils
+from ganeti import vcluster
import qa_config
import qa_error
spath = _MULTIPLEXERS[node][0]
args.append("-oControlPath=%s" % spath)
args.append("-oControlMaster=no")
- args.append(node)
- if cmd:
- args.append(cmd)
+
+ (vcluster_master, vcluster_basedir) = \
+ qa_config.GetVclusterSettings()
+
+ if vcluster_master:
+ args.append(vcluster_master)
+ args.append("%s/%s/cmd" % (vcluster_basedir, node))
+
+ if cmd:
+ # For virtual clusters the whole command must be wrapped using the "cmd"
+ # script, as that script sets a number of environment variables. If the
+ # command contains shell meta characters the whole command needs to be
+ # quoted.
+ args.append(utils.ShellQuote(cmd))
+ else:
+ args.append(node)
+
+ if cmd:
+ args.append(cmd)
return args
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):
(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