Move ensure_tree to utils

Its useful to people other that virt drivers.

Change-Id: I721094a1785d7a275f4bfa8994b7b114a6ec07f6
This commit is contained in:
Michael Still
2012-08-26 21:26:50 +10:00
parent 5c24d8b7d4
commit ef23d7ee75
3 changed files with 3 additions and 13 deletions

View File

@@ -63,10 +63,6 @@ def remove_logical_volumes(*paths):
pass
def ensure_tree(path):
pass
def write_to_file(path, contents, umask=None):
pass

View File

@@ -55,8 +55,8 @@ class _ImageTestCase(test.TestCase):
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
fn = self.mox.CreateMockAnything()
fn(target=self.TEMPLATE_PATH)
self.mox.StubOutWithMock(imagebackend.libvirt_utils, 'ensure_tree')
imagebackend.libvirt_utils.ensure_tree(self.TEMPLATE_DIR)
self.mox.StubOutWithMock(imagebackend.utils, 'ensure_tree')
imagebackend.utils.ensure_tree(self.TEMPLATE_DIR)
self.mox.ReplayAll()
image = self.image_class(self.INSTANCE, self.NAME)
@@ -82,7 +82,7 @@ class _ImageTestCase(test.TestCase):
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
fn = self.mox.CreateMockAnything()
fn(target=self.TEMPLATE_PATH)
self.mox.StubOutWithMock(imagebackend.libvirt_utils, 'ensure_tree')
self.mox.StubOutWithMock(imagebackend.utils, 'ensure_tree')
self.mox.ReplayAll()
image = self.image_class(self.INSTANCE, self.NAME)

View File

@@ -3394,12 +3394,6 @@ disk size: 4.4M''', ''))
libvirt_utils.mkfs('ext4', '/my/block/dev')
libvirt_utils.mkfs('swap', '/my/swap/block/dev')
def test_ensure_tree(self):
with utils.tempdir() as tmpdir:
testdir = '%s/foo/bar/baz' % (tmpdir,)
libvirt_utils.ensure_tree(testdir)
self.assertTrue(os.path.isdir(testdir))
def test_write_to_file(self):
dst_fd, dst_path = tempfile.mkstemp()
try: