NetApp ONTAP: Fix export path used as volume name
On ONTAP NFS driver, the export path was being used as the volume
name. If the export path is different than the volume name, the
API call to delete files would fail and the driver would invoke
a fallback method that deletes the files manually. This patch fixes
that by finding the correct volume name.
(cherry-picked from commit 64df069399
)
Change-Id: Ice78889573a36ff5e8873a0d316ddcf180d0263f
Closes-bug: #1690954
This commit is contained in:
parent
20a803a3f3
commit
fd2c17edc0
|
@ -570,12 +570,21 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase):
|
|||
|
||||
def test_delete_file(self):
|
||||
mock_get_vs_ip = self.mock_object(self.driver, '_get_export_ip_path')
|
||||
mock_get_vs_ip.return_value = (fake.VSERVER_NAME, '/%s' % fake.FLEXVOL)
|
||||
mock_get_vs_ip.return_value = (fake.SHARE_IP, fake.EXPORT_PATH)
|
||||
mock_get_vserver = self.mock_object(self.driver, '_get_vserver_for_ip')
|
||||
mock_get_vserver.return_value = fake.VSERVER_NAME
|
||||
mock_zapi_get_vol = self.driver.zapi_client.get_vol_by_junc_vserver
|
||||
mock_zapi_get_vol.return_value = fake.FLEXVOL
|
||||
mock_zapi_delete = self.driver.zapi_client.delete_file
|
||||
|
||||
self.driver._delete_file(
|
||||
fake.test_snapshot['volume_id'], fake.test_snapshot['name'])
|
||||
|
||||
mock_get_vs_ip.assert_called_once_with(
|
||||
volume_id=fake.test_snapshot['volume_id'])
|
||||
mock_get_vserver.assert_called_once_with(fake.SHARE_IP)
|
||||
mock_zapi_get_vol.assert_called_once_with(
|
||||
fake.VSERVER_NAME, fake.EXPORT_PATH)
|
||||
mock_zapi_delete.assert_called_once_with(
|
||||
'/vol/%s/%s' % (fake.FLEXVOL, fake.test_snapshot['name']))
|
||||
|
||||
|
|
|
@ -437,8 +437,11 @@ class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver,
|
|||
'%s was unsuccessful.', volume['id'])
|
||||
|
||||
def _delete_file(self, file_id, file_name):
|
||||
(_vserver, flexvol) = self._get_export_ip_path(volume_id=file_id)
|
||||
path_on_backend = '/vol' + flexvol + '/' + file_name
|
||||
(host_ip, junction_path) = self._get_export_ip_path(volume_id=file_id)
|
||||
vserver = self._get_vserver_for_ip(host_ip)
|
||||
flexvol = self.zapi_client.get_vol_by_junc_vserver(
|
||||
vserver, junction_path)
|
||||
path_on_backend = '/vol/' + flexvol + '/' + file_name
|
||||
LOG.debug('Attempting to delete file %(path)s for ID %(file_id)s on '
|
||||
'backend.', {'path': path_on_backend, 'file_id': file_id})
|
||||
self.zapi_client.delete_file(path_on_backend)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
NetApp ONTAP NFS (bug 1690954): Fix wrong usage of export path
|
||||
as volume name when deleting volumes and snapshots.
|
Loading…
Reference in New Issue