diff options
author | Adrian Likins <alikins@redhat.com> | 2008-03-28 16:51:55 -0400 |
---|---|---|
committer | Adrian Likins <alikins@redhat.com> | 2008-03-28 16:51:55 -0400 |
commit | b2d8973c777e0c00192aeaa7e0a02b21675ba132 (patch) | |
tree | c5545b635a86eab5ca41b8a178957e8afcf68247 /func/overlord/command.py | |
parent | a2d5d31e8d0cec0e700d6a95e3b912e607bbf84f (diff) | |
download | third_party-func-b2d8973c777e0c00192aeaa7e0a02b21675ba132.tar.gz third_party-func-b2d8973c777e0c00192aeaa7e0a02b21675ba132.tar.xz third_party-func-b2d8973c777e0c00192aeaa7e0a02b21675ba132.zip |
add a BaseCommand class to func/overlord/command.py.
This class adds data about the default settings for the
Overlord class that the various cmd_module classes were
hardcoding, notable DEFAULT_PORT.
update all the cmd_modules/* classes to use the new
BaseCommand class. Remove any DEFAULT_PORT references.
Also remove the ill advised --port option some of them
had, since this doesnt really make much sense.
Progress on https://fedorahosted.org/func/ticket/31
Diffstat (limited to 'func/overlord/command.py')
-rw-r--r-- | func/overlord/command.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/func/overlord/command.py b/func/overlord/command.py index 7cf3623..0fd0c7a 100644 --- a/func/overlord/command.py +++ b/func/overlord/command.py @@ -15,6 +15,8 @@ import optparse import sys from func.config import read_config, CONFIG_FILE +from func.overlord import client + from certmaster.commonconfig import CMConfig class CommandHelpFormatter(optparse.IndentedHelpFormatter): @@ -252,6 +254,7 @@ class Command: self.stderr.write("Unknown command '%s'.\n" % command) return 1 + def outputHelp(self): """ Output help information. @@ -285,3 +288,24 @@ class Command: while c.parentCommand: c = c.parentCommand return c + +DEFAULT_PORT = 51234 +class BaseCommand(Command): + """ wrapper class for commands with some convience functions, namely + getOverlord() for getting a overlord client api handle""" + + interactive = False + verbose=0 + port=DEFAULT_PORT + def getOverlord(self): + if not getattr(self, "server_spec"): + self.server_spec = self.parentCommand.server_spec + + + self.overlord_obj = client.Overlord(self.server_spec, + port=self.port, + interactive=self.interactive, + verbose=self.verbose, + config=self.config) + + |