From 8b5ce44b1bf20524f2edf0b5f126caed1997cb53 Mon Sep 17 00:00:00 2001 From: Sushil Kumar Date: Mon, 16 Dec 2013 18:57:30 +0000 Subject: [PATCH] Changes command to create the directory Reasons: - os.makedirs since running under normal user access will not be able to create the directory at root locations like /var/lib. Changes: - Used utils.execute like used at other places for working under root access. - Test changed to test utils.execute instead of os.makedirs Change-Id: Ie2313ae4cc22ac4a9baa4d8e099080f227a980c4 Closes-Bug: #1261492 --- trove/guestagent/volume.py | 2 +- trove/tests/unittests/guestagent/test_volume.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/trove/guestagent/volume.py b/trove/guestagent/volume.py index 02837166a0..3258b77ce3 100644 --- a/trove/guestagent/volume.py +++ b/trove/guestagent/volume.py @@ -132,7 +132,7 @@ class VolumeMountPoint(object): def mount(self): if not os.path.exists(self.mount_point): - os.makedirs(self.mount_point) + utils.execute("sudo", "mkdir", "-p", self.mount_point) LOG.debug("Adding volume. Device path:%s, mount_point:%s, " "volume_type:%s, mount options:%s" % (self.device_path, self.mount_point, self.volume_fstype, diff --git a/trove/tests/unittests/guestagent/test_volume.py b/trove/tests/unittests/guestagent/test_volume.py index 62dd8e1b1c..daa84e9010 100644 --- a/trove/tests/unittests/guestagent/test_volume.py +++ b/trove/tests/unittests/guestagent/test_volume.py @@ -161,12 +161,12 @@ class VolumeMountPointTest(testtools.TestCase): os.path.exists = MagicMock(return_value=False) fake_spawn = _setUp_fake_spawn() - os.makedirs = MagicMock() + utils.execute = Mock() self.volumeMountPoint.mount() self.assertEqual(1, os.path.exists.call_count) - self.assertEqual(1, os.makedirs.call_count) + self.assertEqual(1, utils.execute.call_count) self.assertEqual(1, fake_spawn.expect.call_count) os.path.exists = origin_