From: Ondrej Lichtner <olichtne(a)redhat.com>
This patch adds detection of NM to the NetConfigDevice helper functions.
So when NM is running the classes in NmConfigDevice are used, instead of
those in NetConfigDevice.
I also changed the logged messages in NetTestSlave from error to warning
level, and reworded it so that it is obvious that the implementation is
highly experimental.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/NetConfigDevice.py | 20 ++++++++++++++++----
lnst/Slave/NetTestSlave.py | 8 ++++----
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py
index d9806db..b0333d5 100644
--- a/lnst/Slave/NetConfigDevice.py
+++ b/lnst/Slave/NetConfigDevice.py
@@ -17,6 +17,8 @@ import sys
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
+
class NetConfigDeviceGeneric:
'''
@@ -298,14 +300,24 @@ def NetConfigDevice(netdev, config):
'''
Class dispatcher
'''
- return type_class_mapping[netdev["type"]](netdev, config)
+ if check_process_running("NetworkManager"):
+ return nm_type_class_mapping[netdev["type"]](netdev, config)
+ else:
+ return type_class_mapping[netdev["type"]](netdev, config)
def NetConfigDeviceType(dev_type):
'''
Class dispatcher for classmethods
'''
- return type_class_mapping[dev_type]
+ if check_process_running("NetworkManager"):
+ return nm_type_class_mapping[dev_type]
+ else:
+ return type_class_mapping[dev_type]
def NetConfigDeviceAllCleanup():
- for dev_type in type_class_mapping:
- NetConfigDeviceType(dev_type).type_cleanup()
+ if check_process_running("NetworkManager"):
+ for dev_type in nm_type_class_mapping:
+ NetConfigDeviceType(dev_type).type_cleanup()
+ else:
+ for dev_type in type_class_mapping:
+ NetConfigDeviceType(dev_type).type_cleanup()
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index f3a321a..e7de8ac 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -70,10 +70,10 @@ class SlaveMethods:
sleep(1)
if check_process_running("NetworkManager"):
- logging.error("=============================================")
- logging.error("NetworkManager is running on a slave machine!")
- logging.error("This might effect test results!")
- logging.error("=============================================")
+ logging.warning("=============================================")
+ logging.warning("NetworkManager is running on a slave machine!")
+ logging.warning("Support of NM is still experimental!")
+ logging.warning("=============================================")
return "hello"
def bye(self):
--
1.8.1.4