[PATCH] Added --basic output option to call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds another output option to call, which does very minimal
formatting on the output.  Essentially, it prints a header (containing the
minion name and return value of the command), and then prints the returned
stdout data.  If the stderr results aren't empty, it will print those as
well.

Sample output:

$ func "xen*" call --basic command run "md5sum /etc/shadow"
**** Results for xen2 (return value: 0) ****
7ac334c1470f6f3a335fbc2b2c911a62  /etc/shadow

**** Results for xen1 (return value: 0) ****
cb4358f028203621571f855ca670d7fd  /etc/shadow

$ func "xen*" call --basic command run "md5sum /etc/blah"
**** Results for xen2 (return value: 1) ****
**** Output to STDERR ****
md5sum: /etc/blah: No such file or directory

**** Results for xen1 (return value: 1) ****
**** Output to STDERR ****
md5sum: /etc/blah: No such file or directory


This makes the output a bit more readable for the standard sys-admin.

I'm not sure if you guys have a separate devel branch, so this patch was
made against master.  If you have a devel branch and want me to patch
against that, just point me towards the git repo url for it.

Thanks,

James Cammarata

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

From 9daf67d8ce072158d1ede7a7b4410efc599eacdf Mon Sep 17 00:00:00 2001
From: James Cammarata <jimi@xxxxxxxx>
Date: Wed, 1 Apr 2009 15:35:04 -0500
Subject: [PATCH] Added --basic output option to call

---
 func/overlord/cmd_modules/call.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py
index 59a2997..89c5263 100644
--- a/func/overlord/cmd_modules/call.py
+++ b/func/overlord/cmd_modules/call.py
@@ -50,6 +50,9 @@ class Call(base_command.BaseCommand):
         self.parser.add_option("-p", "--pickle", dest="pickle",
                                help="output return data in python pickle format",
                                action="store_true")
+        self.parser.add_option("-b", "--basic", dest="basic",
+                               help="output return data with minimal, basic formating",
+                               action="store_true")
         self.parser.add_option("-f", "--forks", dest="forks",
                                help="how many parallel processes?  (default 1)",
                                default=self.forks)
@@ -107,6 +110,16 @@ class Call(base_command.BaseCommand):
             import pickle
             return pickle.dumps(data)
 
+        if self.options.basic:
+            output = ""
+            (minion,results) = data
+            output += '**** Results for %s (return value: %d) ****\n' % (minion, results[0])
+            output += results[1]
+            if results[2].strip() not in (None, ''):
+                output += '**** Output to STDERR ****\n'
+                output += results[2]
+            return output
+
         return  pprint.pformat(data)
 
     def do(self, args):
-- 
1.5.5.1

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux