#NEWLINE# def image_delete( id = None , name = None , profile = None ) : #NEWLINE# #INDENT# "\n    Delete an image (glance image-delete)\n\n    CLI Examples:\n\n    .. code-block:: bash\n\n        salt '*' glance.image_delete c2eb2eb0-53e1-4a80-b990-8ec887eae7df\n        salt '*' glance.image_delete id=c2eb2eb0-53e1-4a80-b990-8ec887eae7df\n        salt '*' glance.image_delete name=f16-jeos\n    " #NEWLINE# g_client = _auth ( profile ) #NEWLINE# image = { #NEWLINE# #INDENT# 'id' : False , #NEWLINE# 'name' : None , #NEWLINE# #UNINDENT# } #NEWLINE# if name : #NEWLINE# #INDENT# for image in g_client . images . list ( ) : #NEWLINE# #INDENT# if ( image . name == name ) : #NEWLINE# #INDENT# id = image . id #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not id ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'result' : False , #NEWLINE# 'comment' : 'Unable to resolve image id for name {0}' . format ( name ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not name ) : #NEWLINE# #INDENT# name = image [ 'name' ] #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# g_client . images . delete ( id ) #NEWLINE# #UNINDENT# except exc . HTTPNotFound : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'result' : False , #NEWLINE# 'comment' : 'No image with ID {0}' . format ( id ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# except exc . HTTPForbidden as forbidden : #NEWLINE# #INDENT# log . error ( str ( forbidden ) ) #NEWLINE# return { #NEWLINE# #INDENT# 'result' : False , #NEWLINE# 'comment' : str ( forbidden ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'result' : True , #NEWLINE# 'comment' : "Deleted image '{0}' ({1})." . format ( name , id ) , #NEWLINE# #UNINDENT# }