#NEWLINE# @ rbac ( '*' ) #NEWLINE# def time_estimate( self , resource_desc ) : #NEWLINE# #INDENT# '\n        Return ``(estimate, criteria)`` indicating how well this resource\n        allocator can satisfy the `resource_desc` request.  The estimate will\n        be:\n\n        - >0 for an estimate of walltime (seconds).\n        -  0 for no estimate.\n        - -1 for no resource at this time.\n        - -2 for no support for `resource_desc`.\n\n        The returned criteria is a dictionary containing information related\n        to the estimate, such as hostnames, load averages, unsupported\n        resources, etc.\n\n        resource_desc: dict\n            Description of required resources.\n        ' #NEWLINE# ( retcode , info ) = self . check_compatibility ( resource_desc ) #NEWLINE# if ( retcode != 0 ) : #NEWLINE# #INDENT# return ( retcode , info ) #NEWLINE# #UNINDENT# hostnames = self . _get_hosts ( ) #NEWLINE# if ( not hostnames ) : #NEWLINE# #INDENT# return ( ( - 2 ) , { #NEWLINE# #INDENT# 'hostnames' : 'no hosts available' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( 'min_cpus' in resource_desc ) : #NEWLINE# #INDENT# value = resource_desc [ 'min_cpus' ] #NEWLINE# if ( len ( info ) < value ) : #NEWLINE# #INDENT# return ( ( - 2 ) , { #NEWLINE# #INDENT# 'min_cpus' : ( 'want %s, have %s' % ( value , len ( hostnames ) ) ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# criteria = { #NEWLINE# #INDENT# 'hostnames' : hostnames , #NEWLINE# 'total_cpus' : len ( hostnames ) , #NEWLINE# #UNINDENT# } #NEWLINE# return ( 0 , criteria )