Tue, Jan 14, 2014 at 09:46:02PM CET, jpirko(a)redhat.com wrote:
Tue, Jan 14, 2014 at 03:12:56PM CET, jtluka(a)redhat.com wrote:
>NM connections might not be available immediately and in that case an
>activation of such connection will raise DBusException. This patch adds
>a check for the exception and retries to activate connection five times
>with 1 second step. After timeout the exception is passed further.
This looks like one ugly workaround. Why is this really needed? Why
there is a delay? Can't we listen to some dbus signal instead of this
polling?
Yes, you're more than right. I was thinking about it after I sent the
patch and I agree that this should be done prettier.
I'll post another patch once I have it.
>
>Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
>---
> lnst/Slave/NmConfigDevice.py | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
>diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
>index 396dea8..fa8fed4 100644
>--- a/lnst/Slave/NmConfigDevice.py
>+++ b/lnst/Slave/NmConfigDevice.py
>@@ -24,6 +24,7 @@ from lnst.Common.Utils import kmod_in_use, bool_it
> from lnst.Common.NetUtils import scan_netdevs
> from lnst.Common.Utils import check_process_running
> from lnst.Common.Config import lnst_config
>+from dbus.exceptions import DBusException
>
> NM_BUS = "org.freedesktop.NetworkManager"
> OBJ_PRE = "/org/freedesktop/NetworkManager"
>@@ -221,9 +222,19 @@ class NmConfigDeviceGeneric(object):
> except:
> device_obj_path = "/"
>
>- netdev["acon_obj_path"] = nm_if.ActivateConnection(
>- netdev["con_obj_path"],
>- device_obj_path, "/")
>+ timeout = 0
>+ while timeout != 5:
>+ try:
>+ netdev["acon_obj_path"] = nm_if.ActivateConnection(
>+
netdev["con_obj_path"],
>+ device_obj_path,
"/")
>+ break
>+ except DBusException as e:
>+ # connection might not be available yet, wait 1 second
>+ timeout += 1
>+ if timeout == 5:
>+ raise e
>+ time.sleep(1)
>
> logging.debug("Device object path: %s" % device_obj_path)
> logging.debug("Connection object path: %s" %
netdev["con_obj_path"])
>--
>1.8.1.4
>
>_______________________________________________
>LNST-developers mailing list
>LNST-developers(a)lists.fedorahosted.org
>https://lists.fedorahosted.org/mailman/listinfo/lnst-developers