Merge "NetApp ONTAP: Fix share size when creating from snapshot" into stable/ocata

This commit is contained in:
Zuul 2018-04-20 13:46:14 +00:00 committed by Gerrit Code Review
commit e9ded083dd
3 changed files with 39 additions and 6 deletions

View File

@ -644,6 +644,16 @@ class NetAppCmodeFileStorageLibrary(object):
parent_snapshot_name,
**provisioning_options)
volume = vserver_client.get_volume(share_name)
volume_size = int(math.ceil(float(volume['size']) / units.Gi))
if share['size'] > volume_size:
LOG.debug("Size of the share requested is larger than the "
"snapshot, extending from %(old)sG to %(new)sG" % {
'old': volume_size,
'new': share['size'],
})
vserver_client.set_volume_size(share_name, share['size'])
@na_utils.trace
def _share_exists(self, share_name, vserver_client):
return vserver_client.volume_exists(share_name)

View File

@ -920,31 +920,49 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
fake.AGGREGATES[1],
fake.EXTRA_SPEC)
@ddt.data(None, 'fake_location')
def test_allocate_container_from_snapshot(self, provider_location):
@ddt.data({'provider_location': None, 'size': 50},
{'provider_location': 'fake_location', 'size': 30},
{'provider_location': 'fake_location', 'size': 20})
@ddt.unpack
def test_allocate_container_from_snapshot(self, provider_location, size):
self.mock_object(
self.library, '_get_provisioning_options_for_share',
mock.Mock(return_value=copy.deepcopy(fake.PROVISIONING_OPTIONS)))
vserver_client = mock.Mock()
original_volume = copy.deepcopy(fake.FLEXVOL_TO_MANAGE)
original_volume['size'] = 32212254720 # 30 GB
original_volume_size_gb = int(math.ceil(
float(original_volume['size']) / units.Gi))
vserver_client.get_volume.return_value = original_volume
fake_share = copy.deepcopy(fake.SHARE)
fake_share['size'] = size
fake_snapshot = copy.deepcopy(fake.SNAPSHOT)
fake_snapshot['provider_location'] = provider_location
self.library._allocate_container_from_snapshot(fake.SHARE,
self.library._allocate_container_from_snapshot(fake_share,
fake_snapshot,
vserver_client)
share_name = self.library._get_backend_share_name(fake.SHARE['id'])
share_name = self.library._get_backend_share_name(fake_share['id'])
parent_share_name = self.library._get_backend_share_name(
fake.SNAPSHOT['share_id'])
fake_snapshot['share_id'])
parent_snapshot_name = self.library._get_backend_snapshot_name(
fake.SNAPSHOT['id']) if not provider_location else 'fake_location'
fake_snapshot['id']) if not provider_location else 'fake_location'
vserver_client.create_volume_clone.assert_called_once_with(
share_name, parent_share_name, parent_snapshot_name,
thin_provisioned=True, snapshot_policy='default',
language='en-US', dedup_enabled=True, split=True,
compression_enabled=False, max_files=5000)
vserver_client.get_volume.assert_called_once_with(share_name)
if size > original_volume_size_gb:
vserver_client.set_volume_size.assert_called_once_with(
share_name, size)
else:
vserver_client.set_volume_size.assert_not_called()
def test_share_exists(self):

View File

@ -0,0 +1,5 @@
---
fixes:
- The NetApp ONTAP driver has been fixed to honor the share size as
requested when creating shares from an existing snapshot.