diff options
| author | Martin Sivak <msivak@redhat.com> | 2007-11-29 11:07:33 +0100 |
|---|---|---|
| committer | Martin Sivak <msivak@redhat.com> | 2007-11-29 11:07:33 +0100 |
| commit | a62614a26e4bb0e99421dc4e9a66ff53121ffaac (patch) | |
| tree | f280fea7d79a35cd3269f6d80f861520f33379cd | |
| parent | d5323c105843804c3d55f572a3a8b9474424da9d (diff) | |
Make it possible to select flow from plugin
| -rw-r--r-- | main.py | 30 | ||||
| -rw-r--r-- | tasker/plugins.py | 12 |
2 files changed, 36 insertions, 6 deletions
@@ -25,7 +25,8 @@ class Flags: def usage(name): print """Usage: - %s [params] [plugin [flow]] + %s [params] + %s [params] -f plugin flow %s [params] -t plugin task params is none or more items from: -c <config file> - select different config file @@ -39,10 +40,12 @@ def usage(name): """ % (name, name) if __name__=="__main__": - params, rest = getopt.getopt(sys.argv[1:], "tc:vl:x:g:P:h", ["task", "config=", "verbose", "log=", "exclude=", "gui=", "plugin-path=", "print-config", "help"]) + params, rest = getopt.getopt(sys.argv[1:], "ftc:vl:x:g:P:h", ["flow", "task", "config=", "verbose", "log=", "exclude=", "gui=", "plugin-path=", "print-config", "help"]) for key,val in params: if key in ("-t", "--task"): Config.operation.mode = "task" + if key in ("-f", "--flow"): + Config.operation.mode = "flow" elif key in ("-c", "--config"): Config.read(val) elif key in ("-v", "--verbose"): @@ -61,6 +64,16 @@ if __name__=="__main__": elif key in ("-h", "--help"): usage(sys.argv[0]) sys.exit(1) + if Config.operation.mode == "flow": + Config.operation.plugin = rest[0] + if len(rest)<=1: + Config.operation.mode = "plugin" + else: + Config.operation.flow = rest[1] + elif Config.operation.mode == "task": + Config.operation.plugin = rest[0] + Config.operation.task = rest[1] + if Flags.print_config: print 76*"-" @@ -69,6 +82,15 @@ if __name__=="__main__": pluginSystem = tasker.plugins.PluginSystem() - for plugin in pluginSystem.list(): - pluginSystem.autorun(plugin) + if Config.operation.mode == "auto": + for plugin in pluginSystem.list(): + pluginSystem.autorun(plugin) + elif Config.operation.mode == "flow": + pluginSystem.autorun(Config.operation.plugin, flow = Config.operation.flow) + elif Config.operation.mode == "plugin": + pluginSystem.autorun(Config.operation.plugin) + elif Config.operation.mode == "task": + pass + else: + print "Incorrect task specified\n" diff --git a/tasker/plugins.py b/tasker/plugins.py index dee5602..1a11a97 100644 --- a/tasker/plugins.py +++ b/tasker/plugins.py @@ -276,15 +276,23 @@ class PluginSystem(object): """Return the list of imported plugins""" return self._plugins.keys() - def autorun(self, plugin): + def autorun(self, plugin, flow = None): """Perform automated run of plugin""" pklass = self._plugins[plugin].get_plugin() #get top level class of plugin Logger.info("Plugin information...") Logger.info("name:%s , version:%s , author:%s " % pklass.info()) flows = pklass.getFlows() Logger.info("Provided flows : %s " % flows) - flowName = pklass.default_flow + if flow==None: + flowName = pklass.default_flow + else: + flowName = flow + Logger.info("Using %s flow" % flowName) + if flowName not in flows: + Logger.error("Flow %s does not exist in plugin %s", flowName, plugin) + return + p = pklass(flowName) for (step, rv) in p: #autorun all the needed steps Logger.info("Running step %s in plugin %s ...", step, plugin) |
