diff options
author | David Cantrell <dcantrell@redhat.com> | 2008-10-31 16:19:48 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2008-11-03 09:25:11 -1000 |
commit | 532865b09fea4b72bde3ccd4bfbc134b70d8a6f2 (patch) | |
tree | c44ad4b0dbd13d2c6f2773e32b69d8a1cda3acfc /network.py | |
parent | 340ea253abedbd0d2c38834afd327bb120b66609 (diff) | |
download | anaconda-532865b09fea4b72bde3ccd4bfbc134b70d8a6f2.tar.gz anaconda-532865b09fea4b72bde3ccd4bfbc134b70d8a6f2.tar.xz anaconda-532865b09fea4b72bde3ccd4bfbc134b70d8a6f2.zip |
Make sure we look up the IP address for the correct device (#469439)
The VNC launch code in vnc.py needed an update to work better with
NetworkManager. When collecting the hostname and IP address, it was
assuming the first device in the netdevices list is our active NIC,
which may or may not be true.
Added getActiveNetDevs() in network.py to ask NetworkManager for a
list of all currently configured interfaces. Return a list of
device names. A list seems a bit pointless, but I'd like to have
this in place now for future improvements where we might need to
handle more than one active NIC during installation. After all,
NM can do that.
The message reported by anaconda once VNC is ready will contain the
FQDN:DISPLAY_NUMBER (IP ADDRESS), if it can. If it can't find your
IP address, it leaves that out. If it can't find your hostname, it
also leaves that out.
Diffstat (limited to 'network.py')
-rw-r--r-- | network.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/network.py b/network.py index e7392cc09..c986cda7c 100644 --- a/network.py +++ b/network.py @@ -202,6 +202,36 @@ def hasActiveNetDev(): except: return False +# Return a list of device names (e.g., eth0) for all active devices. +# Returning a list here even though we will almost always have one +# device. NM uses lists throughout its D-Bus communication, so trying +# to follow suit here. Also, if this uses a list now, we can think +# about multihomed hosts during installation later. +def getActiveNetDevs(): + active_devs = set() + + bus = dbus.SystemBus() + nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH) + nm_props_iface = dbus.Interface(nm, isys.DBUS_PROPS_IFACE) + + active_connections = nm_props_iface.Get(isys.NM_MANAGER_IFACE, "ActiveConnections") + + for connection in active_connections: + active_connection = bus.get_object(isys.NM_SERVICE, connection) + active_connection_props_iface = dbus.Interface(active_connection, isys.DBUS_PROPS_IFACE) + devices = active_connection_props_iface.Get(isys.NM_MANAGER_IFACE, 'Devices') + + for device_path in devices: + device = bus.get_object(isys.NM_SERVICE, device_path) + device_props_iface = dbus.Interface(device, isys.DBUS_PROPS_IFACE) + + interface_name = device_props_iface.Get(isys.NM_MANAGER_IFACE, 'Interface') + active_devs.add(interface_name) + + ret = list(active_devs) + ret.sort() + return ret + class NetworkDevice(SimpleConfigFile): def __str__(self): s = "" |