From fc9702f3d26b3c8ed495b5cf07b42659f35f5188 Mon Sep 17 00:00:00 2001
From: Greg Swift <gregswift@gmail.com>
Date: Tue, 7 Dec 2010 23:05:52 -0600
Subject: [[PATCH]] updated Client call in scripts in scripts/ to include the opts.delegate value.
 Extended the get_host_list method in func-yum and func-ps-compare to accept the opts object to handle the delegation call.


Signed-off-by: Greg Swift <gregswift@gmail.com>
---
 scripts/func-down-hosts        |    2 +-
 scripts/func-find-user         |    2 +-
 scripts/func-grep              |    2 +-
 scripts/func-list-vms-per-host |    4 ++--
 scripts/func-ps-compare        |    8 ++++----
 scripts/func-whatsmyname       |    2 +-
 scripts/func-yum               |   24 ++++++++++++------------
 7 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/scripts/func-down-hosts b/scripts/func-down-hosts
index 3f6b60a..5d5c9f1 100755
--- a/scripts/func-down-hosts
+++ b/scripts/func-down-hosts
@@ -18,7 +18,7 @@ def main(args):
     if opts.host:
         hosts = ';'.join(opts.host)
 
-    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)
 
     results = fc.test.ping()
     offline = []
diff --git a/scripts/func-find-user b/scripts/func-find-user
index 99e037f..14adcea 100755
--- a/scripts/func-find-user
+++ b/scripts/func-find-user
@@ -52,7 +52,7 @@ hosts ='*'
 if opts.host:
     hosts = ';'.join(opts.host)
 
-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)
 
 results = fc.process.grep(username)
 for (hn, output) in results.items():
diff --git a/scripts/func-grep b/scripts/func-grep
index 21d8b18..cdda8f1 100755
--- a/scripts/func-grep
+++ b/scripts/func-grep
@@ -52,7 +52,7 @@ hosts ='*'
 if opts.host:
     hosts = ';'.join(opts.host)
 
-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)
 
 cmd = '/bin/grep %s %s %s' % (opts.grep_options, search_str, ' '.join(search_where))
 print cmd
diff --git a/scripts/func-list-vms-per-host b/scripts/func-list-vms-per-host
index 24689c5..cbbf7b6 100755
--- a/scripts/func-list-vms-per-host
+++ b/scripts/func-list-vms-per-host
@@ -40,7 +40,7 @@ hosts ='*'
 if opts.host:
     hosts = ';'.join(opts.host)
 
-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)
 
 results = fc.system.list_modules()
 hosts_to_scan = []
@@ -48,7 +48,7 @@ for (hn, mods) in results.items():
     if 'virt' in mods:
         hosts_to_scan.append(hn)
 
-fc = func.overlord.client.Client(';'.join(hosts_to_scan), timeout=opts.timeout, nforks=len(hosts_to_scan))
+fc = func.overlord.client.Client(';'.join(hosts_to_scan), timeout=opts.timeout, nforks=len(hosts_to_scan), delegate=opts.delegate)
 results = fc.virt.info()
 
 for (hn, vms) in sorted(results.items()):
diff --git a/scripts/func-ps-compare b/scripts/func-ps-compare
index cc2bfb8..990cc3b 100755
--- a/scripts/func-ps-compare
+++ b/scripts/func-ps-compare
@@ -8,8 +8,8 @@ from optparse import OptionParser
 from func.utils import is_error
 
 
-def get_host_list(hosts):
-    fc = fclient.Client(hosts)
+def get_host_list(hosts, opts):
+    fc = fclient.Client(hosts, delegate=opts.delegate)
     host_list = fc.minions_class.get_all_hosts() # grumble
     return host_list
     
@@ -32,7 +32,7 @@ if len(extcmds) != 2:
     sys.exit(1)
 
 hosts = ';'.join(extcmds)
-host_list = get_host_list(hosts)
+host_list = get_host_list(hosts, opts)
 
 if len(host_list) != 2:
     print("Must specify exactly two hosts to compare, hosts found: %s" % ' '.join(host_list))
@@ -41,7 +41,7 @@ if len(host_list) != 2:
 host1 = host_list[0]
 host2 = host_list[1]
 
-fc = fclient.Client(hosts, timeout=opts.timeout, nforks=2)
+fc = fclient.Client(hosts, timeout=opts.timeout, nforks=2, delegate=opts.delegate)
 results = fc.process.info("axw")
 
 processes = {}
diff --git a/scripts/func-whatsmyname b/scripts/func-whatsmyname
index 579b483..39be514 100755
--- a/scripts/func-whatsmyname
+++ b/scripts/func-whatsmyname
@@ -40,7 +40,7 @@ hosts ='*'
 if opts.host:
     hosts = ';'.join(opts.host)
 
