Merge "Fix creating volume by snapshot for GPFS driver"
This commit is contained in:
commit
0e38f5c78a
@ -855,6 +855,9 @@ class GPFSDriverTestCase(test.TestCase):
|
|||||||
mock_resize_volume_file.return_value = 5 * units.Gi
|
mock_resize_volume_file.return_value = 5 * units.Gi
|
||||||
volume = self._fake_volume()
|
volume = self._fake_volume()
|
||||||
volume['consistencygroup_id'] = None
|
volume['consistencygroup_id'] = None
|
||||||
|
self.driver.db = mock.Mock()
|
||||||
|
self.driver.db.volume_get = mock.Mock()
|
||||||
|
self.driver.db.volume_get.return_value = volume
|
||||||
snapshot = self._fake_snapshot()
|
snapshot = self._fake_snapshot()
|
||||||
mock_snapshot_path.return_value = "/tmp/fakepath"
|
mock_snapshot_path.return_value = "/tmp/fakepath"
|
||||||
self.assertEqual({'size': 5.0},
|
self.assertEqual({'size': 5.0},
|
||||||
@ -885,6 +888,9 @@ class GPFSDriverTestCase(test.TestCase):
|
|||||||
mock_resize_volume_file.return_value = 5 * units.Gi
|
mock_resize_volume_file.return_value = 5 * units.Gi
|
||||||
volume = self._fake_volume()
|
volume = self._fake_volume()
|
||||||
volume['consistencygroup_id'] = None
|
volume['consistencygroup_id'] = None
|
||||||
|
self.driver.db = mock.Mock()
|
||||||
|
self.driver.db.volume_get = mock.Mock()
|
||||||
|
self.driver.db.volume_get.return_value = volume
|
||||||
snapshot = self._fake_snapshot()
|
snapshot = self._fake_snapshot()
|
||||||
mock_snapshot_path.return_value = "/tmp/fakepath"
|
mock_snapshot_path.return_value = "/tmp/fakepath"
|
||||||
mock_set_volume_attributes.return_value = True
|
mock_set_volume_attributes.return_value = True
|
||||||
|
@ -542,12 +542,11 @@ class GPFSDriver(driver.ConsistencyGroupVD, driver.ExtendVD,
|
|||||||
# check if the snapshot lies in the same CG as the volume to be created
|
# check if the snapshot lies in the same CG as the volume to be created
|
||||||
# if yes, clone the volume from the snapshot, else perform full copy
|
# if yes, clone the volume from the snapshot, else perform full copy
|
||||||
clone = False
|
clone = False
|
||||||
if volume['consistencygroup_id'] is not None:
|
ctxt = context.get_admin_context()
|
||||||
ctxt = context.get_admin_context()
|
snap_parent_vol = self.db.volume_get(ctxt, snapshot['volume_id'])
|
||||||
snap_parent_vol = self.db.volume_get(ctxt, snapshot['volume_id'])
|
if (volume['consistencygroup_id'] ==
|
||||||
if (volume['consistencygroup_id'] ==
|
snap_parent_vol['consistencygroup_id']):
|
||||||
snap_parent_vol['consistencygroup_id']):
|
clone = True
|
||||||
clone = True
|
|
||||||
volume_path = self._get_volume_path(volume)
|
volume_path = self._get_volume_path(volume)
|
||||||
if clone:
|
if clone:
|
||||||
self._create_gpfs_copy(src=snapshot_path, dest=volume_path)
|
self._create_gpfs_copy(src=snapshot_path, dest=volume_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user