summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2008-03-28 14:13:49 -0400
committerAdrian Likins <alikins@redhat.com>2008-03-28 14:13:49 -0400
commit4054792be014a9b7373a5b909f5052ab271c2307 (patch)
tree3cd0cbecad706d16d3483b2c071f101c607580e8 /func
parent8bf00319db57ecfed8477f97e673248ff3d9e44a (diff)
downloadthird_party-func-4054792be014a9b7373a5b909f5052ab271c2307.tar.gz
third_party-func-4054792be014a9b7373a5b909f5052ab271c2307.tar.xz
third_party-func-4054792be014a9b7373a5b909f5052ab271c2307.zip
Changing func/func/overlord/client.py:Client() to Overlord(). Client() still
works but will dive a deprecation warning. First pass at this refactor. I think just about everything has been updated, but some questions remain. Like if client.py needs a name change.
Diffstat (limited to 'func')
-rw-r--r--func/minion/modules/jobs.py2
-rwxr-xr-xfunc/overlord/client.py22
-rw-r--r--func/overlord/cmd_modules/call.py14
-rw-r--r--func/overlord/cmd_modules/check.py7
-rw-r--r--func/overlord/cmd_modules/copyfile.py12
-rw-r--r--func/overlord/cmd_modules/listminions.py12
-rw-r--r--func/overlord/cmd_modules/ping.py9
-rw-r--r--func/overlord/cmd_modules/show.py12
-rwxr-xr-xfunc/overlord/inventory.py6
-rwxr-xr-xfunc/overlord/test_func.py10
10 files changed, 62 insertions, 44 deletions
diff --git a/func/minion/modules/jobs.py b/func/minion/modules/jobs.py
index 90c7421..97d203f 100644
--- a/func/minion/modules/jobs.py
+++ b/func/minion/modules/jobs.py
@@ -1,5 +1,5 @@
## (Largely internal) module for access to asynchoronously dispatched
-## module job ID's. The Func Client() module wraps most of this usage
+## module job ID's. The Func Overlord() module wraps most of this usage
## so it's not entirely relevant to folks using the CLI or Func API
## directly.
##
diff --git a/func/overlord/client.py b/func/overlord/client.py
index 26b1cca..299fb5d 100755
--- a/func/overlord/client.py
+++ b/func/overlord/client.py
@@ -83,7 +83,7 @@ class CommandAutomagic(object):
# ===================================
# this is a module level def so we can use it and isServer() from
-# other modules with a Client class
+# other modules with a Overlord class
class Minions(object):
def __init__(self, spec, port=51234,
@@ -153,7 +153,9 @@ def is_minion(minion_string):
return minions.is_minion()
-class Client(object):
+
+
+class Overlord(object):
def __init__(self, server_spec, port=DEFAULT_PORT, interactive=False,
verbose=False, noglobs=False, nforks=1, config=None, async=False, init_ssl=True):
@@ -225,9 +227,9 @@ class Client(object):
So, it enables stuff like this:
- Client("*.example.org").yum.install("foo")
+ Overlord("*.example.org").yum.install("foo")
- # WARNING: any missing values in Client's source will yield
+ # WARNING: any missing values in Overlord's source will yield
# strange errors with this engaged. Be aware of that.
"""
@@ -239,7 +241,7 @@ class Client(object):
"""
Use this to acquire status from jobs when using run with async client handles
"""
- return jobthing.job_status(jobid, client_class=Client)
+ return jobthing.job_status(jobid, client_class=Overlord)
# -----------------------------------------------
@@ -250,7 +252,7 @@ class Client(object):
returns.
The returns may include exception objects.
- If Client() was constructed with noglobs=True, the return is instead
+ If Overlord() was constructed with noglobs=True, the return is instead
just a single value, not a hash.
"""
@@ -352,3 +354,11 @@ class Client(object):
if x > max:
max = x
return max
+
+
+class Client(Overlord):
+ def __init__(self, *args, **kwargs):
+ Overlord.__init__(self, *args, **kwargs)
+ # we can remove this if folks want -akl
+ print "Client() class is deprecated, please use the Overlord() class."
+
diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py
index 7add5bf..ea16975 100644
--- a/func/overlord/cmd_modules/call.py
+++ b/func/overlord/cmd_modules/call.py
@@ -77,8 +77,8 @@ class Call(client.command.Command):
if self.options.rawprint:
return data
-
- return pprint.pformat(data)
+
+ return pprint.pformat(data)
def do(self, args):
@@ -103,9 +103,13 @@ class Call(client.command.Command):
# or some sort of shared datastruct?
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, nforks=self.options.forks)
- results = client_obj.run(self.module, self.method, self.method_args)
+ overlord_obj = client.Overlord(self.server_spec,port=self.port,
+ interactive=True,
+ verbose=self.verbose,
+ config=self.config,
+ nforks=self.options.forks)
+ results = overlord_obj.run(self.module, self.method, self.method_args)
+
# TO DO: add multiplexer support
# probably as a higher level module.
diff --git a/func/overlord/cmd_modules/check.py b/func/overlord/cmd_modules/check.py
index 446e6de..b360df6 100644
--- a/func/overlord/cmd_modules/check.py
+++ b/func/overlord/cmd_modules/check.py
@@ -82,14 +82,15 @@ class CheckAction(client.command.Command):
# construct a client handle and see if any hosts are reachable
self.server_spec = self.parentCommand.server_spec
- client_obj = client.Client(
+ overlord_obj = client.Overlord(
self.server_spec,
port=self.port,
interactive=False,
verbose=False,
config=self.config
- )
- results = client_obj.test.add(1,2)
+ )
+
+ results = overlord_obj.test.add(1,2)
hosts = results.keys()
if len(hosts) == 0:
print "* no systems have signed certs"
diff --git a/func/overlord/cmd_modules/copyfile.py b/func/overlord/cmd_modules/copyfile.py
index 295aeab..a149d5d 100644
--- a/func/overlord/cmd_modules/copyfile.py
+++ b/func/overlord/cmd_modules/copyfile.py
@@ -49,11 +49,11 @@ class CopyFile(client.command.Command):
def do(self, args):
self.server_spec = self.parentCommand.server_spec
- client_obj = client.Client(self.server_spec,
- port=self.port,
- interactive=False,
- verbose=self.options.verbose,
- config=self.config)
+ overlord_obj = client.Overlord(self.server_spec,
+ port=self.port,
+ interactive=False,
+ verbose=self.options.verbose,
+ config=self.config)
try:
@@ -69,5 +69,5 @@ class CopyFile(client.command.Command):
data = xmlrpclib.Binary(fb)
- results = client_obj.run("copyfile", "copyfile", [self.options.remotepath, data,
+ results = overlord_obj.run("copyfile", "copyfile", [self.options.remotepath, data,
mode, uid, gid])
diff --git a/func/overlord/cmd_modules/listminions.py b/func/overlord/cmd_modules/listminions.py
index 9421b8d..fbfc282 100644
--- a/func/overlord/cmd_modules/listminions.py
+++ b/func/overlord/cmd_modules/listminions.py
@@ -37,13 +37,13 @@ class ListMinions(client.command.Command):
def do(self, args):
self.server_spec = self.parentCommand.server_spec
- client_obj = client.Client(self.server_spec,
- port=self.port,
- interactive=False,
- verbose=self.options.verbose,
- config=self.config)
+ overlord_obj = client.Overlord(self.server_spec,
+ port=self.port,
+ interactive=False,
+ verbose=self.options.verbose,
+ config=self.config)
- results = client_obj.test.add(1,2)
+ results = overlord_obj.test.add(1,2)
servers = results.keys()
servers.sort()
diff --git a/func/overlord/cmd_modules/ping.py b/func/overlord/cmd_modules/ping.py
index 438e2a9..a94fa70 100644
--- a/func/overlord/cmd_modules/ping.py
+++ b/func/overlord/cmd_modules/ping.py
@@ -57,10 +57,13 @@ class Ping(client.command.Command):
for server in servers:
- client_obj = client.Client(server,port=self.options.port,interactive=False,
- verbose=self.options.verbose,config=self.config, noglobs=True)
+ overlord_obj = client.Overlord(server,port=self.options.port,
+ interactive=False,
+ verbose=self.options.verbose,
+ config=self.config, noglobs=True)
- results = client_obj.run("test", "ping", [])
+ results = overlord_obj.run("test", "ping", [])
+ print "results", results, type(results)
if results == 1:
print "[ ok ... ] %s" % server
else:
diff --git a/func/overlord/cmd_modules/show.py b/func/overlord/cmd_modules/show.py
index e1df554..8963082 100644
--- a/func/overlord/cmd_modules/show.py
+++ b/func/overlord/cmd_modules/show.py
@@ -48,13 +48,13 @@ class ShowHardware(client.command.Command):
self.server_spec = self.parentCommand.parentCommand.server_spec
- client_obj = client.Client(self.server_spec,
- port=self.port,
- interactive=False,
- verbose=self.options.verbose,
- config=self.config)
+ overlord_obj = client.Overlord(self.server_spec,
+ port=self.port,
+ interactive=False,
+ verbose=self.options.verbose,
+ config=self.config)
- results = client_obj.run("hardware", "info", [])
+ results = overlord_obj.run("hardware", "info", [])
# if the user
top_options = ["port","verbose"]
diff --git a/func/overlord/inventory.py b/func/overlord/inventory.py
index 8302a1c..d1dcf67 100755
--- a/func/overlord/inventory.py
+++ b/func/overlord/inventory.py
@@ -76,7 +76,7 @@ class FuncInventory(object):
self.git_setup(options)
# see what modules each host provides (as well as what hosts we have)
- host_methods = func_client.Client(options.server_spec).system.list_methods()
+ host_methods = func_client.Overlord(options.server_spec).system.list_methods()
# call all remote info methods and handle them
if options.verbose:
@@ -106,8 +106,8 @@ class FuncInventory(object):
if not "all" in filtered_function_list and not method_name in filtered_function_list:
continue
- client = func_client.Client(host,noglobs=True) # ,noglobs=True)
- results = getattr(getattr(client,module_name),method_name)()
+ overlord = func_client.Overlord(host,noglobs=True) # ,noglobs=True)
+ results = getattr(getattr(overlord,module_name),method_name)()
if self.options.verbose:
print "-- %s: running: %s %s" % (host, module_name, method_name)
self.save_results(options, host, module_name, method_name, results)
diff --git a/func/overlord/test_func.py b/func/overlord/test_func.py
index 2b3f041..4c08a56 100755
--- a/func/overlord/test_func.py
+++ b/func/overlord/test_func.py
@@ -15,11 +15,11 @@ TEST_SMART = True
if TEST_GETATTR:
import func.overlord.client as func_client
- print func_client.Client("*").hardware.pci_info()
- #print func_client.Client("*").test.add(1,2)
- #print func_client.Client("*").hardware.info()
- #print func_client.Client("*").run("hardware","info",[])
- #print func_client.Client(socket.gethostname(),noglobs=True).test.add("1","2")
+ print func_client.Overlord("*").hardware.pci_info()
+ #print func_client.Overlord("*").test.add(1,2)
+ #print func_client.Overlord("*").hardware.info()
+ #print func_client.Overlord("*").run("hardware","info",[])
+ #print func_client.Overlord(socket.gethostname(),noglobs=True).test.add("1","2")
sys.exit(1)
# get a connecton (to be replaced by client lib logic)