Wait for all devices activated by nm-c-e (#520146).
We used to activate just one device when enabling network,
so it was ok to use waitForConnection (wait just for any
connection). Now that more devices can be set to be activated
in nm-c-e (by checking [] Connect automatically), we should
wait for all devices activated by nm-c-e this way, otherwise
we can fail with traceback in next steps reading device
configuration.
---
gui.py | 40 ++++++++++++++++++++++++++++------------
isys/isys.py | 1 +
network.py | 29 ++++++++++++++++++++++++++++-
3 files changed, 57 insertions(+), 13 deletions(-)
diff --git a/gui.py b/gui.py
index f7ee82f..ccb0690 100755
--- a/gui.py
+++ b/gui.py
@@ -1006,35 +1006,51 @@ class InstallInterface(InstallInterfaceBase):
self.anaconda.network.update()
if just_setup:
- # TODORV check which devices were actually activated by nmce
- # and which we should wait for (the case for more than one
- # device)
- onboot_devs = self.anaconda.network.getOnbootIfaces()
- if onboot_devs:
- install_device = onboot_devs[0]
+ waited_devs = self.anaconda.network.getOnbootIfaces()
+ else:
+ waited_devs = [install_device]
self.anaconda.network.write()
- if install_device:
+ if waited_devs:
w = WaitWindow(_("Waiting for NetworkManager"),
- _("Waiting for NetworkManager to get connection."))
- networkEnabled = self.anaconda.network.waitForConnection()
- if not networkEnabled and not just_setup:
- self._handleNetworkError(install_device)
+ _("Waiting for NetworkManager to activate "
+ "these devices: %s" % ",".join(waited_devs)))
+ failed_devs = self.anaconda.network.waitForDevicesActivation(wai ted_devs)
w.pop()
+ networkEnabled = network.hasActiveNetDev()
+
+ if just_setup:
+ if failed_devs:
+ self._handleDeviceActivationFail(failed_devs)
+ else:
+ if not networkEnabled:
+ self._handleNetworkError(install_device)
+
if just_setup:
break
class IPError(Exception):
pass
@@ -762,6 +763,32 @@ class Network:
f.close()
+ def waitForDevicesActivation(self, devices):
+ waited_devs_props = {}
+
+ bus = dbus.SystemBus()
+ nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH)
+ device_paths = nm.get_dbus_method("GetDevices")()
+ for device_path in device_paths:
+ device = bus.get_object(isys.NM_SERVICE, device_path)
+ device_props_iface = dbus.Interface(device, isys.DBUS_PROPS_IFACE)
+ iface = str(device_props_iface.Get(isys.NM_MANAGER_IFACE, "Interface"))
+ if iface in devices:
+ waited_devs_props[iface] = device_props_iface
+
+ i = 0
+ while True:
+ for dev, device_props_iface in waited_devs_props.items():
+ state = device_props_iface.Get(isys.NM_MANAGER_IFACE, "State")
+ if state == isys.NM_DEVICE_STATE_ACTIVATED:
+ waited_devs_props.pop(dev)
+ if len(waited_devs_props) == 0:
+ return []
+ if i >= CONNECTION_TIMEOUT:
+ return waited_devs_props.keys()
+ i += 1
+ time.sleep(1)
+
# write out current configuration state and wait for NetworkManager
# to bring the device up, watch NM state and return to the caller
# once we have a state
@@ -771,7 +798,7 @@ class Network:
props = dbus.Interface(nm, isys.DBUS_PROPS_IFACE)
i = 0
- while i < 45:
+ while i < CONNECTION_TIMEOUT:
state = props.Get(isys.NM_SERVICE, "State")
if int(state) == isys.NM_STATE_CONNECTED:
isys.resetResolv()
--
1.6.0.6
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list