Merge "HNAS: Cloned volume with different volume type"

This commit is contained in:
Jenkins 2017-02-05 20:06:05 +00:00 committed by Gerrit Code Review
commit 4bf39cd36d
3 changed files with 26 additions and 0 deletions

View File

@ -302,6 +302,17 @@ class HNASNFSDriverTest(test.TestCase):
self.assertEqual('hnas', out['provider_location'])
def test_create_cloned_volume_invalid_volume_type(self):
self.volume.volume_type_id = fake.VOLUME_TYPE_ID
self.clone.volume_type_id = fake.VOLUME_TYPE2_ID
self.mock_object(self.driver, 'extend_volume')
self.mock_object(backend.HNASSSHBackend, 'file_clone')
self.assertRaises(exception.InvalidVolumeType,
self.driver.create_cloned_volume, self.volume,
self.clone)
def test_get_volume_stats(self):
self.driver.pools = [{'pool_name': 'default',
'service_label': 'default',

View File

@ -284,6 +284,16 @@ class HNASNFSDriver(nfs.NfsDriver):
:param src_vref: reference to the source volume
:returns: the provider_location of the cloned volume
"""
# HNAS always creates cloned volumes in the same pool as the source
# volumes. So, it is not allowed to use different volume types for
# clone operations.
if volume.volume_type_id != src_vref.volume_type_id:
msg = _("Source and cloned volumes should have the same "
"volume type.")
LOG.error(msg)
raise exception.InvalidVolumeType(msg)
vol_size = volume.size
src_vol_size = src_vref.size

View File

@ -0,0 +1,5 @@
---
fixes:
- Fixed HNAS bug that placed a cloned volume in the same pool as its
source, even if the clone had a different pool specification. Driver will
not allow to make clones using a different volume type anymore.