Use os.mkdir instead of mkdir
There was a few places where we were shelling out to mkdir instead of just calling the built in python implementation. Change-Id: I6f232f81e36dc750e064af6047c137a3bccbdc0a Signed-off-by: Chuck Short <chucks@redhat.com>
This commit is contained in:
parent
82daaab5cc
commit
fc3f5d8e8d
cinder
@ -202,6 +202,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
with mock.patch.object(self._driver, '_execute') as mock_execute, \
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'.read_proc_mount') as mock_open, \
|
||||
mock.patch('os.mkdir') as mock_mkdir, \
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'._validate_volume') as mock_validate:
|
||||
# Content of /proc/mount (not mounted yet).
|
||||
@ -211,14 +212,13 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
self._driver._mount_quobyte(self.TEST_QUOBYTE_VOLUME,
|
||||
self.TEST_MNT_POINT)
|
||||
|
||||
mkdir_call = mock.call('mkdir', '-p', self.TEST_MNT_POINT)
|
||||
|
||||
mock_mkdir.assert_called_once_with(self.TEST_MNT_POINT)
|
||||
mount_call = mock.call(
|
||||
'mount.quobyte', '--disable-xattrs', self.TEST_QUOBYTE_VOLUME,
|
||||
self.TEST_MNT_POINT, run_as_root=False)
|
||||
|
||||
mock_execute.assert_has_calls(
|
||||
[mkdir_call, mount_call], any_order=False)
|
||||
[mount_call], any_order=False)
|
||||
mock_validate.called_once_with(self.TEST_MNT_POINT)
|
||||
|
||||
def test_mount_quobyte_already_mounted_detected_seen_in_proc_mount(self):
|
||||
@ -250,6 +250,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
with mock.patch.object(self._driver, '_execute') as mock_execute, \
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'.read_proc_mount') as mock_open, \
|
||||
mock.patch('os.mkdir') as mock_mkdir, \
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'._validate_volume') as mock_validate:
|
||||
# Content of /proc/mount (empty).
|
||||
@ -261,11 +262,11 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
self.TEST_MNT_POINT,
|
||||
ensure=True)
|
||||
|
||||
mkdir_call = mock.call('mkdir', '-p', self.TEST_MNT_POINT)
|
||||
mock_mkdir.assert_called_once_with(self.TEST_MNT_POINT)
|
||||
mount_call = mock.call(
|
||||
'mount.quobyte', '--disable-xattrs', self.TEST_QUOBYTE_VOLUME,
|
||||
self.TEST_MNT_POINT, run_as_root=False)
|
||||
mock_execute.assert_has_calls([mkdir_call, mount_call],
|
||||
mock_execute.assert_has_calls([mount_call],
|
||||
any_order=False)
|
||||
mock_validate.assert_called_once_with(self.TEST_MNT_POINT)
|
||||
|
||||
@ -276,6 +277,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
but with ensure=False.
|
||||
"""
|
||||
with mock.patch.object(self._driver, '_execute') as mock_execute, \
|
||||
mock.patch('os.mkdir') as mock_mkdir, \
|
||||
mock.patch('cinder.volume.drivers.quobyte.QuobyteDriver'
|
||||
'.read_proc_mount') as mock_open:
|
||||
mock_open.return_value = six.StringIO()
|
||||
@ -284,17 +286,17 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
putils.ProcessExecutionError( # mount
|
||||
stderr='is busy or already mounted')]
|
||||
|
||||
self.assertRaises(putils.ProcessExecutionError,
|
||||
self.assertRaises(exception.VolumeDriverException,
|
||||
self._driver._mount_quobyte,
|
||||
self.TEST_QUOBYTE_VOLUME,
|
||||
self.TEST_MNT_POINT,
|
||||
ensure=False)
|
||||
|
||||
mkdir_call = mock.call('mkdir', '-p', self.TEST_MNT_POINT)
|
||||
mock_mkdir.assert_called_once_with(self.TEST_MNT_POINT)
|
||||
mount_call = mock.call(
|
||||
'mount.quobyte', '--disable-xattrs', self.TEST_QUOBYTE_VOLUME,
|
||||
self.TEST_MNT_POINT, run_as_root=False)
|
||||
mock_execute.assert_has_calls([mkdir_call, mount_call],
|
||||
mock_execute.assert_has_calls([mount_call],
|
||||
any_order=False)
|
||||
|
||||
@mock.patch.object(image_utils, "qemu_img_info")
|
||||
|
@ -693,8 +693,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
||||
LOG.info('Already mounted: %s', mount_path)
|
||||
return
|
||||
|
||||
self._execute('mkdir', '-p', mount_path,
|
||||
check_exit_code=False)
|
||||
os.mkdir(mount_path)
|
||||
self._remotefsclient._mount_nfs(nfs_share, mount_path,
|
||||
mnt_flags)
|
||||
return
|
||||
|
@ -566,7 +566,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed):
|
||||
|
||||
if not mounted:
|
||||
if not os.path.isdir(mount_path):
|
||||
self._execute('mkdir', '-p', mount_path)
|
||||
os.mkdir(mount_path)
|
||||
|
||||
command = ['mount.quobyte', '--disable-xattrs',
|
||||
quobyte_volume, mount_path]
|
||||
|
Loading…
x
Reference in New Issue
Block a user