#NEWLINE# def allowed( self , request , datum ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# limits = api . nova . tenant_absolute_limits ( request , reserved = True ) #NEWLINE# instances_available = ( limits [ 'maxTotalInstances' ] - limits [ 'totalInstancesUsed' ] ) #NEWLINE# cores_available = ( limits [ 'maxTotalCores' ] - limits [ 'totalCoresUsed' ] ) #NEWLINE# ram_available = ( limits [ 'maxTotalRAMSize' ] - limits [ 'totalRAMUsed' ] ) #NEWLINE# if ( ( instances_available <= 0 ) or ( cores_available <= 0 ) or ( ram_available <= 0 ) ) : #NEWLINE# #INDENT# if ( 'disabled' not in self . classes ) : #NEWLINE# #INDENT# self . classes = ( [ c for c in self . classes ] + [ 'disabled' ] ) #NEWLINE# self . verbose_name = string_concat ( request . verbose_name , ' ' , _ ( '(Quota exceeded)' ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . verbose_name = _ ( 'Launch Instance' ) #NEWLINE# classes = [ c for c in self . classes if ( c != 'disabled' ) ] #NEWLINE# self . classes = classes #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# LOG . exception ( 'Failed to retrieve quota information' ) #NEWLINE# #UNINDENT# return True