From: Ondrej Lichtner <olichtne(a)redhat.com>
This method provides new functionality to the python tasks. With this
the user can specify exactly which resources should be synchronized to
a single slave machine.
Since in case of python tasks all resources are automatically
synchronized this method doesn't have any practical meaning yet. This
will be changed in the following commits.
Example of use:
m1 = ctl.get_host("1")
m1.sync_resources(modules=["IcmpPing"], tools=["multicast"])
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Task.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index c933cfb..b028231 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -229,6 +229,27 @@ class HostAPI(object):
iface = self._m.get_interface(interface_id)
return Prefix(iface, addr_number)
+ def sync_resources(self, modules=[], tools=[]):
+ res_table = self._ctl._ctl._resource_table
+ sync_table = {'module': {}, 'tools': {}}
+ for mod in modules:
+ if mod in res_table['module']:
+ sync_table['module'][mod] = res_table['module'][mod]
+ else:
+ msg = "Module '%s' not found on the controller"\
+ % mod
+ raise TaskError(msg, cmd)
+
+ for tool in tools:
+ if tool in res_table['tools']:
+ sync_table['tools'][tool] = res_table['tools'][tool]
+ else:
+ msg = "Tool '%s' not found on the controller"\
+ % tool
+ raise TaskError(msg, cmd)
+
+ self._m.sync_resources(sync_table)
+
class ModuleAPI(object):
""" An API class representing a module. """
--
1.8.5.3