def AddNodePrefix(path, _noderoot=_VIRT_NODEROOT):
  """Adds a node-specific prefix to a path in a virtual cluster.

  Returned path includes user-specified root directory if specified in
  environment. As an example, the path C{/var/lib/ganeti} becomes
  C{/tmp/vcluster/node1/var/lib/ganeti} if C{/tmp/vcluster/node1} is the root
  directory specified in the environment.

  """
  assert os.path.isabs(path), "Path not absolute: " + path

  if _noderoot:
    result = "%s/%s" % (_noderoot, path)
  else:
    result = path

  assert os.path.isabs(result), "Path not absolute: " + path

  return os.path.normpath(result)
dataset/ETHPy150Open ganeti/ganeti/lib/vcluster.py/AddNodePrefix/original