From e436e0064233248a0976cc97116271313a52d462 Mon Sep 17 00:00:00 2001 From: Peter Schiffer Date: Mon, 17 Mar 2014 15:46:11 +0100 Subject: System: added networking info --- commands/system/lmi/scripts/system/__init__.py | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/commands/system/lmi/scripts/system/__init__.py b/commands/system/lmi/scripts/system/__init__.py index 9588ec3..8617138 100644 --- a/commands/system/lmi/scripts/system/__init__.py +++ b/commands/system/lmi/scripts/system/__init__.py @@ -110,6 +110,7 @@ def get_system_info(ns): result += get_hwinfo(ns) result += get_osinfo(ns) result += get_servicesinfo(ns) + result += get_networkinfo(ns) return result def get_hostname(ns): @@ -231,3 +232,47 @@ def get_servicesinfo(ns): ('Firewall:', fw), ('Logging:', logging)] return result + +def get_networkinfo(ns): + """ + :returns: Tabular data of networking status. + :rtype: List of tuples + """ + result = [('', ''), ('Networking', '')] + try: + lan_endpoints = get_all_instances(ns, 'LMI_LANEndpoint') + except LMIClassNotFound: + result.append((' N/A', '')) + return result + nic = 1 + for lan_endpoint in lan_endpoints: + if lan_endpoint.Name == 'lo': + continue + result += [ + (' NIC %d' % nic, ''), + (' Name:', lan_endpoint.Name)] + try: + ip_net_con = lan_endpoint.associators( + ResultClass='LMI_IPNetworkConnection')[0] + result.append((' Status:', + ns.LMI_IPNetworkConnection.OperatingStatusValues.value_name( + ip_net_con.OperatingStatus))) + except LMIClassNotFound: + pass + try: + for ip_protocol_endpoint in lan_endpoint.associators( + ResultClass='LMI_IPProtocolEndpoint'): + if ip_protocol_endpoint.ProtocolIFType == \ + ns.LMI_IPProtocolEndpoint.ProtocolIFTypeValues.IPv4: + result.append((' IPv4 Address:', + ip_protocol_endpoint.IPv4Address)) + elif ip_protocol_endpoint.ProtocolIFType == \ + ns.LMI_IPProtocolEndpoint.ProtocolIFTypeValues.IPv6: + result.append((' IPv6 Address:', + ip_protocol_endpoint.IPv6Address)) + except LMIClassNotFound: + pass + result += [ + (' MAC Address:', lan_endpoint.MACAddress)] + nic += 1 + return result -- cgit