-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)
 results = fc.command.run('/bin/hostname -f')
 for (hn, output) in results.items():
     if is_error(output):
diff --git a/scripts/func-yum b/scripts/func-yum
index e2374bb..b945b02 100755
--- a/scripts/func-yum
+++ b/scripts/func-yum
@@ -143,7 +143,7 @@ def filter_hosts(hosts, opts):
     
     online = []
     offline = []
-    fc = fclient.Client(hosts, timeout=opts.short_timeout, nforks=opts.forks)
+    fc = fclient.Client(hosts, timeout=opts.short_timeout, nforks=opts.forks, delegate=opts.delegate)
     results = fc.test.ping()
     for (hn, out) in results.items():
         if out != 1:
@@ -462,8 +462,8 @@ def search(hosts, opts, search_str, target=None):
                         results[hn].append('%s:%s' % (thistarget, r.strip()))
     return results
 
-def get_host_list(hosts):
-    fc = fclient.Client(hosts)
+def get_host_list(hosts, opts):
+    fc = fclient.Client(hosts, delegate=opts.delegate)
     host_list = fc.minions_class.get_all_hosts() # grumble
     return host_list
     
@@ -482,7 +482,7 @@ def main(args):
         
         hosts, offline = filter_hosts(hosts, opts)
         getinfo_forks = len(hosts) # gives us a slight advantage on an expensive operation
-        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=getinfo_forks)
+        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=getinfo_forks, delegate=opts.delegate)
         errors = store_info(fc, opts)
         if not opts.quiet:
             print 'stored info for:' 
@@ -499,7 +499,7 @@ def main(args):
     elif basecmd == 'update':
         hosts, offline = filter_hosts(hosts, opts)
         
-        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=opts.forks, async=True)
+        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=opts.forks, delegate=opts.delegate, async=True)
         _confirm_on_change(basecmd, extcmds, hosts)
         
         errors = update(fc, opts, extcmds)
@@ -507,7 +507,7 @@ def main(args):
             errorprint('  %s' % error)
         if not opts.quiet:
             print 'updating stored info for updated hosts'
-        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=opts.forks)
+        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=opts.forks, delegate=opts.delegate)
         errors = store_info(fc, opts) # get latest info for the hosts 
         for error in errors:
             errorprint('  %s' % error)
@@ -515,7 +515,7 @@ def main(args):
         
         
     elif basecmd == 'status':
-        host_list = get_host_list(hosts)
+        host_list = get_host_list(hosts, opts)
         now = time.time()
         status =  return_status(host_list, opts)
         for hn in sorted(status.keys()):
@@ -533,7 +533,7 @@ def main(args):
 
 
     elif basecmd == 'list':
-        host_list = get_host_list(hosts)
+        host_list = get_host_list(hosts, opts)
         extopts = ['installed', 'updates', 'orphans', 'security-updates',
                    'updated', 'with-security', 'with-updates']
         if len(extcmds) == 0:
@@ -588,14 +588,14 @@ def main(args):
                 
     elif basecmd == 'custom':
         hosts, offline = filter_hosts(hosts, opts)
-        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=opts.forks)
+        fc = fclient.Client(';'.join(hosts), timeout=opts.timeout, nforks=opts.forks, delegate=opts.delegate)
         _confirm_on_change(basecmd, extcmds, hosts)        
         errors = custom(fc, opts, extcmds)
         for error in errors:
             errorprint('  %s' % error)
     
     elif basecmd == 'clean':
-        host_list = get_host_list(hosts)
+        host_list = get_host_list(hosts, opts)
         extopts = ['old-data', 'downed-hosts', 'empty-hosts']
         if len(extcmds) == 0:
             errorprint("specify %s" % ' '.join(extopts))
@@ -605,7 +605,7 @@ def main(args):
             if item == 'old-data':
                 pass
     elif basecmd == 'search':
-        host_list = get_host_list(hosts)        
+        host_list = get_host_list(hosts, opts)
         if not extcmds:
             errorprint("search searchstring [where to search: installed, updates, updated]")
             errorprint("must specify at least what to search for")
@@ -626,7 +626,7 @@ def main(args):
             errorprint("Must specify exactly two hosts to compare")
             return 1
         hosts = ';'.join(extcmds)
-        host_list = get_host_list(hosts)
+        host_list = get_host_list(hosts, opts)
         if len(host_list) != 2:
             errorprint("Must specify exactly two hosts to compare, hosts found: %s" % ' '.join(host_list))
             return 1
-- 
1.7.2.3

