def _update_nested_quota_allocated(self, ctxt, target_project, target_project_quotas, res, new_limit): reservations = [] # per_volume_gigabytes doesn't make sense to nest if res == "per_volume_gigabytes": return reservations quota_for_res = target_project_quotas.get(res, {}) orig_quota_from_target_proj = quota_for_res.get('limit', 0) # If limit was -1, we were "taking" current child's usage from parent if orig_quota_from_target_proj == -1: orig_quota_from_target_proj = self._get_quota_usage(quota_for_res) new_quota_from_target_proj = new_limit # If we set limit to -1, we will "take" the current usage from parent if new_limit == -1: new_quota_from_target_proj = self._get_quota_usage(quota_for_res) res_change = new_quota_from_target_proj - orig_quota_from_target_proj if res_change != 0: deltas = {res: res_change} reservations += quota_utils.update_alloc_to_next_hard_limit( ctxt, QUOTAS.resources, deltas, res, None, target_project.id) return reservations
def _update_nested_quota_allocated(self, ctxt, target_project, target_project_quotas, res, new_limit): reservations = [] # per_volume_gigabytes doesn't make sense to nest if res == "per_volume_gigabytes": return reservations quota_for_res = target_project_quotas.get(res, {}) orig_quota_from_target_proj = quota_for_res.get('limit', 0) # If limit was -1, we were "taking" current child's usage from parent if orig_quota_from_target_proj == -1: orig_quota_from_target_proj = self._get_quota_usage(quota_for_res) new_quota_from_target_proj = new_limit # If we set limit to -1, we will "take" the current usage from parent if new_limit == -1: new_quota_from_target_proj = self._get_quota_usage(quota_for_res) res_change = new_quota_from_target_proj - orig_quota_from_target_proj if res_change != 0: deltas = {res: res_change} reservations += quota_utils.update_alloc_to_next_hard_limit( ctxt, QUOTAS.resources, deltas, res, None, target_project.id) return reservations