Merge "NetApp ONTAP: Fix export path used as volume name"

This commit is contained in:
Zuul 2018-04-18 15:41:30 +00:00 committed by Gerrit Code Review
commit 2131d441e4
3 changed files with 20 additions and 3 deletions

View File

@ -597,12 +597,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']))

View File

@ -434,8 +434,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)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
NetApp ONTAP NFS (bug 1690954): Fix wrong usage of export path
as volume name when deleting volumes and snapshots.