diff options
| author | Mark Washenberger <mark.washenberger@rackspace.com> | 2011-06-22 09:33:46 -0400 |
|---|---|---|
| committer | Mark Washenberger <mark.washenberger@rackspace.com> | 2011-06-22 09:33:46 -0400 |
| commit | 13a51049ce5e76fd679b3dee978edce58db21d09 (patch) | |
| tree | 9bb319a79083aaa2b596a8fba6a654ba156049b0 | |
| parent | 186598a819c4e9c4b1b76aad61e7df56cdddd5be (diff) | |
| download | nova-13a51049ce5e76fd679b3dee978edce58db21d09.tar.gz nova-13a51049ce5e76fd679b3dee978edce58db21d09.tar.xz nova-13a51049ce5e76fd679b3dee978edce58db21d09.zip | |
fix some issues with flags and logging
| -rw-r--r-- | nova/service.py | 19 | ||||
| -rw-r--r-- | nova/utils.py | 10 |
2 files changed, 20 insertions, 9 deletions
diff --git a/nova/service.py b/nova/service.py index ca247c0f9..41c6551e0 100644 --- a/nova/service.py +++ b/nova/service.py @@ -38,6 +38,8 @@ from nova import version from nova import wsgi +LOG = logging.getLogger('nova.service') + FLAGS = flags.FLAGS flags.DEFINE_integer('report_interval', 10, 'seconds between nodes reporting state to datastore', @@ -58,18 +60,19 @@ flags.DEFINE_string('api_paste_config', "api-paste.ini", class Launcher(object): """Launch one or more services and wait for them to complete.""" - def __init__(self, _flags=None): + def __init__(self, flags=None): """Initialize the service launcher. - :param _flags: Flags to use for the services we're going to load. + :param flags: Flags to use for the services we're going to load. :returns: None """ self._services = [] self._version = version.version_string_with_vcs() - self._flags = _flags - self._setup_logging() + self._flags = flags self._setup_flags() + self._setup_logging() + self._log_flags() def _setup_logging(self): """Logic to ensure logging is going to work correctly for services. @@ -86,13 +89,19 @@ class Launcher(object): :returns: None """ - utils.default_flagfile() + utils.default_flagfile(args=self._flags) FLAGS(self._flags or []) flags.DEFINE_flag(flags.HelpFlag()) flags.DEFINE_flag(flags.HelpshortFlag()) flags.DEFINE_flag(flags.HelpXMLFlag()) FLAGS.ParseNewFlags() + def _log_flags(self): + LOG.debug(_("Full set of FLAGS:")) + for flag in FLAGS: + flag_get = FLAGS.get(flag, None) + LOG.debug("%(flag)s : %(flag_get)s" % locals()) + @staticmethod def run_service(service): """Start and wait for a service to finish. diff --git a/nova/utils.py b/nova/utils.py index e2ac16f31..a9b0f3128 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -226,8 +226,10 @@ def novadir(): return os.path.abspath(nova.__file__).split('nova/__init__.pyc')[0] -def default_flagfile(filename='nova.conf'): - for arg in sys.argv: +def default_flagfile(filename='nova.conf', args=None): + if args is None: + args = sys.argv + for arg in args: if arg.find('flagfile') != -1: break else: @@ -239,8 +241,8 @@ def default_flagfile(filename='nova.conf'): filename = "./nova.conf" if not os.path.exists(filename): filename = '/etc/nova/nova.conf' - flagfile = ['--flagfile=%s' % filename] - sys.argv = sys.argv[:1] + flagfile + sys.argv[1:] + flagfile = '--flagfile=%s' % filename + args.insert(1, flagfile) def debug(arg): |
