diff --git a/cinder/tests/unit/volume/drivers/test_quobyte.py b/cinder/tests/unit/volume/drivers/test_quobyte.py index fe4d590c734..2f5fe2d015d 100644 --- a/cinder/tests/unit/volume/drivers/test_quobyte.py +++ b/cinder/tests/unit/volume/drivers/test_quobyte.py @@ -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") diff --git a/cinder/volume/drivers/nexenta/nfs.py b/cinder/volume/drivers/nexenta/nfs.py index 15c92c1790b..598a3dafee0 100644 --- a/cinder/volume/drivers/nexenta/nfs.py +++ b/cinder/volume/drivers/nexenta/nfs.py @@ -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 diff --git a/cinder/volume/drivers/quobyte.py b/cinder/volume/drivers/quobyte.py index 2b922df5a91..9c71ddcd293 100644 --- a/cinder/volume/drivers/quobyte.py +++ b/cinder/volume/drivers/quobyte.py @@ -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]