#NEWLINE# def _process_quotas( self , context , resources , project_id , quotas , quota_class = None , defaults = True , usages = None , remains = False ) : #NEWLINE# #INDENT# modified_quotas = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( project_id == context . project_id ) : #NEWLINE# #INDENT# quota_class = context . quota_class #NEWLINE# #UNINDENT# if quota_class : #NEWLINE# #INDENT# class_quotas = db . quota_class_get_all_by_name ( context , quota_class ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# class_quotas = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# default_quotas = self . get_defaults ( context , resources ) #NEWLINE# for resource in resources . values ( ) : #NEWLINE# #INDENT# if ( ( not defaults ) and ( resource . name not in quotas ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# limit = quotas . get ( resource . name , class_quotas . get ( resource . name , default_quotas [ resource . name ] ) ) #NEWLINE# modified_quotas [ resource . name ] = dict ( limit = limit ) #NEWLINE# if usages : #NEWLINE# #INDENT# usage = usages . get ( resource . name , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# modified_quotas [ resource . name ] . update ( in_use = usage . get ( 'in_use' , 0 ) , reserved = usage . get ( 'reserved' , 0 ) ) #NEWLINE# #UNINDENT# if remains : #NEWLINE# #INDENT# modified_quotas [ resource . name ] . update ( remains = limit ) #NEWLINE# #UNINDENT# #UNINDENT# if remains : #NEWLINE# #INDENT# all_quotas = db . quota_get_all ( context , project_id ) #NEWLINE# for quota in all_quotas : #NEWLINE# #INDENT# if ( quota . resource in modified_quotas ) : #NEWLINE# #INDENT# modified_quotas [ quota . resource ] [ 'remains' ] -= quota . hard_limit #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return usage