add some basic logging output to certmaster
[certmaster.git] / certmaster / overlord / func_command.py
1 #!/usr/bin/python
2
3 ## func command line interface & client lib
4 ##
5 ## Copyright 2007,2008 Red Hat, Inc
6 ## +AUTHORS
7 ##
8 ## This software may be freely redistributed under the terms of the GNU
9 ## general public license.
10 ##
11 ## You should have received a copy of the GNU General Public License
12 ## along with this program; if not, write to the Free Software
13 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14
15 import sys
16
17
18 import command
19
20 #FIXME: need a plug-in runtime module loader here
21 from cmd_modules import call
22 from cmd_modules import show
23 from cmd_modules import copyfile
24 from cmd_modules import listminions
25 from cmd_modules import ping
26
27 from func.overlord import client
28
29 class FuncCommandLine(command.Command):
30 name = "func"
31 usage = "func is the commandline interface to a func minion"
32
33 subCommandClasses = [call.Call, show.Show,
34 copyfile.CopyFile, listminions.ListMinions, ping.Ping]
35
36 def __init__(self):
37
38 command.Command.__init__(self)
39
40 def do(self, args):
41 pass
42
43 def addOptions(self):
44 self.parser.add_option('', '--version', action="store_true",
45 help="show version information")
46
47 # just some ugly goo to try to guess if arg[1] is hostnamegoo or
48 # a command name
49 def _isGlob(self, str):
50 if str.find("*") or str.find("?") or str.find("[") or str.find("]"):
51 return True
52 return False
53
54 def handleArguments(self, args):
55 if len(args) < 2:
56 print "see the func manpage for usage"
57 sys.exit(411)
58 server_string = args[0]
59 # try to be clever about this for now
60 if client.isServer(server_string) or self._isGlob(server_string):
61 self.server_spec = server_string
62 args.pop(0)
63 # if it doesn't look like server, assume it
64 # is a sub command? that seems wrong, what about
65 # typo's and such? How to catch that? -akl
66 # maybe a class variable self.data on Command?
67
68 def handleOptions(self, options):
69 if options.version:
70 #FIXME
71 print "version is NOT IMPLEMENTED YET"