[NetApp] Allow extension/shrinking of NetApp replicated share

The NetApp ONTAP driver is now fixed to allow extension
and shrinking of share replicas after they get promoted.

Change-Id: Iea92feaf5894c10674d2ec4c1a4d7b0191e6d5b4
Closes-Bug: #1700871
(cherry picked from commit 75f108b0ae)
(cherry picked from commit e38c8b508f)
This commit is contained in:
Naresh Kumar Gunjalli 2019-02-14 13:21:30 +00:00 committed by Douglas Viroel
parent 0f96e37e88
commit 5255ca20fb
4 changed files with 76 additions and 0 deletions

View File

@ -1723,6 +1723,38 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
errors[0].get_child_content('error-code'), errors[0].get_child_content('error-code'),
errors[0].get_child_content('error-message')) 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 @na_utils.trace
def set_volume_security_style(self, volume_name, security_style='unix'): def set_volume_security_style(self, volume_name, security_style='unix'):
"""Set volume security style""" """Set volume security style"""

View File

@ -1355,6 +1355,8 @@ class NetAppCmodeFileStorageLibrary(object):
"""Extends size of existing share.""" """Extends size of existing share."""
vserver, vserver_client = self._get_vserver(share_server=share_server) vserver, vserver_client = self._get_vserver(share_server=share_server)
share_name = self._get_backend_share_name(share['id']) 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.', LOG.debug('Extending share %(name)s to %(size)s GB.',
{'name': share_name, 'size': new_size}) {'name': share_name, 'size': new_size})
vserver_client.set_volume_size(share_name, new_size) vserver_client.set_volume_size(share_name, new_size)
@ -1366,6 +1368,8 @@ class NetAppCmodeFileStorageLibrary(object):
"""Shrinks size of existing share.""" """Shrinks size of existing share."""
vserver, vserver_client = self._get_vserver(share_server=share_server) vserver, vserver_client = self._get_vserver(share_server=share_server)
share_name = self._get_backend_share_name(share['id']) 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.', LOG.debug('Shrinking share %(name)s to %(size)s GB.',
{'name': share_name, 'size': new_size}) {'name': share_name, 'size': new_size})
vserver_client.set_volume_size(share_name, new_size) vserver_client.set_volume_size(share_name, new_size)
@ -1774,6 +1778,11 @@ class NetAppCmodeFileStorageLibrary(object):
new_active_replica['export_locations'] = self._create_export( new_active_replica['export_locations'] = self._create_export(
new_active_replica, share_server, vserver, vserver_client) new_active_replica, share_server, vserver, vserver_client)
new_active_replica['replica_state'] = constants.REPLICA_STATE_ACTIVE 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 return new_active_replica
def _safe_change_replica_source(self, dm_session, replica, def _safe_change_replica_source(self, dm_session, replica,

View File

@ -3312,6 +3312,37 @@ class NetAppClientCmodeTestCase(test.TestCase):
fake.SHARE_NAME, fake.SHARE_NAME,
10) 10)
@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): def test_set_volume_size_api_error(self):
api_response = netapp_api.NaElement( api_response = netapp_api.NaElement(

View File

@ -0,0 +1,4 @@
---
fixes:
- The NetApp ONTAP driver is now fixed to allow extension and shrinking
of share replicas after they get promoted.