summaryrefslogtreecommitdiffstats
path: root/func/overlord/func_command.py
blob: 09b324a2b6678840c87441aa08615976713ce968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import glob
import sys


import command

#FIXME: need a plug-in runtime module loader here
from cmd_modules import call
from cmd_modules import show
from cmd_modules import copyfile
from cmd_modules import listminions
from cmd_modules import ping

from func.overlord import client

class FuncCommandLine(command.Command):
    name = "func"
    usage = "func is the commandline interface to a func minion"

    subCommandClasses = [call.Call, show.Show,
                         copyfile.CopyFile, listminions.ListMinions, ping.Ping]

    def __init__(self):

        command.Command.__init__(self)

    def do(self, args):
        pass

    def addOptions(self):
        self.parser.add_option('', '--version', action="store_true",
            help="show version information")

    # just some ugly goo to try to guess if arg[1] is hostnamegoo or
    # a command name
    def _isGlob(self, str):
        if str.find("*") or str.find("?") or str.find("[") or str.find("]"):
            return True
        return False
        
    def handleArguments(self, args):
        if len(args) < 2:
            print "see the func manpage for usage"
            sys.exit(411)
        server_string = args[0]
        # try to be clever about this for now
        if client.isServer(server_string) or self._isGlob(server_string):
            self.server_spec = server_string
            args.pop(0)
        # if it doesn't look like server, assume it
        # is a sub command? that seems wrong, what about
        # typo's and such? How to catch that? -akl
        # maybe a class variable self.data on Command?

    def handleOptions(self, options):
        if options.version:
            #FIXME
            print "version is NOT IMPLEMENTED YET"