Merge "Revert "Use os.mkdir instead of mkdir""

This commit is contained in:
Zuul 2018-07-16 17:48:27 +00:00 committed by Gerrit Code Review
commit 47228e5ba3
3 changed files with 11 additions and 12 deletions

View File

@ -202,7 +202,6 @@ 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).
@ -212,13 +211,14 @@ class QuobyteDriverTestCase(test.TestCase):
self._driver._mount_quobyte(self.TEST_QUOBYTE_VOLUME,
self.TEST_MNT_POINT)
mock_mkdir.assert_called_once_with(self.TEST_MNT_POINT)
mkdir_call = mock.call('mkdir', '-p', 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(
[mount_call], any_order=False)
[mkdir_call, 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,7 +250,6 @@ 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).
@ -262,11 +261,11 @@ class QuobyteDriverTestCase(test.TestCase):
self.TEST_MNT_POINT,
ensure=True)
mock_mkdir.assert_called_once_with(self.TEST_MNT_POINT)
mkdir_call = mock.call('mkdir', '-p', 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([mount_call],
mock_execute.assert_has_calls([mkdir_call, mount_call],
any_order=False)
mock_validate.assert_called_once_with(self.TEST_MNT_POINT)
@ -277,7 +276,6 @@ 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()
@ -286,17 +284,17 @@ class QuobyteDriverTestCase(test.TestCase):
putils.ProcessExecutionError( # mount
stderr='is busy or already mounted')]
self.assertRaises(exception.VolumeDriverException,
self.assertRaises(putils.ProcessExecutionError,
self._driver._mount_quobyte,
self.TEST_QUOBYTE_VOLUME,
self.TEST_MNT_POINT,
ensure=False)
mock_mkdir.assert_called_once_with(self.TEST_MNT_POINT)
mkdir_call = mock.call('mkdir', '-p', 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([mount_call],
mock_execute.assert_has_calls([mkdir_call, mount_call],
any_order=False)
@mock.patch.object(image_utils, "qemu_img_info")

View File

@ -693,7 +693,8 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
LOG.info('Already mounted: %s', mount_path)
return
os.mkdir(mount_path)
self._execute('mkdir', '-p', mount_path,
check_exit_code=False)
self._remotefsclient._mount_nfs(nfs_share, mount_path,
mnt_flags)
return

View File

@ -566,7 +566,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed):
if not mounted:
if not os.path.isdir(mount_path):
os.mkdir(mount_path)
self._execute('mkdir', '-p', mount_path)
command = ['mount.quobyte', '--disable-xattrs',
quobyte_volume, mount_path]