scripts/func-command | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) New commits: commit 8aaaca7c573795b3ad332b9f1b82eea9fa29875a Merge: 334d443... a12fd56... Author: Seth Vidal <skvidal@xxxxxxxxxxxxxxxxx> Date: Fri Feb 18 11:52:26 2011 -0500 Merge branch 'master' of ssh://git.fedorahosted.org/git/func * 'master' of ssh://git.fedorahosted.org/git/func: Added delegate as a default Overlord config option, including placing it in the overlord.conf Adjusted default Overlord class to define delegate as None. The logic behind this is that the Overlord config has a default value of false. If a call plans on overriding the default option of the system, it can do so, thus changing None to True/False. If delegate is passed in as none, then they want the system default. Added delegate and no-delegate as options in func.overlord.scripts.base_func_parser (default to None) Implemented the new delegate cli options inside func-command, the other scripts will need it if accepted Added a line return on the mapfile load error message for delegation for cleaner output. added rhel4/py2.3 sha support into getfile using same method as copyfile diff --cc scripts/func-command index 59f3723,9ab1560..d119ef2 --- a/scripts/func-command +++ b/scripts/func-command @@@ -28,22 -25,8 +28,22 @@@ def main(args) hosts ='*' if opts.host: hosts = ';'.join(opts.host) + + if opts.output_dest: + if opts.output_dest[0] != '/': + opts.output_dest = os.path.realpath(os.path.expanduser(opts.output_dest)) + if not os.path.exists(opts.output_dest): + try: + os.makedirs(opts.output_dest) + except (IOError, OSError), e: + print >> sys.stderr, "Could not make dir %s: %s" % (opts.output_dest, e) + sys.exit(1) + + if not os.access(opts.output_dest, os.W_OK): + print >> sys.stderr, "Cannot write to path %s" % opts.output_dest + sys.exit(1) - fc = func.overlord.client.Client(hosts, timeout=opts.timeout, nforks=opts.forks) + fc = func.overlord.client.Client(hosts, timeout=opts.timeout, nforks=opts.forks, delegate=opts.delegate) print mycmd results = fc.command.run(mycmd) commit 334d4433ae60f5fdd9e3fb7ed138b1119d6d48e4 Author: Seth Vidal <skvidal@xxxxxxxxxxxxxxxxx> Date: Mon Feb 14 13:31:06 2011 -0500 add --output-to-dir option to func-command diff --git a/scripts/func-command b/scripts/func-command index 4d1d522..59f3723 100755 --- a/scripts/func-command +++ b/scripts/func-command @@ -4,6 +4,7 @@ import sys +import os import func.overlord.client from func.overlord.scripts import base_func_parser, handle_base_func_options, errorprint from func.utils import is_error @@ -13,6 +14,8 @@ def main(args): parser = base_func_parser(outputpath=False) parser.add_option('--returncodes', action='store_true', help="prefix each line with the commands returncode") parser.add_option('--oneline', action='store_true', help="output all things as one line - to make grepping easier, will not remove \n's from output of commands, though") + parser.add_option('-o', '--output-to-dir', dest='output_dest', default=None, + help="output each hosts results to a file in a dir named for the host") opts, args = parser.parse_args(args) opts = handle_base_func_options(parser, opts) @@ -25,6 +28,20 @@ def main(args): hosts ='*' if opts.host: hosts = ';'.join(opts.host) + + if opts.output_dest: + if opts.output_dest[0] != '/': + opts.output_dest = os.path.realpath(os.path.expanduser(opts.output_dest)) + if not os.path.exists(opts.output_dest): + try: + os.makedirs(opts.output_dest) + except (IOError, OSError), e: + print >> sys.stderr, "Could not make dir %s: %s" % (opts.output_dest, e) + sys.exit(1) + + if not os.access(opts.output_dest, os.W_OK): + print >> sys.stderr, "Cannot write to path %s" % opts.output_dest + sys.exit(1) fc = func.overlord.client.Client(hosts, timeout=opts.timeout, nforks=opts.forks) @@ -39,6 +56,16 @@ def main(args): errorprint(msg) continue + if opts.output_dest: + fo = open(opts.output_dest + '/' + hn+'.output', 'w') + fo.write(mycmd + '\n') + if opts.returncodes: + fo.write('%s:\nreturn code:%s\n%s\n' % (hn, output[0], output[1])) + else: + fo.write('%s:\n%s\n' % (hn,output[1])) + fo.close() + continue + if opts.oneline: if opts.returncodes: print '%s:%s:%s' % (hn, output[0], output[1]) @@ -50,6 +77,9 @@ def main(args): else: print '%s:\n%s' % (hn, output[1]) + if opts.output_dest: + print "output written to %s" % opts.output_dest + if __name__ == "__main__": sys.exit(main(sys.argv[1:])) _______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list