Merge "DRBD: extend volume if larger than snapshot"
This commit is contained in:
commit
bbe407e8ba
@ -480,17 +480,62 @@ class DrbdManageIscsiTestCase(test.TestCase):
|
||||
self.assertEqual("list_snapshots", dmd.odm.calls[4][0])
|
||||
self.assertEqual("restore_snapshot", dmd.odm.calls[5][0])
|
||||
self.assertEqual("run_external_plugin", dmd.odm.calls[6][0])
|
||||
self.assertEqual("list_snapshots", dmd.odm.calls[7][0])
|
||||
self.assertEqual("remove_snapshot", dmd.odm.calls[8][0])
|
||||
# resize image checks
|
||||
self.assertEqual("list_volumes", dmd.odm.calls[7][0])
|
||||
self.assertEqual(newvol['id'], dmd.odm.calls[7][3]["aux:cinder-id"])
|
||||
self.assertEqual("resize_volume", dmd.odm.calls[8][0])
|
||||
self.assertEqual("res", dmd.odm.calls[8][1])
|
||||
self.assertEqual(2, dmd.odm.calls[8][2])
|
||||
self.assertEqual(-1, dmd.odm.calls[8][3])
|
||||
self.assertEqual(5242880, dmd.odm.calls[8][4])
|
||||
|
||||
self.assertEqual("run_external_plugin", dmd.odm.calls[9][0])
|
||||
self.assertEqual("list_snapshots", dmd.odm.calls[10][0])
|
||||
self.assertEqual("remove_snapshot", dmd.odm.calls[11][0])
|
||||
|
||||
def test_create_volume_from_snapshot(self):
|
||||
snap = {'project_id': 'testprjid',
|
||||
'name': 'testvol',
|
||||
'volume_size': 1,
|
||||
'id': 'ba253fd0-8068-11e4-98c0-5254008ea111',
|
||||
'volume_type_id': 'drbdmanage',
|
||||
'created_at': timeutils.utcnow()}
|
||||
|
||||
newvol = {'id': 'ca253fd0-8068-11e4-98c0-5254008ea111'}
|
||||
|
||||
dmd = drv.DrbdManageIscsiDriver(configuration=self.configuration)
|
||||
dmd.odm = DrbdManageFakeDriver()
|
||||
dmd.create_volume_from_snapshot(newvol, snap)
|
||||
self.assertEqual("list_snapshots", dmd.odm.calls[0][0])
|
||||
self.assertEqual("restore_snapshot", dmd.odm.calls[1][0])
|
||||
self.assertEqual("run_external_plugin", dmd.odm.calls[2][0])
|
||||
|
||||
def test_create_volume_from_snapshot_larger_size(self):
|
||||
snap = {'project_id': 'testprjid',
|
||||
'name': 'testvol',
|
||||
'volume_size': 1,
|
||||
'id': 'ba253fd0-8068-11e4-98c0-5254008ea111',
|
||||
'volume_type_id': 'drbdmanage',
|
||||
'created_at': timeutils.utcnow()}
|
||||
|
||||
newvol = {'size': 5,
|
||||
'id': 'ca253fd0-8068-11e4-98c0-5254008ea111'}
|
||||
|
||||
dmd = drv.DrbdManageIscsiDriver(configuration=self.configuration)
|
||||
dmd.odm = DrbdManageFakeDriver()
|
||||
dmd.create_volume_from_snapshot(newvol, snap)
|
||||
self.assertEqual("list_snapshots", dmd.odm.calls[0][0])
|
||||
self.assertEqual("restore_snapshot", dmd.odm.calls[1][0])
|
||||
self.assertEqual("run_external_plugin", dmd.odm.calls[2][0])
|
||||
|
||||
# resize image checks
|
||||
self.assertEqual("list_volumes", dmd.odm.calls[9][0])
|
||||
self.assertEqual(newvol['id'], dmd.odm.calls[9][3]["aux:cinder-id"])
|
||||
self.assertEqual("resize_volume", dmd.odm.calls[10][0])
|
||||
self.assertEqual("res", dmd.odm.calls[10][1])
|
||||
self.assertEqual(2, dmd.odm.calls[10][2])
|
||||
self.assertEqual(-1, dmd.odm.calls[10][3])
|
||||
self.assertEqual(5242880, dmd.odm.calls[10][4])
|
||||
self.assertEqual("list_volumes", dmd.odm.calls[3][0])
|
||||
self.assertEqual(newvol['id'], dmd.odm.calls[3][3]["aux:cinder-id"])
|
||||
self.assertEqual("resize_volume", dmd.odm.calls[4][0])
|
||||
self.assertEqual("res", dmd.odm.calls[4][1])
|
||||
self.assertEqual(2, dmd.odm.calls[4][2])
|
||||
self.assertEqual(-1, dmd.odm.calls[4][3])
|
||||
self.assertEqual(5242880, dmd.odm.calls[4][4])
|
||||
|
||||
|
||||
class DrbdManageDrbdTestCase(DrbdManageIscsiTestCase):
|
||||
|
@ -585,24 +585,26 @@ class DrbdManageBaseDriver(driver.VolumeDriver):
|
||||
{'res': new_res, 'vol': volume['id']})
|
||||
raise exception.VolumeBackendAPIException(data=message)
|
||||
|
||||
if (('size' in volume) and (volume['size'] > snapshot['volume_size'])):
|
||||
LOG.debug("resize volume '%(dst_vol)s' from %(src_size)d to "
|
||||
"%(dst_size)d",
|
||||
{'dst_vol': volume['id'],
|
||||
'src_size': snapshot['volume_size'],
|
||||
'dst_size': volume['size']})
|
||||
self.extend_volume(volume, volume['size'])
|
||||
|
||||
def create_cloned_volume(self, volume, src_vref):
|
||||
temp_id = self._clean_uuid()
|
||||
snapshot = {'id': temp_id}
|
||||
|
||||
self.create_snapshot({'id': temp_id, 'volume_id': src_vref['id']})
|
||||
self.create_snapshot({'id': temp_id,
|
||||
'volume_id': src_vref['id']})
|
||||
|
||||
snapshot['volume_size'] = src_vref['size']
|
||||
self.create_volume_from_snapshot(volume, snapshot)
|
||||
|
||||
self.delete_snapshot(snapshot)
|
||||
|
||||
if (('size' in volume) and (volume['size'] > src_vref['size'])):
|
||||
LOG.debug("resize volume '%(dst_vol)s' from %(src_size)d to "
|
||||
"%(dst_size)d",
|
||||
{'dst_vol': volume['id'],
|
||||
'src_size': src_vref['size'],
|
||||
'dst_size': volume['size']})
|
||||
self.extend_volume(volume, volume['size'])
|
||||
|
||||
def _update_volume_stats(self):
|
||||
data = {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user