#NEWLINE# def _discover_or_create_image( self ) : #NEWLINE# #INDENT# glance_wrap = glance_wrapper . wrap ( self . clients . glance , self ) #NEWLINE# if CONF . image . name_regex : #NEWLINE# #INDENT# LOG . debug ( ( "Trying to discover a public image with name matching regular expression '%s'. Note that case insensitive matching is performed" % CONF . image . name_regex ) ) #NEWLINE# images = glance_wrap . list_images ( status = 'active' , visibility = 'public' ) #NEWLINE# for img in images : #NEWLINE# #INDENT# if ( img . name and re . match ( CONF . image . name_regex , img . name , re . IGNORECASE ) ) : #NEWLINE# #INDENT# LOG . debug ( "The following public image discovered: '{0}'. Using image '{0}' for the tests" . format ( img . name ) ) #NEWLINE# return img #NEWLINE# #UNINDENT# #UNINDENT# LOG . debug ( ( "There is no public image with name matching regular expression '%s'" % CONF . image . name_regex ) ) #NEWLINE# #UNINDENT# params = { #NEWLINE# #INDENT# 'name' : self . generate_random_name ( ) , #NEWLINE# 'disk_format' : CONF . image . disk_format , #NEWLINE# 'container_format' : CONF . image . container_format , #NEWLINE# 'image_location' : os . path . join ( _create_or_get_data_dir ( ) , self . image_name ) , #NEWLINE# 'visibility' : 'public' , #NEWLINE# #UNINDENT# } #NEWLINE# LOG . debug ( ( "Creating image '%s'" % params [ 'name' ] ) ) #NEWLINE# image = glance_wrap . create_image ( ** params ) #NEWLINE# self . _created_images . append ( image ) #NEWLINE# return image