commit b9bd6c46f0c3026b9c3bf43937251236f28ed0bc
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Aug 13 18:34:51 2014 +0200
NetTestSlave: enable/disable NM on demand
This commit adds 3 new Slave methods:
enable_nm
disable_nm
restore_nm_option
These can be used to manipulate the value of the "use_nm" option, which
controlls whether the slave will use NM for interface configuration.
The patch also adds these methods to the controller class Machine.
This is usefull for network namespaces since NM doesn't support them and
probably never will.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Machine.py | 9 +++++++++
lnst/Slave/NetTestSlave.py | 29 +++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 56566a5..7ef3837 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -365,6 +365,15 @@ class Machine(object):
self._rpc_call("map_resource", res["hash"], res_type,
res_name)
+ def enable_nm(self):
+ return self._rpc_call("enable_nm")
+
+ def disable_nm(self):
+ return self._rpc_call("disable_nm")
+
+ def restore_nm_option(self):
+ return self._rpc_call("restore_nm_option")
+
def __str__(self):
return "[Machine hostname(%s) libvirt_domain(%s) interfaces(%d)]" % \
(self._hostname, self._libvirt_domain, len(self._interfaces))
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 0b00a68..2cc0cca 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -59,8 +59,11 @@ class SlaveMethods:
self._resource_table = {'module': {}, 'tools': {}}
+ self._bkp_nm_opt_val = lnst_config.get_option("environment",
"use_nm")
+
def hello(self, recipe_path):
self.machine_cleanup()
+ self.restore_nm_option()
logging.info("Recieved a controller connection.")
self.clear_resource_table()
@@ -342,6 +345,32 @@ class SlaveMethods:
file_handle.close()
self._copy_sources = {}
+ def enable_nm(self):
+
logging.warning("====================================================")
+ logging.warning("Enabling use of NetworkManager on controller
request")
+
logging.warning("====================================================")
+ val = lnst_config.get_option("environment", "use_nm")
+ lnst_config.set_option("environment", "use_nm", True)
+ return val
+
+ def disable_nm(self):
+
logging.warning("=====================================================")
+ logging.warning("Disabling use of NetworkManager on controller
request")
+
logging.warning("=====================================================")
+ val = lnst_config.get_option("environment", "use_nm")
+ lnst_config.set_option("environment", "use_nm", False)
+ return val
+
+ def restore_nm_option(self):
+ val = lnst_config.get_option("environment", "use_nm")
+ if val == self._bkp_nm_opt_val:
+ return val
+ logging.warning("=========================================")
+ logging.warning("Restoring use_nm option to original value")
+ logging.warning("=========================================")
+ lnst_config.set_option("environment", "use_nm",
self._bkp_nm_opt_val)
+ return val
+
class ServerHandler(object):
def __init__(self, addr):
self._connection_handler = ConnectionHandler()