commit 23880569317db35a28d37e680821eafa1c856766
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 3 16:00:38 2014 +0100
Task: add HostAPI method sync_resources
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>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Task.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
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. """