diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py index 06bc321769..128ef16984 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py @@ -1627,6 +1627,38 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): errors[0].get_child_content('error-code'), errors[0].get_child_content('error-message')) + @na_utils.trace + def set_volume_filesys_size_fixed(self, + volume_name, filesys_size_fixed=False): + """Set volume file system size fixed to true/false.""" + api_args = { + 'query': { + 'volume-attributes': { + 'volume-id-attributes': { + 'name': volume_name, + }, + }, + }, + 'attributes': { + 'volume-attributes': { + 'volume-space-attributes': { + 'is-filesys-size-fixed': six.text_type( + filesys_size_fixed).lower(), + }, + }, + }, + } + result = self.send_request('volume-modify-iter', api_args) + failures = result.get_child_content('num-failed') + if failures and int(failures) > 0: + failure_list = result.get_child_by_name( + 'failure-list') or netapp_api.NaElement('none') + errors = failure_list.get_children() + if errors: + raise netapp_api.NaApiError( + errors[0].get_child_content('error-code'), + errors[0].get_child_content('error-message')) + @na_utils.trace def set_volume_security_style(self, volume_name, security_style='unix'): """Set volume security style""" diff --git a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py index 5a38a123f9..3b4531e917 100644 --- a/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py +++ b/manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py @@ -1325,6 +1325,8 @@ class NetAppCmodeFileStorageLibrary(object): """Extends size of existing share.""" vserver, vserver_client = self._get_vserver(share_server=share_server) share_name = self._get_backend_share_name(share['id']) + vserver_client.set_volume_filesys_size_fixed(share_name, + filesys_size_fixed=False) LOG.debug('Extending share %(name)s to %(size)s GB.', {'name': share_name, 'size': new_size}) vserver_client.set_volume_size(share_name, new_size) @@ -1336,6 +1338,8 @@ class NetAppCmodeFileStorageLibrary(object): """Shrinks size of existing share.""" vserver, vserver_client = self._get_vserver(share_server=share_server) share_name = self._get_backend_share_name(share['id']) + vserver_client.set_volume_filesys_size_fixed(share_name, + filesys_size_fixed=False) LOG.debug('Shrinking share %(name)s to %(size)s GB.', {'name': share_name, 'size': new_size}) vserver_client.set_volume_size(share_name, new_size) @@ -1744,6 +1748,11 @@ class NetAppCmodeFileStorageLibrary(object): new_active_replica['export_locations'] = self._create_export( new_active_replica, share_server, vserver, vserver_client) new_active_replica['replica_state'] = constants.REPLICA_STATE_ACTIVE + + # 4. Set File system size fixed to false + vserver_client.set_volume_filesys_size_fixed(share_name, + filesys_size_fixed=False) + return new_active_replica def _safe_change_replica_source(self, dm_session, replica, diff --git a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py index 447d2ace4e..1693b263b5 100644 --- a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py +++ b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py @@ -3135,6 +3135,37 @@ class NetAppClientCmodeTestCase(test.TestCase): self.client.send_request.assert_has_calls([ mock.call('volume-modify-iter', volume_modify_iter_args)]) + @ddt.data(True, False) + def test_set_volume_filesys_size_fixed(self, filesys_size_fixed): + api_response = netapp_api.NaElement( + fake.VOLUME_MODIFY_ITER_RESPONSE) + self.mock_object(self.client, + 'send_request', + mock.Mock(return_value=api_response)) + + self.client.set_volume_filesys_size_fixed(fake.SHARE_NAME, + filesys_size_fixed) + + api_args = { + 'query': { + 'volume-attributes': { + 'volume-id-attributes': { + 'name': fake.SHARE_NAME + } + } + }, + 'attributes': { + 'volume-attributes': { + 'volume-space-attributes': { + 'is-filesys-size-fixed': six.text_type( + filesys_size_fixed).lower(), + }, + }, + }, + } + self.client.send_request.assert_called_once_with( + 'volume-modify-iter', api_args) + def test_set_volume_size_api_error(self): api_response = netapp_api.NaElement( diff --git a/releasenotes/notes/bug-1700871-ontap-allow-extend-of-replicated-share-2c9709180d954308.yaml b/releasenotes/notes/bug-1700871-ontap-allow-extend-of-replicated-share-2c9709180d954308.yaml new file mode 100644 index 0000000000..f29fbe380d --- /dev/null +++ b/releasenotes/notes/bug-1700871-ontap-allow-extend-of-replicated-share-2c9709180d954308.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - The NetApp ONTAP driver is now fixed to allow extension and shrinking + of share replicas after they get promoted.