commit aa0bbb4af915f49247efed886a438d243a751c2e
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jul 19 14:16:44 2013 +0200
NetTestSlave: method set_device_down detects NM
This method is automatically called by the controller when initializing
interfaces before they are configured.
When the interface is managed by NM calling ip link set <if> down will
make NM see it as unavailable to repair this we had to set the if back
to up before using NM. Instead when NM is present we will disconnect the
device through the dbus interface.
I didn't remove the code that "resets" the interface if it's
unavailable
before using NM, just in case there will be similar problems in the
future.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NetTestSlave.py | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 77ad679..4be56ce 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -17,6 +17,7 @@ import os
import sys, traceback
import datetime
import socket
+import dbus
from time import sleep
from xmlrpclib import Binary
from tempfile import NamedTemporaryFile
@@ -116,7 +117,26 @@ class SlaveMethods:
devs = self.get_devices_by_hwaddr(hwaddr)
for dev in devs:
- exec_cmd("ip link set %s down" % dev["name"])
+ if check_process_running("NetworkManager") and\
+ self._config.get_option("environment",
"use_nm"):
+ bus = dbus.SystemBus()
+ nm_obj = bus.get_object("org.freedesktop.NetworkManager",
+ "/org/freedesktop/NetworkManager")
+ nm_if = dbus.Interface(nm_obj,
"org.freedesktop.NetworkManager")
+ dev_obj_path = nm_if.GetDeviceByIpIface(dev["name"])
+ dev_obj = bus.get_object("org.freedesktop.NetworkManager",
+ dev_obj_path)
+ dev_props = dbus.Interface(dev_obj,
+ "org.freedesktop.DBus.Properties")
+ if dev_props.Get("org.freedesktop.NetworkManager.Device",
+ "ActiveConnection") != "/":
+ dev_if = dbus.Interface(dev_obj,
+
"org.freedesktop.NetworkManager.Device")
+ logging.debug("Disconnecting device %s: %s" %
+ (dev["name"], dev_obj_path))
+ dev_if.Disconnect()
+ else:
+ exec_cmd("ip link set %s down" % dev["name"])
return True
Show replies by date