#NEWLINE# def get_location( conn , vm_ ) : #NEWLINE# #INDENT# '\n    Return the location object to use\n    ' #NEWLINE# locations = conn . list_locations ( ) #NEWLINE# vm_location = config . get_cloud_config_value ( 'location' , vm_ , __opts__ ) . encode ( 'ascii' , 'salt-cloud-force-ascii' ) #NEWLINE# for img in locations : #NEWLINE# #INDENT# if isinstance ( img . id , string_types ) : #NEWLINE# #INDENT# img_id = img . id . encode ( 'ascii' , 'salt-cloud-force-ascii' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# img_id = str ( img . id ) #NEWLINE# #UNINDENT# if isinstance ( img . name , string_types ) : #NEWLINE# #INDENT# img_name = img . name . encode ( 'ascii' , 'salt-cloud-force-ascii' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# img_name = str ( img . name ) #NEWLINE# #UNINDENT# if ( vm_location and ( vm_location in ( img_id , img_name ) ) ) : #NEWLINE# #INDENT# return img #NEWLINE# #UNINDENT# #UNINDENT# raise SaltCloudNotFound ( "The specified location, '{0}', could not be found." . format ( vm_location ) )