@db_api.retry_if_session_inactive()
def get_reservations_for_resources(context, tenant_id, resources, expired=False):
 if (not resources):
  return
 now = utcnow()
 resv_query = context.session.query(quota_models.ResourceDelta.resource, quota_models.Reservation.expiration, sql.func.sum(quota_models.ResourceDelta.amount)).join(quota_models.Reservation)
 if expired:
  exp_expr = (quota_models.Reservation.expiration < now)
 else:
  exp_expr = (quota_models.Reservation.expiration >= now)
 resv_query = resv_query.filter(sa.and_((quota_models.Reservation.tenant_id == tenant_id), quota_models.ResourceDelta.resource.in_(resources), exp_expr)).group_by(quota_models.ResourceDelta.resource, quota_models.Reservation.expiration)
 return dict(((resource, total_reserved) for (resource, exp, total_reserved) in resv_query))

@ db_api . retry_if_session_inactive ( ) def get_reservations_for_resources ( context , tenant_id , resources , expired = False ) : if ( not resources ) : return now = utcnow ( ) resv_query = context . session . query ( quota_models . ResourceDelta . resource , quota_models . Reservation . expiration , sql . func . sum ( quota_models . ResourceDelta . amount ) ) . join ( quota_models . Reservation ) if expired : exp_expr = ( quota_models . Reservation . expiration < now ) else : exp_expr = ( quota_models . Reservation . expiration >= now ) resv_query = resv_query . filter ( sa . and_ ( ( quota_models . Reservation . tenant_id == tenant_id ) , quota_models . ResourceDelta . resource . in_ ( resources ) , exp_expr ) ) . group_by ( quota_models . ResourceDelta . resource , quota_models . Reservation . expiration ) return dict ( ( ( resource , total_reserved ) for ( resource , exp , total_reserved ) in resv_query ) )
retrieve total amount of reservations for specified resources .