NetApp cDot: Fix manage volumes
When running NetApp cDot driver using nas_secure_files_operation=false, managing a volume will always fail if the files permissions are not set to 0777. This patch changes the python call from shutil.move to _execute() which is run using elevated permissions. Change-Id: I41484ced6269d0d4b7553e84c734ef22ab46fcd9 Closes-bug: #1691771
This commit is contained in:
parent
5e2062ceaf
commit
4b874c5ddc
@ -26,7 +26,6 @@ import mock
|
|||||||
from os_brick.remotefs import remotefs as remotefs_brick
|
from os_brick.remotefs import remotefs as remotefs_brick
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
import shutil
|
|
||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
@ -802,7 +801,6 @@ class NetAppNfsDriverTestCase(test.TestCase):
|
|||||||
vol_path = "%s/%s" % (self.fake_nfs_export_1, test_file)
|
vol_path = "%s/%s" % (self.fake_nfs_export_1, test_file)
|
||||||
vol_ref = {'source-name': vol_path}
|
vol_ref = {'source-name': vol_path}
|
||||||
self.driver._check_volume_type = mock.Mock()
|
self.driver._check_volume_type = mock.Mock()
|
||||||
shutil.move = mock.Mock()
|
|
||||||
self.mock_object(self.driver, '_execute')
|
self.mock_object(self.driver, '_execute')
|
||||||
self.driver._ensure_shares_mounted = mock.Mock()
|
self.driver._ensure_shares_mounted = mock.Mock()
|
||||||
self.driver._get_mount_point_for_share = mock.Mock(
|
self.driver._get_mount_point_for_share = mock.Mock(
|
||||||
@ -835,14 +833,15 @@ class NetAppNfsDriverTestCase(test.TestCase):
|
|||||||
volume = fake.FAKE_MANAGE_VOLUME
|
volume = fake.FAKE_MANAGE_VOLUME
|
||||||
vol_path = "%s/%s" % (self.fake_nfs_export_1, test_file)
|
vol_path = "%s/%s" % (self.fake_nfs_export_1, test_file)
|
||||||
vol_ref = {'source-name': vol_path}
|
vol_ref = {'source-name': vol_path}
|
||||||
mock_check_volume_type = self.driver._check_volume_type = mock.Mock()
|
self.driver._check_volume_type = mock.Mock()
|
||||||
self.driver._ensure_shares_mounted = mock.Mock()
|
self.driver._ensure_shares_mounted = mock.Mock()
|
||||||
self.driver._get_mount_point_for_share = mock.Mock(
|
self.driver._get_mount_point_for_share = mock.Mock(
|
||||||
return_value=self.fake_mount_point)
|
return_value=self.fake_mount_point)
|
||||||
self.driver._get_share_mount_and_vol_from_vol_ref = mock.Mock(
|
self.driver._get_share_mount_and_vol_from_vol_ref = mock.Mock(
|
||||||
return_value=(self.fake_nfs_export_1, self.fake_mount_point,
|
return_value=(self.fake_nfs_export_1, self.fake_mount_point,
|
||||||
test_file))
|
test_file))
|
||||||
self.driver._execute = mock.Mock(side_effect=OSError)
|
self.driver._execute = mock.Mock(
|
||||||
|
side_effect=processutils.ProcessExecutionError)
|
||||||
mock_get_specs = self.mock_object(na_utils, 'get_volume_extra_specs')
|
mock_get_specs = self.mock_object(na_utils, 'get_volume_extra_specs')
|
||||||
mock_get_specs.return_value = {}
|
mock_get_specs.return_value = {}
|
||||||
self.mock_object(self.driver, '_do_qos_for_volume')
|
self.mock_object(self.driver, '_do_qos_for_volume')
|
||||||
@ -850,9 +849,6 @@ class NetAppNfsDriverTestCase(test.TestCase):
|
|||||||
self.assertRaises(exception.VolumeBackendAPIException,
|
self.assertRaises(exception.VolumeBackendAPIException,
|
||||||
self.driver.manage_existing, volume, vol_ref)
|
self.driver.manage_existing, volume, vol_ref)
|
||||||
|
|
||||||
mock_check_volume_type.assert_called_once_with(
|
|
||||||
volume, self.fake_nfs_export_1, test_file, {})
|
|
||||||
|
|
||||||
def test_unmanage(self):
|
def test_unmanage(self):
|
||||||
mock_log = self.mock_object(nfs_base, 'LOG')
|
mock_log = self.mock_object(nfs_base, 'LOG')
|
||||||
volume = {'id': '123', 'provider_location': '/share'}
|
volume = {'id': '123', 'provider_location': '/share'}
|
||||||
|
@ -25,7 +25,6 @@ import copy
|
|||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -1001,11 +1000,13 @@ class NetAppNfsDriver(driver.ManageableVD,
|
|||||||
src_vol = os.path.join(nfs_mount, vol_path)
|
src_vol = os.path.join(nfs_mount, vol_path)
|
||||||
dst_vol = os.path.join(nfs_mount, volume['name'])
|
dst_vol = os.path.join(nfs_mount, volume['name'])
|
||||||
try:
|
try:
|
||||||
shutil.move(src_vol, dst_vol)
|
self._execute("mv", src_vol, dst_vol,
|
||||||
|
run_as_root=self._execute_as_root,
|
||||||
|
check_exit_code=True)
|
||||||
LOG.debug("Setting newly managed Cinder volume name to %s",
|
LOG.debug("Setting newly managed Cinder volume name to %s",
|
||||||
volume['name'])
|
volume['name'])
|
||||||
self._set_rw_permissions_for_all(dst_vol)
|
self._set_rw_permissions_for_all(dst_vol)
|
||||||
except (OSError, IOError) as err:
|
except processutils.ProcessExecutionError as err:
|
||||||
exception_msg = (_("Failed to manage existing volume %(name)s,"
|
exception_msg = (_("Failed to manage existing volume %(name)s,"
|
||||||
" because rename operation failed:"
|
" because rename operation failed:"
|
||||||
" Error msg: %(msg)s."),
|
" Error msg: %(msg)s."),
|
||||||
|
@ -149,6 +149,7 @@ blockdev: CommandFilter, blockdev, root
|
|||||||
|
|
||||||
# cinder/volume/drivers/ibm/gpfs.py
|
# cinder/volume/drivers/ibm/gpfs.py
|
||||||
# cinder/volume/drivers/tintri.py
|
# cinder/volume/drivers/tintri.py
|
||||||
|
# cinder/volume/drivers/netapp/dataontap/nfs_base.py
|
||||||
mv: CommandFilter, mv, root
|
mv: CommandFilter, mv, root
|
||||||
|
|
||||||
# cinder/volume/drivers/ibm/gpfs.py
|
# cinder/volume/drivers/ibm/gpfs.py
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- The NetApp cDOT driver operating with NFS protocol has been fixed to
|
||||||
|
manage volumes correctly when ``nas_secure_file_operations`` option has
|
||||||
|
been set to False.
|
Loading…
Reference in New Issue
Block a user