From 8f2ff4d7c902d534d68ff1a16418b7be492033bf Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 7 Feb 2008 13:13:24 -0500 Subject: Carving away at func some more to just get down to cert items, still lots more to do. --- func/overlord/cmd_modules/__init__.py | 0 func/overlord/cmd_modules/__init__.pyc | Bin 133 -> 0 bytes func/overlord/cmd_modules/call.py | 114 ------------------------------- func/overlord/cmd_modules/call.pyc | Bin 2900 -> 0 bytes func/overlord/cmd_modules/copyfile.py | 73 -------------------- func/overlord/cmd_modules/listminions.py | 51 -------------- func/overlord/cmd_modules/ping.py | 69 ------------------- func/overlord/cmd_modules/show.py | 99 --------------------------- 8 files changed, 406 deletions(-) delete mode 100644 func/overlord/cmd_modules/__init__.py delete mode 100644 func/overlord/cmd_modules/__init__.pyc delete mode 100644 func/overlord/cmd_modules/call.py delete mode 100644 func/overlord/cmd_modules/call.pyc delete mode 100644 func/overlord/cmd_modules/copyfile.py delete mode 100644 func/overlord/cmd_modules/listminions.py delete mode 100644 func/overlord/cmd_modules/ping.py delete mode 100644 func/overlord/cmd_modules/show.py (limited to 'func/overlord/cmd_modules') diff --git a/func/overlord/cmd_modules/__init__.py b/func/overlord/cmd_modules/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/func/overlord/cmd_modules/__init__.pyc b/func/overlord/cmd_modules/__init__.pyc deleted file mode 100644 index 287b354..0000000 Binary files a/func/overlord/cmd_modules/__init__.pyc and /dev/null differ diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py deleted file mode 100644 index 7add5bf..0000000 --- a/func/overlord/cmd_modules/call.py +++ /dev/null @@ -1,114 +0,0 @@ -""" -call func method invoker - -Copyright 2007, Red Hat, Inc -see AUTHORS - -This software may be freely redistributed under the terms of the GNU -general public license. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -""" - - -import optparse -import pprint -import xmlrpclib - -from func.overlord import command -from func.overlord import client - -DEFAULT_PORT = 51234 -DEFAULT_FORKS = 1 - -class Call(client.command.Command): - name = "call" - usage = "call module method name arg1 arg2..." - def addOptions(self): - self.parser.add_option("-v", "--verbose", dest="verbose", - action="store_true") - self.parser.add_option("-x", "--xmlrpc", dest="xmlrpc", - help="output return data in XMLRPC format", - action="store_true") - self.parser.add_option("", "--raw", dest="rawprint", - help="output return data using Python print", - action="store_true") - self.parser.add_option("-j", "--json", dest="json", - help="output return data using JSON", - action="store_true") - self.parser.add_option("-p", "--port", dest="port", - default=DEFAULT_PORT) - self.parser.add_option("-f", "--forks", dest="forks", - help="how many parallel processes? (default 1)", - default=DEFAULT_FORKS) - - def handleOptions(self, options): - self.options = options - - self.verbose = options.verbose - self.port = options.port - - # I'm not really a fan of the "module methodname" approach - # but we'll keep it for now -akl - - def parse(self, argv): - self.argv = argv - - return command.Command.parse(self, argv) - - - def format_return(self, data): - """ - The call module supports multiple output return types, the default is pprint. - """ - - if self.options.xmlrpc: - return xmlrpclib.dumps((data,"")) - - if self.options.json: - try: - import simplejson - return simplejson.dumps(data) - except ImportError: - print "WARNING: json support not found, install python-simplejson" - return data - - if self.options.rawprint: - return data - - return pprint.pformat(data) - - def do(self, args): - - # I'm not really a fan of the "module methodname" approach - # but we'll keep it for now -akl - - # I kind of feel like we shouldn't be parsing args here, but I'm - # not sure what the write place is -al; - self.module = args[0] - if len(args) > 1: - self.method = args[1] - else: - self.method = None - if len(args) > 2: - self.method_args = args[2:] - else: - self.method_args = [] - - # this could get weird, sub sub classes might be calling this - # this with multiple.parentCommand.parentCommands... - # maybe command.py needs a way to set attrs on subCommands? - # 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) - - # TO DO: add multiplexer support - # probably as a higher level module. - - # dump the return code stuff atm till we figure out the right place for it - return self.format_return(results) diff --git a/func/overlord/cmd_modules/call.pyc b/func/overlord/cmd_modules/call.pyc deleted file mode 100644 index f6c588d..0000000 Binary files a/func/overlord/cmd_modules/call.pyc and /dev/null differ diff --git a/func/overlord/cmd_modules/copyfile.py b/func/overlord/cmd_modules/copyfile.py deleted file mode 100644 index 295aeab..0000000 --- a/func/overlord/cmd_modules/copyfile.py +++ /dev/null @@ -1,73 +0,0 @@ -""" -copyfile command line - -Copyright 2007, Red Hat, Inc -see AUTHORS - -This software may be freely redistributed under the terms of the GNU -general public license. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -""" - - -import optparse -import os -import pprint -import stat -import xmlrpclib - -from func.overlord import command -from func.overlord import client - -DEFAULT_PORT = 51234 - -class CopyFile(client.command.Command): - name = "copyfile" - usage = "copy a file to a client" - - - def addOptions(self): - self.parser.add_option("-f", "--file", dest="filename", - action="store") - self.parser.add_option("", "--remotepath", dest="remotepath", - action="store") - self.parser.add_option("", "--force", dest="force", - action="store_true") - self.parser.add_option("-v", "--verbose", dest="verbose", - action="store_true") - self.parser.add_option("-p", "--port", dest="port") - - def handleOptions(self, options): - self.port = DEFAULT_PORT - if self.options.port: - self.port = self.options.port - - - 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) - - - try: - fb = open(self.options.filename, "r").read() - except IOError, e: - print "Unable to open file: %s: %s" % (self.options.filename, e) - return - - st = os.stat(self.options.filename) - mode = stat.S_IMODE(st.st_mode) - uid = st.st_uid - gid = st.st_gid - - - data = xmlrpclib.Binary(fb) - results = client_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 deleted file mode 100644 index 50c7e24..0000000 --- a/func/overlord/cmd_modules/listminions.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -copyfile command line - -Copyright 2007, Red Hat, Inc -see AUTHORS - -This software may be freely redistributed under the terms of the GNU -general public license. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -""" - - -import optparse -import os - -from func.overlord import command -from func.overlord import client -DEFAULT_PORT = 51234 - -class ListMinions(client.command.Command): - name = "list_minions" - usage = "show known minions" - - def addOptions(self): - self.parser.add_option("-v", "--verbose", dest="verbose", - action="store_true") - - def handleOptions(self, options): - self.port = DEFAULT_PORT - if options.verbose: - self.verbose = self.options.verbose - - 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) - - servers = client_obj.servers - print servers - for server in servers: - # just cause I hate regex'es -akl - host = server.split(':')[-2] - host = host.split('/')[-1] - print host diff --git a/func/overlord/cmd_modules/ping.py b/func/overlord/cmd_modules/ping.py deleted file mode 100644 index f756fd9..0000000 --- a/func/overlord/cmd_modules/ping.py +++ /dev/null @@ -1,69 +0,0 @@ -""" -copyfile command line - -Copyright 2007, Red Hat, Inc -Michael DeHaan -also see AUTHORS - -This software may be freely redistributed under the terms of the GNU -general public license. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -""" - -import optparse -import os -import pprint -import stat -import xmlrpclib - -from func.overlord import command -from func.overlord import client - -# FIXME: this really should not be in each sub module. -DEFAULT_PORT = 51234 - - -class Ping(client.command.Command): - name = "ping" - usage = "see what func minions are up/accessible" - - def addOptions(self): - """ - Not too many options for you! (Seriously, it's a simple command ... func "*" ping) - """ - # FIXME: verbose and port should be added globally to all sub modules - self.parser.add_option("-v", "--verbose", dest="verbose", - action="store_true") - self.parser.add_option("-p", "--port", dest="port", - default=DEFAULT_PORT) - - def handleOptions(self, options): - """ - Nothing to do here... - """ - pass - - def do(self, args): - self.server_spec = self.parentCommand.server_spec - - # because this is mainly an interactive command, expand the server list and make seperate connections. - # to make things look more speedy. - - servers = client.expand_servers(self.server_spec, port=self.options.port, noglobs=None, - verbose=self.options.verbose, just_fqdns=True) - - for server in servers: - - client_obj = client.Client(server,port=self.options.port,interactive=False, - verbose=self.options.verbose,config=self.config, noglobs=True) - - results = client_obj.run("test", "ping", []) - if results == 1: - print "[ ok ... ] %s" % server - else: - print "[ FAILED ] %s" % server - - return 1 diff --git a/func/overlord/cmd_modules/show.py b/func/overlord/cmd_modules/show.py deleted file mode 100644 index e1df554..0000000 --- a/func/overlord/cmd_modules/show.py +++ /dev/null @@ -1,99 +0,0 @@ -""" -show introspection commandline - -Copyright 2007, Red Hat, Inc -see AUTHORS - -This software may be freely redistributed under the terms of the GNU -general public license. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -""" - - -import optparse -import pprint -import xmlrpclib - -from func.overlord import command -from func.overlord import client - -DEFAULT_PORT = 51234 - - -class ShowHardware(client.command.Command): - name = "hardware" - usage = "show hardware details" - - # FIXME: we might as well make verbose be in the subclass - # and probably an inc variable while we are at it - def addOptions(self): - self.parser.add_option("-v", "--verbose", dest="verbose", - action="store_true") - self.parser.add_option("-p", "--port", dest="port") - - - def handleOptions(self, options): - self.port = DEFAULT_PORT - if self.options.port: - self.port = self.options.port - - def parse(self, argv): - self.argv = argv - return command.Command.parse(self,argv) - - def do(self,args): - - 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) - - results = client_obj.run("hardware", "info", []) - - # if the user - top_options = ["port","verbose"] - - for minion in results: - print "%s:" % minion - minion_data = results[minion] - # if user set no args - if not args: - pprint.pprint(minion_data) - continue - - for arg in args: - if arg in minion_data: - print minion_data[arg] - - -class Show(client.command.Command): - name = "show" - usage = "various simple report stuff" - subCommandClasses = [ShowHardware] - def addOptions(self): - self.parser.add_option("-v", "--verbose", dest="verbose", - action="store_true") - self.parser.add_option("-p", "--port", dest="port", - default=DEFAULT_PORT) - - def handleOptions(self, options): - self.options = options - - self.verbose = options.verbose - self.port = options.port - - - def parse(self, argv): - self.argv = argv - - return command.Command.parse(self, argv) - - - def do(self, args): - pass -- cgit