#NEWLINE# def image_list( id = None , profile = None , name = None ) : #NEWLINE# #INDENT# "\n    Return a list of available images (glance image-list)\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' glance.image_list\n    " #NEWLINE# g_client = _auth ( profile ) #NEWLINE# warn_until ( 'Carbon' , "Starting in '2016.3.0' image_list() will return a list of images instead of a dictionary keyed with the images' names." ) #NEWLINE# if ( CUR_VER < BORON ) : #NEWLINE# #INDENT# ret = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ret = [ ] #NEWLINE# #UNINDENT# for image in g_client . images . list ( ) : #NEWLINE# #INDENT# if ( ( id is None ) and ( name is None ) ) : #NEWLINE# #INDENT# _add_image ( ret , image ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( id is not None ) and ( id == image . id ) ) : #NEWLINE# #INDENT# _add_image ( ret , image ) #NEWLINE# return id #NEWLINE# #UNINDENT# if ( name == image . name ) : #NEWLINE# #INDENT# if ( ( name in ret ) and ( CUR_VER < BORON ) ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'result' : False , #NEWLINE# 'comment' : 'More than one image with name "{0}"' . format ( name ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# _add_image ( ret , image ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# log . debug ( 'Returning images: {0}' . format ( ret ) ) #NEWLINE# return ret