Port ipa-replica-prepare to the admintool framework

Break the script into several smaller methods.

Use modern idioms: os.path.join instead of string addition; the with statement
for closing files.

Add --quiet, --verbose, and --log-file options. Use logging instead of print
statements. (http://freeipa.org/page/V3/Logging_and_output)

Part of: https://fedorahosted.org/freeipa/ticket/2652
Fixes: https://fedorahosted.org/freeipa/ticket/3285
This commit is contained in:
Petr Viktorin
2013-02-01 13:44:59 -05:00
committed by Rob Crittenden
parent 55cfd06e3a
commit 26c498736e
3 changed files with 512 additions and 489 deletions
+4 -1
View File
@@ -77,12 +77,14 @@ class AdminTool(object):
command_name - shown in logs
log_file_name - if None, logging is to stderr only
usage - text shown in help
description - text shown in help
See the setup_logging method for more info on logging.
"""
command_name = None
log_file_name = None
usage = None
description = None
log = None
_option_parsers = dict()
@@ -91,7 +93,8 @@ class AdminTool(object):
def make_parser(cls):
"""Create an option parser shared across all instances of this class"""
parser = config.IPAOptionParser(version=version.VERSION,
usage=cls.usage, formatter=config.IPAFormatter())
usage=cls.usage, formatter=config.IPAFormatter(),
description=cls.description)
cls.option_parser = parser
cls.add_options(parser)