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.
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