summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2014-03-17 15:46:11 +0100
committerPeter Schiffer <pschiffe@redhat.com>2014-03-17 15:46:11 +0100
commite436e0064233248a0976cc97116271313a52d462 (patch)
treea8bfc2f23f5eff139d0472b7f8e398edc2455ab5
parent79b1b0e1935f068517acad9fb36647a6e5879f53 (diff)
downloadopenlmi-scripts-e436e0064233248a0976cc97116271313a52d462.tar.gz
openlmi-scripts-e436e0064233248a0976cc97116271313a52d462.tar.xz
openlmi-scripts-e436e0064233248a0976cc97116271313a52d462.zip
System: added networking info
-rw-r--r--commands/system/lmi/scripts/system/__init__.py45
1 files changed, 45 insertions, 0 deletions
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