add_host() is used in PyRecipe in setup phase, returns
HostAPI object and adds entry to mreq dictionary
id is generated by sequentially get_m_id()
init_hosts() is used to bind HostAPI objects with Machine objects,
because HostAPI objects are created sooner than Machine objects
(it was the other way around in XML recipes)
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Task.py | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index cb52921..32e0db9 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -49,6 +49,13 @@ def breakpoint():
return
raw_input("Press enter to continue: ")
+def add_host(params=None):
+ m_id = ctl.gen_m_id()
+ ctl.mreq[m_id] = {'interfaces' : {}, 'params' : {}}
+ handle = HostAPI(ctl, m_id)
+ ctl.add_host(m_id, handle)
+ return handle
+
class TaskError(Exception): pass
class ControllerAPI(object):
@@ -57,6 +64,7 @@ class ControllerAPI(object):
def __init__(self, ctl, hosts):
self._ctl = ctl
self._result = True
+ self._m_id_seq = 0
self.mreq = {}
self._perf_repo_api = PerfRepoAPI()
@@ -65,8 +73,17 @@ class ControllerAPI(object):
def get_mreq(self):
return self.mreq
+
+ def gen_m_id(self):
+ self._m_id_seq += 1
+ return "m_id_%s" % self._m_id_seq
+
+ def add_host(self, host_id, handle):
+ self._hosts[host_id] = handle
+
+ def init_hosts(self, hosts):
for host_id, host in hosts.iteritems():
- self._hosts[host_id] = HostAPI(self, host_id, host)
+ self._hosts[host_id].init_host(host)
def _run_command(self, command):
"""
--
2.4.11