summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2014-03-18 07:40:36 +0100
committerMichal Minar <miminar@redhat.com>2014-03-18 07:40:36 +0100
commit71d8c6e975402cba911cd915c7434ce596b2d949 (patch)
tree4478d0664678278b18800ae73702e4204004a0cd
parentb76c8e39759316247e34a1a54aad07097691e38c (diff)
parente436e0064233248a0976cc97116271313a52d462 (diff)
downloadopenlmi-scripts-71d8c6e975402cba911cd915c7434ce596b2d949.tar.gz
openlmi-scripts-71d8c6e975402cba911cd915c7434ce596b2d949.tar.xz
openlmi-scripts-71d8c6e975402cba911cd915c7434ce596b2d949.zip
Merge pull request #75 from pschiffe/master
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