summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
Diffstat (limited to 'func')
-rwxr-xr-xfunc/overlord/client.py15
-rw-r--r--func/overlord/cmd_modules/call.py18
2 files changed, 26 insertions, 7 deletions
diff --git a/func/overlord/client.py b/func/overlord/client.py
index 4e7ed27..a52aefa 100755
--- a/func/overlord/client.py
+++ b/func/overlord/client.py
@@ -134,6 +134,7 @@ class Client(object):
self.interactive = interactive
self.noglobs = noglobs
self.nforks = nforks
+
self.servers = expand_servers(self.server_spec,port=self.port,
noglobs=self.noglobs,verbose=self.verbose)
@@ -215,10 +216,18 @@ class Client(object):
return (server_name, retval)
if not self.noglobs:
- results = forkbomb.batch_run(self.servers, process_server,nforks)
+ if self.nforks > 1:
+ # using forkbomb module to distribute job over multiple threads
+ results = forkbomb.batch_run(self.servers, process_server,nforks)
+ else:
+ # no need to go through the fork code, we can do this directly
+ results = {}
+ for x in self.servers:
+ (nkey,nvalue) = process_server(0, 0, x)
+ results[nkey] = nvalue
else:
- # just call the handler without the forkbomb code in play
- self.process_server(0, 0, None)
+ # no need to go through the fork code, we can do this directly
+ self.process_server(0, 0, self.server)
return results
diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py
index b3484f6..b62131f 100644
--- a/func/overlord/cmd_modules/call.py
+++ b/func/overlord/cmd_modules/call.py
@@ -23,6 +23,7 @@ from func.overlord import command
from func.overlord import client
DEFAULT_PORT = 51234
+DEFAULT_FORKS = 1
class Call(client.command.Command):
name = "call"
@@ -41,6 +42,9 @@ class Call(client.command.Command):
action="store_true")
self.parser.add_option("-p", "--port", dest="port",
default=DEFAULT_PORT)
+ self.parser.add_option("-f", "--forks", dest="forks",
+ help="how many parallel processes? (default 1)",
+ default=DEFAULT_FORKS)
def handleOptions(self, options):
self.options = options
@@ -85,9 +89,15 @@ class Call(client.command.Command):
# I kind of feel like we shouldn't be parsing args here, but I'm
# not sure what the write place is -al;
- self.module = args[0]
- self.method = args[1]
- self.method_args = args[2:]
+ self.module = args[0]
+ if len(args) > 1:
+ self.method = args[1]
+ else:
+ self.method = None
+ if len(args) > 2:
+ self.method_args = args[2:]
+ else:
+ self.method_args = []
# this could get weird, sub sub classes might be calling this
# this with multiple.parentCommand.parentCommands...
@@ -96,7 +106,7 @@ class Call(client.command.Command):
self.server_spec = self.parentCommand.server_spec
client_obj = client.Client(self.server_spec,port=self.port,interactive=True,
- verbose=self.verbose, config=self.config)
+ verbose=self.verbose, config=self.config, nforks=self.options.forks)
results = client_obj.run(self.module, self.method, self.method_args)
# TO DO: add multiplexer support