#NEWLINE# def print_containers( containers , to_json = False ) : #NEWLINE# #INDENT# containers = sorted ( containers , key = ( lambda c : c . name ) ) #NEWLINE# if to_json : #NEWLINE# #INDENT# d = [ c . to_dict ( ) for c in containers ] #NEWLINE# puts ( json . dumps ( d , indent = 2 , sort_keys = True , separators = ( ',' , ': ' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# puts ( colored . blue ( columns ( [ 'NODE' , 15 ] , [ 'CONTAINER ID' , 15 ] , [ 'STATUS' , 7 ] , [ 'IP' , 15 ] , [ 'NETWORK' , 10 ] , [ 'PARTITION' , 10 ] ) ) ) #NEWLINE# def partition_label( c ) : #NEWLINE# #INDENT# if c . holy : #NEWLINE# #INDENT# return 'H' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if c . partition : #NEWLINE# #INDENT# if c . neutral : #NEWLINE# #INDENT# return ( str ( c . partition ) + ' [N]' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return str ( c . partition ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if c . neutral : #NEWLINE# #INDENT# return 'N' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for container in containers : #NEWLINE# #INDENT# puts ( columns ( [ container . name , 15 ] , [ container . container_id [ : 12 ] , 15 ] , [ container . state , 7 ] , [ ( container . ip_address or '' ) , 15 ] , [ container . network_state , 10 ] , [ partition_label ( container ) , 10 ] ) )