#NEWLINE# @ click . command ( ) #NEWLINE# @ click . option ( '--name' , default = None , help = 'Filter on image name' ) #NEWLINE# @ click . option ( '--public/--private' , is_flag = True , default = None , help = 'Display only public or private images' ) #NEWLINE# @ environment . pass_env #NEWLINE# def cli( env , name , public ) : #NEWLINE# #INDENT# 'List images.' #NEWLINE# image_mgr = SoftLayer . ImageManager ( env . client ) #NEWLINE# images = [ ] #NEWLINE# if ( public in [ False , None ] ) : #NEWLINE# #INDENT# for image in image_mgr . list_private_images ( name = name , mask = image_mod . MASK ) : #NEWLINE# #INDENT# images . append ( image ) #NEWLINE# #UNINDENT# #UNINDENT# if ( public in [ True , None ] ) : #NEWLINE# #INDENT# for image in image_mgr . list_public_images ( name = name , mask = image_mod . MASK ) : #NEWLINE# #INDENT# images . append ( name ) #NEWLINE# #UNINDENT# #UNINDENT# table = formatting . Table ( [ 'id' , 'name' , 'type' , 'visibility' , 'account' ] ) #NEWLINE# images = [ image for image in images if ( image [ 'parentId' ] == '' ) ] #NEWLINE# for image in images : #NEWLINE# #INDENT# visibility = ( image_mod . PUBLIC_TYPE if image [ 'publicFlag' ] else image_mod . PRIVATE_TYPE ) #NEWLINE# table . add_row ( [ image . get ( 'id' , formatting . blank ( ) ) , formatting . FormattedItem ( image [ 'name' ] , click . wrap_text ( image [ 'name' ] , width = 50 ) ) , formatting . FormattedItem ( utils . lookup ( image , 'imageType' , 'keyName' ) , utils . lookup ( image , 'imageType' , 'name' ) ) , visibility , image . get ( 'accountId' , formatting . blank ( ) ) ] ) #NEWLINE# #UNINDENT# env . fout ( table )