Merge "remove reserve_quota_delta"
This commit is contained in:
commit
52b39b77af
|
@ -734,25 +734,6 @@ def downsize_quota_delta(context, instance):
|
|||
return resize_quota_delta(context, new_flavor, old_flavor, 1, -1)
|
||||
|
||||
|
||||
def reserve_quota_delta(context, deltas, instance):
|
||||
"""If there are deltas to reserve, construct a Quotas object and
|
||||
reserve the deltas for the given project.
|
||||
|
||||
:param context: The nova request context.
|
||||
:param deltas: A dictionary of the proposed delta changes.
|
||||
:param instance: The instance we're operating on, so that
|
||||
quotas can use the correct project_id/user_id.
|
||||
:return: nova.objects.quotas.Quotas
|
||||
"""
|
||||
quotas = objects.Quotas(context=context)
|
||||
if deltas:
|
||||
project_id, user_id = objects.quotas.ids_from_instance(context,
|
||||
instance)
|
||||
quotas.reserve(project_id=project_id, user_id=user_id,
|
||||
**deltas)
|
||||
return quotas
|
||||
|
||||
|
||||
def get_headroom(quotas, usages, deltas):
|
||||
headroom = {res: quotas[res] - usages[res]
|
||||
for res in quotas.keys()}
|
||||
|
|
|
@ -650,14 +650,13 @@ class CellsConductorAPIRPCRedirect(test.NoDBTestCase):
|
|||
@mock.patch.object(objects.RequestSpec, 'get_by_instance_uuid')
|
||||
@mock.patch.object(compute_api.API, '_record_action_start')
|
||||
@mock.patch.object(compute_api.API, '_resize_cells_support')
|
||||
@mock.patch.object(compute_utils, 'reserve_quota_delta')
|
||||
@mock.patch.object(compute_utils, 'upsize_quota_delta')
|
||||
@mock.patch.object(objects.Instance, 'save')
|
||||
@mock.patch.object(flavors, 'extract_flavor')
|
||||
@mock.patch.object(compute_api.API, '_check_auto_disk_config')
|
||||
@mock.patch.object(objects.BlockDeviceMappingList, 'get_by_instance_uuid')
|
||||
def test_resize_instance(self, _bdms, _check, _extract, _save, _upsize,
|
||||
_reserve, _cells, _record, _spec_get_by_uuid):
|
||||
_cells, _record, _spec_get_by_uuid):
|
||||
flavor = objects.Flavor(**test_flavor.fake_flavor)
|
||||
_extract.return_value = flavor
|
||||
orig_system_metadata = {}
|
||||
|
|
|
@ -1097,25 +1097,6 @@ class ComputeUtilsQuotaTestCase(test.TestCase):
|
|||
deltas = compute_utils.reverse_upsize_quota_delta(self.context, inst)
|
||||
self.assertEqual(expected_deltas, deltas)
|
||||
|
||||
@mock.patch.object(objects.Quotas, 'reserve')
|
||||
@mock.patch.object(objects.quotas, 'ids_from_instance')
|
||||
def test_reserve_quota_delta(self, mock_ids_from_instance,
|
||||
mock_reserve):
|
||||
quotas = objects.Quotas(context=context)
|
||||
inst = create_instance(self.context, params=None)
|
||||
inst.old_flavor = flavors.get_flavor_by_name('m1.tiny')
|
||||
inst.new_flavor = flavors.get_flavor_by_name('m1.medium')
|
||||
|
||||
mock_ids_from_instance.return_value = (inst.project_id, inst.user_id)
|
||||
mock_reserve.return_value = quotas
|
||||
|
||||
deltas = compute_utils.upsize_quota_delta(self.context,
|
||||
inst.new_flavor,
|
||||
inst.old_flavor)
|
||||
compute_utils.reserve_quota_delta(self.context, deltas, inst)
|
||||
mock_reserve.assert_called_once_with(project_id=inst.project_id,
|
||||
user_id=inst.user_id, **deltas)
|
||||
|
||||
@mock.patch('nova.objects.Quotas.count_as_dict')
|
||||
def test_check_instance_quota_exceeds_with_multiple_resources(self,
|
||||
mock_count):
|
||||
|
|
Loading…
Reference in New Issue