Beispiel #1
0
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
Beispiel #2
0
  def test(self):
    self.assertRaises(RuntimeError, vcluster.MakeNodeRoot, "/tmp", "/")

    for i in ["/tmp", "/tmp/", "/tmp///"]:
      self.assertEqual(vcluster.MakeNodeRoot(i, "other.example.com"),
                       "/tmp/other.example.com")