#NEWLINE# def get_networkinfo( ns ) : #NEWLINE# #INDENT# '\n    Prints tabular data of networking status.\n    ' #NEWLINE# tf = TableFormatter ( stdout , 0 , True , { #NEWLINE# #INDENT# 0 : FIRST_COLUMN_MIN_SIZE , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = [ ( '' , '' ) , ( 'Networking:' , '' ) ] #NEWLINE# try : #NEWLINE# #INDENT# lan_endpoints = get_all_instances ( ns , 'LMI_LANEndpoint' ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# result += [ ( get_colored_string ( 'error:' , RED_COLOR ) , 'Missing class LMI_LANEndpoint. Is openlmi-networking package installed on the server?' ) ] #NEWLINE# tf . produce_output ( result ) #NEWLINE# return [ ] #NEWLINE# #UNINDENT# nic = 1 #NEWLINE# for lan_endpoint in lan_endpoints : #NEWLINE# #INDENT# if ( lan_endpoint . Name == 'lo' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# result += [ ( ( '  NIC %d' % nic ) , '' ) , ( '    Name:' , lan_endpoint . Name ) ] #NEWLINE# try : #NEWLINE# #INDENT# ip_net_con = lan_endpoint . associators ( AssocClass = 'LMI_EndpointForIPNetworkConnection' , ResultClass = 'LMI_IPNetworkConnection' ) [ 0 ] #NEWLINE# result += [ ( '    Status:' , ns . LMI_IPNetworkConnection . OperatingStatusValues . value_name ( ip_net_con . OperatingStatus ) ) ] #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# for ip_protocol_endpoint in lan_endpoint . associators ( AssocClass = 'LMI_BindsToLANEndpoint' , ResultClass = 'LMI_IPProtocolEndpoint' ) : #NEWLINE# #INDENT# if ( ip_protocol_endpoint . ProtocolIFType == ns . LMI_IPProtocolEndpoint . ProtocolIFTypeValues . IPv4 ) : #NEWLINE# #INDENT# result += [ ( '    IPv4 Address:' , ip_protocol_endpoint . IPv4Address ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ip_protocol_endpoint . ProtocolIFType == ns . LMI_IPProtocolEndpoint . ProtocolIFTypeValues . IPv6 ) : #NEWLINE# #INDENT# result += [ ( '    IPv6 Address:' , ip_protocol_endpoint . IPv6Address ) ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# result += [ ( '    MAC Address:' , lan_endpoint . MACAddress ) ] #NEWLINE# tf . produce_output ( result ) #NEWLINE# result = [ ] #NEWLINE# nic += 1 #NEWLINE# #UNINDENT# return [ ]