From: Ondrej Lichtner <olichtne(a)redhat.com>
This commit moves the call of slave cleanup from the server loop to the
rpc method hello() as it makes more sense to do the cleanup whenever a
new session is started by the controller.
The rest of the patch changes related code on the controller side, this
is also related to the previous commit that removed the --cleanup option
and replaced it with --config.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Machine.py | 5 +----
lnst/Controller/NetTestController.py | 5 ++---
lnst/Slave/NetTestSlave.py | 12 +++++-------
3 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index 96f3657..6a870ef 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -113,7 +113,7 @@ class Machine(object):
return result
- def configure(self, recipe_name, do_cleanup=False):
+ def configure(self, recipe_name):
""" Prepare the machine
Calling this method will initialize the rpc connection to the
@@ -135,9 +135,6 @@ class Machine(object):
"to machine %s, handshake failed!" % hostname
raise Machine(msg)
- if do_cleanup:
- self._rpc_call("machine_cleanup")
-
for iface in self._interfaces:
iface.initialize()
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 5404284..3379aef 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -44,9 +44,8 @@ def ignore_event(**kwarg):
pass
class NetTestController:
- def __init__(self, recipe_path, log_ctl, cleanup=False,
+ def __init__(self, recipe_path, log_ctl,
res_serializer=None, pool_checks=True):
- self._docleanup = cleanup
self._res_serializer = res_serializer
self._remote_capture_files = {}
self._log_ctl = log_ctl
@@ -204,7 +203,7 @@ class NetTestController:
machine.set_network_bridges(self._network_bridges)
recipe_name = os.path.basename(self._recipe_path)
- machine.configure(recipe_name, self._docleanup)
+ machine.configure(recipe_name)
machine.sync_resources(self._resource_table)
def _prepare_interface(self, m_id, iface_xml_data):
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 94a92c0..cbb3958 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -83,11 +83,15 @@ class SlaveMethods:
self.ctl_clean_exit = True
def hello(self, recipe_path):
+ if not self.ctl_clean_exit:
+ self._methods.machine_cleanup()
+ self._methods.ctl_clean_exit = True
+
logging.info("Recieved a controller connection.")
self.clear_resource_table()
self._cache.del_old_entries()
self.reset_file_transfers()
- self.ctl_clean_exit = False
+ self._ctl_clean_exit = False
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
self._log_ctl.set_recipe(recipe_path, expand=date)
@@ -451,8 +455,6 @@ class NetTestSlave:
self._log_ctl = log_ctl
- self._start = True
-
self._nl_socket = NetlinkSocket(family=NETLINK_ROUTE)
self._nl_socket.bind(RTNL_GROUPS)
self._server_handler.add_connection('netlink', self._nl_socket)
@@ -461,13 +463,9 @@ class NetTestSlave:
while not self._finished:
if self._server_handler.get_ctl_sock() == None:
self._log_ctl.cancel_connection()
- if not self._start and not self._methods.ctl_clean_exit:
- self._methods.machine_cleanup()
- self._methods.ctl_clean_exit = True
try:
logging.info("Waiting for connection.")
self._server_handler.accept_connection()
- self._start = False
except socket.error:
continue
self._log_ctl.set_connection(
--
1.8.3.1