From 595149d52180ffaee1c8dead5499a363ea4c2ffb Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 7 Feb 2013 13:12:53 +0100 Subject: [PATCH] vcluster: Make _MakeNodeRoot public The QA code will also have to generate virtual paths and this function comes in handy. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Michele Tartara <mtartara@google.com> --- lib/vcluster.py | 6 +++--- test/py/ganeti.vcluster_unittest.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/vcluster.py b/lib/vcluster.py index ed28cab17..407c352e9 100644 --- a/lib/vcluster.py +++ b/lib/vcluster.py @@ -142,7 +142,7 @@ def GetVirtualHostname(): return _VIRT_HOSTNAME -def _MakeNodeRoot(base, node_name): +def MakeNodeRoot(base, node_name): """Appends a node name to the base directory. """ @@ -162,7 +162,7 @@ def ExchangeNodeRoot(node_name, filename, """ if _basedir: pure = _RemoveNodePrefix(filename, _noderoot=_noderoot) - result = "%s/%s" % (_MakeNodeRoot(_basedir, node_name), pure) + result = "%s/%s" % (MakeNodeRoot(_basedir, node_name), pure) else: result = filename @@ -175,7 +175,7 @@ def EnvironmentForHost(hostname, _basedir=_VIRT_BASEDIR): """ if _basedir: return { - _ROOTDIR_ENVNAME: _MakeNodeRoot(_basedir, hostname), + _ROOTDIR_ENVNAME: MakeNodeRoot(_basedir, hostname), _HOSTNAME_ENVNAME: hostname, } else: diff --git a/test/py/ganeti.vcluster_unittest.py b/test/py/ganeti.vcluster_unittest.py index e47b1f886..0f216da4e 100755 --- a/test/py/ganeti.vcluster_unittest.py +++ b/test/py/ganeti.vcluster_unittest.py @@ -108,10 +108,10 @@ class TestPreparePaths(_EnvVarTest): class TestMakeNodeRoot(unittest.TestCase): def test(self): - self.assertRaises(RuntimeError, vcluster._MakeNodeRoot, "/tmp", "/") + self.assertRaises(RuntimeError, vcluster.MakeNodeRoot, "/tmp", "/") for i in ["/tmp", "/tmp/", "/tmp///"]: - self.assertEqual(vcluster._MakeNodeRoot(i, "other.example.com"), + self.assertEqual(vcluster.MakeNodeRoot(i, "other.example.com"), "/tmp/other.example.com") -- GitLab