From 985e008c17f6cc031c3a52cd2e5fc58d31ff77f6 Mon Sep 17 00:00:00 2001 From: wuyuting Date: Tue, 14 Jun 2016 22:12:16 -0400 Subject: [PATCH] ProphetStor driver create vol from snap with wrong size Create_volume_from_snapshot can specify a volume size larger than the original snapshot. ProphetStor driver not appear to handle this size difference. This patch fixes it. Co-Authored-By: Xinli Guan Change-Id: I5d1dcd8f9bb892a949e562a58e71161a85bce891 Closes-Bug: #1560661 --- .../unit/volume/drivers/test_prophetstor_dpl.py | 17 ++++++++++++----- cinder/volume/drivers/prophetstor/dplcommon.py | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/test_prophetstor_dpl.py b/cinder/tests/unit/volume/drivers/test_prophetstor_dpl.py index 8a9e9a8958d..475b988e004 100644 --- a/cinder/tests/unit/volume/drivers/test_prophetstor_dpl.py +++ b/cinder/tests/unit/volume/drivers/test_prophetstor_dpl.py @@ -104,13 +104,13 @@ DATA_IN_GROUP = {'id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee', DATA_IN_VOLUME = {'id': 'abc123', 'display_name': 'abc123', 'display_description': '', - 'size': 1, + 'size': 10, 'host': "hostname@backend#%s" % POOLUUID} DATA_IN_VOLUME_VG = {'id': 'abc123', 'display_name': 'abc123', 'display_description': '', - 'size': 1, + 'size': 10, 'consistencygroup_id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee', 'status': 'available', @@ -120,7 +120,7 @@ DATA_IN_REMOVE_VOLUME_VG = { 'id': 'fe2dbc515810451dab2f8c8a48d15bee', 'display_name': 'fe2dbc515810451dab2f8c8a48d15bee', 'display_description': '', - 'size': 1, + 'size': 10, 'consistencygroup_id': 'fe2dbc51-5810-451d-ab2f-8c8a48d15bee', 'status': 'available', 'host': "hostname@backend#%s" % POOLUUID} @@ -128,7 +128,7 @@ DATA_IN_REMOVE_VOLUME_VG = { DATA_IN_VOLUME1 = {'id': 'abc456', 'display_name': 'abc456', 'display_description': '', - 'size': 1, + 'size': 10, 'host': "hostname@backend#%s" % POOLUUID} DATA_IN_CG_SNAPSHOT = { @@ -141,7 +141,8 @@ DATA_IN_CG_SNAPSHOT = { DATA_IN_SNAPSHOT = {'id': 'snapshot1', 'volume_id': 'abc123', 'display_name': 'snapshot1', - 'display_description': ''} + 'display_description': '', + 'size': 5} DATA_OUT_SNAPSHOT_CG = { 'id': 'snapshot1', @@ -577,6 +578,7 @@ class TestProphetStorDPLDriver(test.TestCase): def test_create_volume_from_snapshot(self): self.DPL_MOCK.create_vdev_from_snapshot.return_value = DATA_OUTPUT + self.DPL_MOCK.extend_vdev.return_value = DATA_OUTPUT self.dpldriver.create_volume_from_snapshot(DATA_IN_VOLUME, DATA_IN_SNAPSHOT) self.DPL_MOCK.create_vdev_from_snapshot.assert_called_once_with( @@ -586,6 +588,11 @@ class TestProphetStorDPLDriver(test.TestCase): self._conver_uuid2hex(DATA_IN_SNAPSHOT['id']), self.configuration.dpl_pool, True) + self.DPL_MOCK.extend_vdev.assert_called_once_with( + self._conver_uuid2hex(DATA_IN_VOLUME['id']), + DATA_IN_VOLUME['display_name'], + DATA_IN_VOLUME['display_description'], + DATA_IN_VOLUME['size'] * units.Gi) def test_create_cloned_volume(self): self.DPL_MOCK.clone_vdev.return_value = DATA_OUTPUT diff --git a/cinder/volume/drivers/prophetstor/dplcommon.py b/cinder/volume/drivers/prophetstor/dplcommon.py index 3fc37161744..6bd14d202ef 100644 --- a/cinder/volume/drivers/prophetstor/dplcommon.py +++ b/cinder/volume/drivers/prophetstor/dplcommon.py @@ -1144,6 +1144,9 @@ class DPLCOMMONDriver(driver.CloneableImageVD, LOG.info(_LI('Flexvisor succeeded to create volume %(id)s ' 'from snapshot.'), {'id': volume['id']}) + if volume['size'] > snapshot['size']: + self.extend_volume(volume, volume['size']) + if volume.get('consistencygroup_id', None): try: self._join_volume_group(volume, volume['consistencygroup_id'])