summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2008-07-16 13:05:02 -0400
committerAdrian Likins <alikins@redhat.com>2008-07-16 13:05:02 -0400
commitcb311639535aa5a1bf80bfeb3cbf1954df472c5c (patch)
treeecbea965cf5abc4a3a90cbc0b0c4f9464c73334b /scripts
parent139d9ab8bc7deae4c1167bc5da1ffb478c433037 (diff)
downloadfunc-cb311639535aa5a1bf80bfeb3cbf1954df472c5c.tar.gz
func-cb311639535aa5a1bf80bfeb3cbf1954df472c5c.tar.xz
func-cb311639535aa5a1bf80bfeb3cbf1954df472c5c.zip
func-transmit: handle lists of client globs. Not sure this is the correct
approach, but it seems to mostly work for now test_func_transmit.py: more test cases for func-transmit
Diffstat (limited to 'scripts')
-rw-r--r--scripts/func-transmit21
1 files changed, 18 insertions, 3 deletions
diff --git a/scripts/func-transmit b/scripts/func-transmit
index e43714f..677b1a6 100644
--- a/scripts/func-transmit
+++ b/scripts/func-transmit
@@ -30,8 +30,10 @@ method: run
parameters: "/bin/echo Hello World"
"""
+import string
import sys
import distutils.sysconfig
+import optparse
import func.yaml as yaml # FIXME: need to subpackage this as part of Func
import func.overlord.func_command as func_command
@@ -44,12 +46,25 @@ params = yaml.load(input).next()
# scan arguments
+def is_a_list(item):
+ if type(item) in [type([]), type(())]:
+ return True
+ return False
+
+# slightly odd, but we expect clients to be a string we parse
+# out later (glob and group expansion, etc). So if it is a list,
+# flatten it into a string.
clients = params.get('clients', "*")
+if is_a_list(clients):
+ clients = string.join(clients,';')
+
+
method = params.get('method','unknown')
if method == "list_minions":
- server_spec = "*"
- minion_set = fc.Minions(server_spec)
+ # clients will default to * if not specified, and specifing is a good
+ # way to see who is in what group, etc, so pass it though
+ minion_set = fc.Minions(clients)
servers = minion_set.get_all_hosts()
servers.sort()
results = servers
@@ -68,7 +83,7 @@ else:
method_handle = getattr(module_handle, method)
if parameters is not None:
# listify if we get something thats not a list
- if type(parameters) not in [type([]), type(())]:
+ if not is_a_list(parameters):
parameters = [parameters]
results = method_handle(*parameters)
else: