diff options
| author | Ziad Sawalha <github@highbridgellc.com> | 2011-05-23 20:05:15 -0500 |
|---|---|---|
| committer | Ziad Sawalha <github@highbridgellc.com> | 2011-05-23 20:05:15 -0500 |
| commit | aafd477a9b76a86622d4059560879f738093d5dc (patch) | |
| tree | ec0c9b6d99798372e01a80cb837bfce5b9460cca | |
| parent | 5a7d10b93b74896942fd63df9c09765efec5a700 (diff) | |
Fixed debug/verbose flag processing
| -rwxr-xr-x | bin/keystone | 12 | ||||
| -rwxr-xr-x | bin/keystone-admin | 10 | ||||
| -rwxr-xr-x | bin/keystone-auth | 10 | ||||
| -rwxr-xr-x | bin/keystone-manage | 11 | ||||
| -rwxr-xr-x | bin/sampledata.sh | 2 | ||||
| -rw-r--r-- | keystone/common/config.py | 5 |
6 files changed, 40 insertions, 10 deletions
diff --git a/bin/keystone b/bin/keystone index e2087a8c..04e1659a 100755 --- a/bin/keystone +++ b/bin/keystone @@ -33,6 +33,7 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir)) if os.path.exists(os.path.join(possible_topdir, 'keystone', '__init__.py')): sys.path.insert(0, possible_topdir) + import tools.tracer #load this first import keystone from keystone.common import config @@ -53,13 +54,20 @@ if __name__ == '__main__': # Parse arguments and load config (options, args) = config.parse_options(parser) - config_file = config.find_config_file(options, args) - print "Using config file:", config_file # Start services try: # Load Service API server conf, app = config.load_paste_app('server', options, args) + + debug = options.get('debug') or conf.get('debug', False) + debug = debug in [True, "True", "1"] + verbose = options.get('verbose') or conf.get('verbose', False) + verbose = verbose in [True, "True", "1"] + if debug or verbose: + config_file = config.find_config_file(options, args) + print "Using config file:", config_file + server = wsgi.Server() server.start(app, int(conf['bind_port']), conf['bind_host']) print "Service API listening on %s:%s" % (conf['bind_host'], diff --git a/bin/keystone-admin b/bin/keystone-admin index 2a99b8a3..26cc1ccc 100755 --- a/bin/keystone-admin +++ b/bin/keystone-admin @@ -35,7 +35,6 @@ if os.path.exists(os.path.join(possible_topdir, 'keystone', '__init__.py')): sys.path.insert(0, possible_topdir) import tools.tracer #load this first - import keystone from keystone.common import config from keystone.common import wsgi @@ -50,12 +49,19 @@ if __name__ == '__main__': # Parse arguments and load config (options, args) = config.parse_options(parser) config_file = config.find_config_file(options, args) - print "Using config file:", config_file # Start services try: # Load Admin API server conf, app = config.load_paste_app('admin', options, args) + + debug = options.get('debug') or conf.get('debug', False) + debug = debug in [True, "True", "1"] + verbose = options.get('verbose') or conf.get('verbose', False) + verbose = verbose in [True, "True", "1"] + if debug or verbose: + print "Using config file:", config_file + server = wsgi.Server() server.start(app, int(conf['bind_port']), conf['bind_host']) print "Admin API listening on %s:%s" % (conf['bind_host'], diff --git a/bin/keystone-auth b/bin/keystone-auth index 67fb8a5a..c83af24c 100755 --- a/bin/keystone-auth +++ b/bin/keystone-auth @@ -48,8 +48,14 @@ if __name__ == '__main__': # Parse arguments and load config (options, args) = config.parse_options(parser) - config_file = config.find_config_file(options, args) - print "Using config file:", config_file + + debug = options.get('debug') or conf.get('debug', False) + debug = debug in [True, "True", "1"] + verbose = options.get('verbose') or conf.get('verbose', False) + verbose = verbose in [True, "True", "1"] + if debug or verbose: + config_file = config.find_config_file(options, args) + print "Using config file:", config_file # Start services try: diff --git a/bin/keystone-manage b/bin/keystone-manage index 0b9e67bc..6b17792d 100755 --- a/bin/keystone-manage +++ b/bin/keystone-manage @@ -34,7 +34,7 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir)) if os.path.exists(os.path.join(possible_topdir, 'keystone', '__init__.py')): sys.path.insert(0, possible_topdir) -import tools.tracer +import tools.tracer #load this first import keystone from keystone.common import config import keystone.db.sqlalchemy.api as db_api @@ -95,7 +95,14 @@ def Main(): object_id = args[2] # Set things up to run the command - print "Config file in use: %s" % config_file + debug = options.get('debug') or conf.get('debug', False) + debug = debug in [True, "True", "1"] + verbose = options.get('verbose') or conf.get('verbose', False) + verbose = verbose in [True, "True", "1"] + if debug or verbose: + config_file = config.find_config_file(options, args) + print "Using config file:", config_file + config.setup_logging(options, conf) db_api.configure_db(conf) diff --git a/bin/sampledata.sh b/bin/sampledata.sh index c4102332..14277cde 100755 --- a/bin/sampledata.sh +++ b/bin/sampledata.sh @@ -31,7 +31,7 @@ # Roles ./keystone-manage role add Admin -./keystone-manage role add Admin admin 1234 +./keystone-manage role grant Admin admin 1234 # Groups diff --git a/keystone/common/config.py b/keystone/common/config.py index 708213c9..34281192 100644 --- a/keystone/common/config.py +++ b/keystone/common/config.py @@ -177,7 +177,9 @@ def setup_logging(options, conf): # If either the CLI option or the conf value # is True, we set to True debug = options.get('debug') or conf.get('debug', False) + debug = debug in [True, "True", "1"] verbose = options.get('verbose') or conf.get('verbose', False) + verbose = verbose in [True, "True", "1"] root_logger = logging.root if debug: root_logger.setLevel(logging.DEBUG) @@ -335,10 +337,11 @@ def load_paste_app(app_name, options, args): # We only update the conf dict for the verbose and debug # flags. Everything else must be set up in the conf file... debug = options.get('debug') or conf.get('debug', False) + debug = debug in [True, "True", "1"] verbose = options.get('verbose') or conf.get('verbose', False) + verbose = verbose in [True, "True", "1"] conf['debug'] = debug conf['verbose'] = verbose - # Log the options used when starting if we're in debug mode... if debug: logger = logging.getLogger(app_name) |
