volume_api.extend(self.context, volume, 3)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('extending', volume['status'])
+ reserve.assert_called_once_with(self.context, gigabytes=1,
+ project_id=volume['project_id'])
# Test the quota exceeded
volume['status'] = 'available'
# Test driver success
with mock.patch.object(self.volume.driver,
'extend_volume') as extend_volume:
- extend_volume.return_value = fake_extend
- volume['status'] = 'extending'
- self.volume.extend_volume(self.context, volume['id'], '4',
- fake_reservations)
- volume = db.volume_get(context.get_admin_context(), volume['id'])
- self.assertEqual(4, volume['size'])
- self.assertEqual('available', volume['status'])
+ with mock.patch.object(QUOTAS, 'commit') as quotas_commit:
+ extend_volume.return_value = fake_extend
+ volume['status'] = 'extending'
+ self.volume.extend_volume(self.context, volume['id'], '4',
+ fake_reservations)
+ volume = db.volume_get(context.get_admin_context(),
+ volume['id'])
+ self.assertEqual(4, volume['size'])
+ self.assertEqual('available', volume['status'])
+ quotas_commit.assert_called_with(
+ self.context,
+ ['RESERVATION'],
+ project_id=volume['project_id'])
# clean up
self.volume.delete_volume(self.context, volume['id'])
reserve_opts = {'gigabytes': size_increase}
QUOTAS.add_volume_type_opts(context, reserve_opts,
volume.get('volume_type_id'))
- reservations = QUOTAS.reserve(context, **reserve_opts)
+ reservations = QUOTAS.reserve(context,
+ project_id=volume['project_id'],
+ **reserve_opts)
except exception.OverQuota as exc:
usages = exc.kwargs['usages']
quotas = exc.kwargs['quotas']
{'status': 'error_extending'})
volume = self.db.volume_get(context, volume_id)
+ project_id = volume['project_id']
size_increase = (int(new_size)) - volume['size']
self._notify_about_volume_usage(context, volume, "resize.start")
try:
"to extend volume") %
volume_id)
finally:
- QUOTAS.rollback(context, reservations)
+ QUOTAS.rollback(context, reservations, project_id=project_id)
return
- QUOTAS.commit(context, reservations)
+ QUOTAS.commit(context, reservations, project_id=project_id)
volume = self.db.volume_update(context,
volume['id'],
{'size': int(new_size),