#NEWLINE# def host_passes( self , host_state , spec_obj ) : #NEWLINE# #INDENT# 'Return a list of hosts that can create instance_type\n\n        Check that the extra specs associated with the instance type match\n        the metadata provided by aggregates.  If not present return False.\n        ' #NEWLINE# instance_type = spec_obj . flavor #NEWLINE# if ( ( not instance_type . obj_attr_is_set ( 'extra_specs' ) ) or ( not instance_type . extra_specs ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# metadata = utils . aggregate_metadata_get_by_host ( host_state ) #NEWLINE# for ( key , req ) in six . iteritems ( instance_type . extra_specs ) : #NEWLINE# #INDENT# scope = key . split ( ':' , 1 ) #NEWLINE# if ( len ( scope ) > 1 ) : #NEWLINE# #INDENT# if ( scope [ 0 ] != _SCOPE ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# del scope [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# key = scope [ 0 ] #NEWLINE# aggregate_vals = metadata . get ( key , None ) #NEWLINE# if ( not aggregate_vals ) : #NEWLINE# #INDENT# LOG . debug ( '%(host_state)s fails instance_type extra_specs requirements. Extra_spec %(key)s is not in aggregate.' , { #NEWLINE# #INDENT# 'host_state' : host_state , #NEWLINE# 'key' : key , #NEWLINE# #UNINDENT# } ) #NEWLINE# return False #NEWLINE# #UNINDENT# for aggregate_val in aggregate_vals : #NEWLINE# #INDENT# if extra_specs_ops . match ( aggregate_val , req ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# LOG . debug ( "%(host_state)s fails instance_type extra_specs requirements. '%(aggregate_vals)s' do not match '%(req)s'" , { #NEWLINE# #INDENT# 'host_state' : host_state , #NEWLINE# 'req' : req , #NEWLINE# 'aggregate_vals' : aggregate_vals , #NEWLINE# #UNINDENT# } ) #NEWLINE# return False #NEWLINE# #UNINDENT# #UNINDENT# return True