From a5929a01854dd53828e10008b68763c3959632ec Mon Sep 17 00:00:00 2001 From: "Krzysztof A. Adamski" Date: Sun, 29 Jun 2008 14:43:20 -0400 Subject: Add support for forcing some long running methods to be called in async mode from command line. --- etc/async_methods.conf | 2 ++ func.spec | 1 + func/overlord/cmd_modules/call.py | 9 +++++++++ setup.py | 1 + 4 files changed, 13 insertions(+) create mode 100644 etc/async_methods.conf diff --git a/etc/async_methods.conf b/etc/async_methods.conf new file mode 100644 index 0000000..1d8984d --- /dev/null +++ b/etc/async_methods.conf @@ -0,0 +1,2 @@ +[main] +force_async = command.run, yumcmd.update, virt.install diff --git a/func.spec b/func.spec index e8f6d23..9840ce9 100644 --- a/func.spec +++ b/func.spec @@ -60,6 +60,7 @@ rm -fr $RPM_BUILD_ROOT %dir %{_sysconfdir}/%{name}/minion-acl.d/ %dir /etc/func/modules/ %config(noreplace) /etc/func/minion.conf +%config(noreplace) /etc/func/async_methods.conf %config(noreplace) /etc/logrotate.d/func_rotate %dir %{python_sitelib}/func %dir %{python_sitelib}/func/minion diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py index 18af3a6..648bcab 100644 --- a/func/overlord/cmd_modules/call.py +++ b/func/overlord/cmd_modules/call.py @@ -17,13 +17,19 @@ import optparse import pprint import xmlrpclib import time +import sys from func.overlord import client from func.overlord import base_command +from func.config import read_config, BaseConfig, ListOption import func.jobthing as jobthing DEFAULT_FORKS = 1 +config_file = '/etc/func/async_methods.conf' + +class CallConfig(BaseConfig): + force_async = ListOption('') class Call(base_command.BaseCommand): name = "call" @@ -126,6 +132,9 @@ class Call(base_command.BaseCommand): # or some sort of shared datastruct? # self.getOverlord() + call_config = read_config(config_file, CallConfig) + if self.method and (self.module+"."+self.method in call_config.force_async): + self.options.async=True self.interactive = False self.async = self.options.async diff --git a/setup.py b/setup.py index 2d1d971..bba37f8 100644 --- a/setup.py +++ b/setup.py @@ -53,6 +53,7 @@ if __name__ == "__main__": ], data_files = [(initpath, ["init-scripts/funcd"]), (etcpath, ["etc/minion.conf"]), + (etcpath, ["etc/async_methods.conf"]), (manpath, ["docs/func.1.gz"]), (manpath, ["docs/func-inventory.1.gz"]), (manpath, ["docs/funcd.1.gz"]), -- cgit