From: Ondrej Lichtner <olichtne(a)redhat.com>
Splitting the old set_recipe slave method into two smaller
prepare_machine and start_recipe methods that have the same end result
but are required to be done separately for slaves that a tester connects
to during test execution.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Controller.py | 8 +++++---
lnst/Controller/Machine.py | 18 +++++++++---------
lnst/Slave/NetTestSlave.py | 4 +++-
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/lnst/Controller/Controller.py b/lnst/Controller/Controller.py
index 00b15d9..d1ccf61 100644
--- a/lnst/Controller/Controller.py
+++ b/lnst/Controller/Controller.py
@@ -154,8 +154,8 @@ class Controller(object):
host = getattr(self._hosts, m_id)
machine.set_id(m_id)
- self._prepare_machine(machine, recipe)
machine.set_mapped(True)
+ self._prepare_machine(machine)
for if_id, i in m["interfaces"].items():
host._map_device(if_id, i)
@@ -169,12 +169,14 @@ class Controller(object):
setattr(host, name, new_virt_dev)
new_virt_dev._enable()
- def _prepare_machine(self, machine, recipe):
+ machine.start_recipe(recipe)
+
+ def _prepare_machine(self, machine):
self._log_ctl.add_slave(machine.get_id())
machine.set_mac_pool(self._mac_pool)
machine.set_network_bridges(self._network_bridges)
- machine.set_recipe(recipe)
+ machine.prepare_machine()
def _cleanup_slaves(self):
if self._machines == None:
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index bdfbc1e..042d8e2 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -240,18 +240,13 @@ class Machine(object):
self._slave_desc = slave_desc
- def set_recipe(self, recipe):
- """ Reserves the machine for the specified recipe
-
- Also sends Device classes from the controller and initializes the
- InterfaceManager on the Slave and builds the device database.
- """
- self._recipe = recipe
- recipe_name = recipe.__class__.__name__
- self.rpc_call("set_recipe", recipe_name)
+ def prepare_machine(self):
+ self.rpc_call("prepare_machine")
self._send_device_classes()
self.rpc_call("init_if_manager")
+ self._device_database = {}
+
devices = self.rpc_call("get_devices")
for ifindex, dev in devices.items():
remote_dev = RemoteDevice(Device)
@@ -261,6 +256,11 @@ class Machine(object):
self._device_database[ifindex] = remote_dev
+ def start_recipe(self, recipe):
+ self._recipe = recipe
+ recipe_name = recipe.__class__.__name__
+ self.rpc_call("start_recipe", recipe_name)
+
def _send_device_classes(self):
classes = []
for cls_name, cls in device_classes:
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index f98db6c..75c194b 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -108,13 +108,15 @@ class SlaveMethods:
return ("hello", slave_desc)
- def set_recipe(self, recipe_name):
+ def prepare_machine(self):
self.machine_cleanup()
self.restore_nm_option()
self._cache.del_old_entries()
self.reset_file_transfers()
+ return True
+ def start_recipe(self, recipe_name):
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
self._log_ctl.set_recipe(recipe_name, expand=date)
sleep(1)
--
2.17.0