commit 7922c4e2b3f5f38ec6f5d0fd5bc5a75e24a5907c
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Jul 26 13:08:48 2013 +0200
Slave: use function is_nm_managed
This commit adds the usage of the new function to the appropriate
places. Now instead of just checking if NM is running and if the
variable use_nm is set, we also check if the device is actually managed
by NM and can therefore be configured by it.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Slave/NetConfig.py | 2 +-
lnst/Slave/NetConfigDevice.py | 17 ++++++++++-------
lnst/Slave/NetTestSlave.py | 6 ++++--
3 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/lnst/Slave/NetConfig.py b/lnst/Slave/NetConfig.py
index a9c3729..d159321 100644
--- a/lnst/Slave/NetConfig.py
+++ b/lnst/Slave/NetConfig.py
@@ -81,7 +81,7 @@ class NetConfig:
dev_type = config["type"]
if not dev_type in self._get_used_types():
logging.info("Cleaning up '%s' device class.", dev_type)
- NetConfigDeviceType(dev_type).type_cleanup()
+ NetConfigDeviceType(config, self._config).type_cleanup()
def get_interface_config(self, if_id):
return self._config[if_id]
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py
index c66fa50..27f4cb3 100644
--- a/lnst/Slave/NetConfigDevice.py
+++ b/lnst/Slave/NetConfigDevice.py
@@ -18,6 +18,7 @@ from lnst.Common.ExecCmd import exec_cmd
from lnst.Slave.NetConfigCommon import get_slaves, get_option, get_slave_option
from lnst.Common.Utils import kmod_in_use, bool_it
from lnst.Slave.NmConfigDevice import type_class_mapping as nm_type_class_mapping
+from lnst.Slave.NmConfigDevice import is_nm_managed
from lnst.Common.Utils import check_process_running
from lnst.Common.Config import lnst_config
@@ -298,26 +299,28 @@ def NetConfigDevice(netdev, config):
Class dispatcher
'''
if check_process_running("NetworkManager") and \
- lnst_config.get_option("environment", "use_nm"):
+ lnst_config.get_option("environment", "use_nm") and \
+ is_nm_managed(netdev, config):
return nm_type_class_mapping[netdev["type"]](netdev, config)
else:
return type_class_mapping[netdev["type"]](netdev, config)
-def NetConfigDeviceType(dev_type):
+def NetConfigDeviceType(netdev, config):
'''
Class dispatcher for classmethods
'''
if check_process_running("NetworkManager") and \
- lnst_config.get_option("environment", "use_nm"):
- return nm_type_class_mapping[dev_type]
+ lnst_config.get_option("environment", "use_nm") and \
+ is_nm_managed(netdev, config):
+ return nm_type_class_mapping[netdev["type"]]
else:
- return type_class_mapping[dev_type]
+ return type_class_mapping[netdev["type"]]
def NetConfigDeviceAllCleanup():
if check_process_running("NetworkManager") and \
lnst_config.get_option("environment", "use_nm"):
for dev_type in nm_type_class_mapping:
- NetConfigDeviceType(dev_type).type_cleanup()
+ nm_type_class_mapping[dev_type].type_cleanup()
else:
for dev_type in type_class_mapping:
- NetConfigDeviceType(dev_type).type_cleanup()
+ type_class_mapping[dev_type].type_cleanup()
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index af9ab90..272cb76 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -32,6 +32,7 @@ from lnst.Common.NetTestCommand import NetTestCommandContext
from lnst.Common.NetTestCommand import CommandException, NetTestCommand
from lnst.Slave.NetConfig import NetConfig
from lnst.Slave.NetConfigDevice import NetConfigDeviceAllCleanup
+from lnst.Slave.NmConfigDevice import is_nm_managed_by_name
from lnst.Common.Utils import check_process_running
from lnst.Common.ConnectionHandler import recv_data, send_data
from lnst.Common.ConnectionHandler import ConnectionHandler
@@ -117,8 +118,9 @@ class SlaveMethods:
devs = self.get_devices_by_hwaddr(hwaddr)
for dev in devs:
- if check_process_running("NetworkManager") and\
- lnst_config.get_option("environment", "use_nm"):
+ if check_process_running("NetworkManager") and \
+ lnst_config.get_option("environment", "use_nm") and \
+ is_nm_managed_by_name(dev["name"]):
bus = dbus.SystemBus()
nm_obj = bus.get_object("org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager")
Show replies by date