summaryrefslogtreecommitdiffstats
path: root/isys
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-04-22 00:22:50 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-05-04 15:14:05 -1000
commit2d0cec6dbd804b3f02a6dd7ab6b390955ea3f660 (patch)
tree37ae68fa41a3d20918c0ee63655c34eb331018fc /isys
parente77eaf1276e015b3d7a0d15c52e9f20ba7a4deae (diff)
downloadanaconda-2d0cec6dbd804b3f02a6dd7ab6b390955ea3f660.tar.gz
anaconda-2d0cec6dbd804b3f02a6dd7ab6b390955ea3f660.tar.xz
anaconda-2d0cec6dbd804b3f02a6dd7ab6b390955ea3f660.zip
Collect network interfaces from NetworkManager (#493995)
Remove minihal.py and use NetworkManager to get a list of device names and their hardware addresses. Still have to talk to hal via D-Bus to build a description string, but the hal path is given to us by NetworkManager, so we are sure we are only building a list of interfaces that NetworkManager knows about and can communicate with. Also rewrite command-stubs/list-harddrives to not use minihal.
Diffstat (limited to 'isys')
-rwxr-xr-xisys/isys.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/isys/isys.py b/isys/isys.py
index 0a3fe62c5..0ea19f260 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -36,7 +36,6 @@ import resource
import re
import struct
import block
-import minihal
import rhpl
import dbus
@@ -47,7 +46,6 @@ import warnings
NM_SERVICE = "org.freedesktop.NetworkManager"
NM_MANAGER_PATH = "/org/freedesktop/NetworkManager"
NM_MANAGER_IFACE = "org.freedesktop.NetworkManager"
-DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties"
NM_ACTIVE_CONNECTION_IFACE = "org.freedesktop.NetworkManager.Connection.Active"
NM_CONNECTION_IFACE = "org.freedesktop.NetworkManagerSettings.Connection"
NM_DEVICE_IFACE = "org.freedesktop.NetworkManager.Device"
@@ -58,6 +56,12 @@ NM_STATE_CONNECTING = 2
NM_STATE_CONNECTED = 3
NM_STATE_DISCONNECTED = 4
+HAL_SERVICE = "org.freedesktop.Hal"
+HAL_PATH = "/org/freedesktop/Hal"
+HAL_DEVICE_IFACE = "org.freedesktop.Hal.Device"
+
+DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties"
+
mountCount = {}
MIN_RAM = _isys.MIN_RAM
@@ -579,6 +583,36 @@ def getMacAddress(dev):
device_macaddr = device_props_iface.Get(NM_MANAGER_IFACE, "HwAddress")
return device_macaddr.upper()
+# Get a description string for a network device (e.g., eth0)
+def getNetDevDesc(dev):
+ desc = "Network Interface"
+
+ if dev == '' or dev is None:
+ return desc
+
+ bus = dbus.SystemBus()
+ nm = bus.get_object(NM_SERVICE, NM_MANAGER_PATH)
+ devlist = nm.get_dbus_method("GetDevices")()
+
+ for path in devlist:
+ device = bus.get_object(HAL_SERVICE, path)
+ device_iface = dbus.Interface(device, HAL_DEVICE_IFACE)
+ device_props = device_iface.get_dbus_method("GetAllProperties")()
+
+ if dev == device_props['net.interface']:
+ if device_props.has_key('info.product'):
+ if device_props.has_key('info.vendor'):
+ desc = "%s %s" % (device_props['info.product'],
+ device_props['info.vendor'],)
+ else:
+ desc = device_props['info.product']
+ else:
+ desc = device_props['info.udi']
+
+ return desc
+
+ return desc
+
# Determine if a network device is a wireless device.
def isWireless(dev):
if dev == '' or dev is None: