commit b59f287af66a2350979ea86a32458e227e71ba8e Author: Ondrej Lichtner olichtne@redhat.com Date: Fri Mar 29 14:03:22 2013 +0100
NetTestController: fix slave cleanup
This commit moves the rpc_call of method "bye" so that it is the last method called when communicating with the slave. It also adds a call of the new "kill_cmds" method.
Finally I fixed the disconnect_slave method because it wasn't doing anything usefull (the code was deleted somewhere in git history), now it will properly disconnect the slaves.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com
lnst/Controller/NetTestController.py | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) --- diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py index 89470fb..645ed78 100644 --- a/lnst/Controller/NetTestController.py +++ b/lnst/Controller/NetTestController.py @@ -323,10 +323,14 @@ class NetTestController: return for machine_id in self._recipe["machines"]: info = self._get_machineinfo(machine_id) - if "configured_interfaces" not in info: + + if self._msg_dispatcher.get_connection(machine_id): + self._rpc_call(machine_id, "kill_cmds") + else: continue
- self._rpc_call(machine_id, "bye") + if "configured_interfaces" not in info: + continue
for if_id in reversed(info["configured_interfaces"]): self._rpc_call(machine_id, 'deconfigure_interface', if_id) @@ -353,8 +357,11 @@ class NetTestController: def _disconnect_slaves(self): if 'machines' not in self._recipe: return + for machine_id in self._recipe["machines"]: - info = self._get_machineinfo(machine_id) + if self._msg_dispatcher.get_connection(machine_id): + self._rpc_call(machine_id, "bye") + self._msg_dispatcher.disconnect_slave(machine_id)
def _prepare(self): # All the perparations are made within the recipe parsing @@ -693,3 +700,8 @@ class MessageDispatcher(ConnectionHandler): log_record['address'] = '(' + address + ')' record = logging.makeLogRecord(log_record) logger.handle(record) + + def disconnect_slave(self, machine_id): + del self._slaves[machine_id] + soc = self.get_connection(machine_id) + self.remove_connection(soc)
lnst-developers@lists.fedorahosted.org