]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Sync latest cfg from oslo-incubator
authorMark McLoughlin <markmc@redhat.com>
Mon, 21 Jan 2013 16:53:51 +0000 (16:53 +0000)
committerMark McLoughlin <markmc@redhat.com>
Thu, 31 Jan 2013 07:03:54 +0000 (07:03 +0000)
Main cfg change is:

  c5984ba Move logging config options into the log module

Change-Id: I3913ea54465658d93dc56e014dfe5d911b0541d6

quantum/agent/common/config.py
quantum/agent/netns_cleanup_util.py
quantum/agent/ovs_cleanup_util.py
quantum/db/migration/cli.py
quantum/openstack/common/cfg.py
quantum/openstack/common/log.py
quantum/plugins/nicira/nicira_nvp_plugin/common/config.py
quantum/tests/unit/test_l3_agent.py

index 7faf3cd47eb30b7c61522a4c1a281b88f2e54c38..de58ee26b5625d745a64d56e8396b7dc7d60fb5c 100644 (file)
@@ -27,7 +27,7 @@ def setup_conf():
                    help=_('Top-level directory for maintaining dhcp state')),
     ]
 
-    conf = cfg.CommonConfigOpts()
+    conf = cfg.ConfigOpts()
     conf.register_opts(bind_opts)
     return conf
 
index 73f64c315848cec0f80f4fe42111b7403f205b5f..c4d93f89366e134344bdf1a5b94713425fdb2840 100644 (file)
@@ -68,7 +68,7 @@ def setup_conf():
                     default=False,
                     help=_('Delete the namespace by removing all devices.')),
     ]
-    conf = cfg.CommonConfigOpts()
+    conf = cfg.ConfigOpts()
     conf.register_opts(opts)
     conf.register_opts(dhcp.OPTS)
     config.setup_logging(conf)
index 3e820d28149c7efba3721eb6f06c7bcd97995138..31d1f4b041c3bbfc3483ccade986a902dfdad5a3 100644 (file)
@@ -47,7 +47,7 @@ def setup_conf():
                    help=_("Root helper application.")),
     ]
 
-    conf = cfg.CommonConfigOpts()
+    conf = cfg.ConfigOpts()
     conf.register_cli_opts(opts)
     conf.register_opts(l3_agent.L3NATAgent.OPTS)
     conf.register_opts(interface.OPTS)
index ba115ee1fbd194cc7685a52e6597546554543a9b..dc9ec181786f05ac8f4f7810e05111af6cd0e7df 100644 (file)
@@ -44,7 +44,7 @@ _db_opts = [
                help=_('URL to database')),
 ]
 
-CONF = cfg.CommonConfigOpts()
+CONF = cfg.ConfigOpts()
 CONF.register_opts(_core_opts)
 CONF.register_opts(_db_opts, 'DATABASE')
 CONF.register_opts(_quota_opts, 'QUOTAS')
index 4aad78adc04dd01cd1b798067a68e87447866ffa..c26191c339b9b880754995059c1c8355e45f349d 100644 (file)
@@ -217,7 +217,7 @@ log files::
         ...
      ]
 
-This module also contains a global instance of the CommonConfigOpts class
+This module also contains a global instance of the ConfigOpts class
 in order to support a common usage pattern in OpenStack::
 
     from quantum.openstack.common import cfg
@@ -236,10 +236,11 @@ in order to support a common usage pattern in OpenStack::
 Positional command line arguments are supported via a 'positional' Opt
 constructor argument::
 
-    >>> CONF.register_cli_opt(MultiStrOpt('bar', positional=True))
+    >>> conf = ConfigOpts()
+    >>> conf.register_cli_opt(MultiStrOpt('bar', positional=True))
     True
-    >>> CONF(['a', 'b'])
-    >>> CONF.bar
+    >>> conf(['a', 'b'])
+    >>> conf.bar
     ['a', 'b']
 
 It is also possible to use argparse "sub-parsers" to parse additional
@@ -249,10 +250,11 @@ command line arguments using the SubCommandOpt class:
     ...     list_action = subparsers.add_parser('list')
     ...     list_action.add_argument('id')
     ...
-    >>> CONF.register_cli_opt(SubCommandOpt('action', handler=add_parsers))
+    >>> conf = ConfigOpts()
+    >>> conf.register_cli_opt(SubCommandOpt('action', handler=add_parsers))
     True
-    >>> CONF(['list', '10'])
-    >>> CONF.action.name, CONF.action.id
+    >>> conf(args=['list', '10'])
+    >>> conf.action.name, conf.action.id
     ('list', '10')
 
 """
@@ -1726,64 +1728,4 @@ class ConfigOpts(collections.Mapping):
             return value
 
 
-class CommonConfigOpts(ConfigOpts):
-
-    DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
-    DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
-
-    common_cli_opts = [
-        BoolOpt('debug',
-                short='d',
-                default=False,
-                help='Print debugging output (set logging level to '
-                     'DEBUG instead of default WARNING level).'),
-        BoolOpt('verbose',
-                short='v',
-                default=False,
-                help='Print more verbose output (set logging level to '
-                     'INFO instead of default WARNING level).'),
-    ]
-
-    logging_cli_opts = [
-        StrOpt('log-config',
-               metavar='PATH',
-               help='If this option is specified, the logging configuration '
-                    'file specified is used and overrides any other logging '
-                    'options specified. Please see the Python logging module '
-                    'documentation for details on logging configuration '
-                    'files.'),
-        StrOpt('log-format',
-               default=DEFAULT_LOG_FORMAT,
-               metavar='FORMAT',
-               help='A logging.Formatter log message format string which may '
-                    'use any of the available logging.LogRecord attributes. '
-                    'Default: %(default)s'),
-        StrOpt('log-date-format',
-               default=DEFAULT_LOG_DATE_FORMAT,
-               metavar='DATE_FORMAT',
-               help='Format string for %%(asctime)s in log records. '
-                    'Default: %(default)s'),
-        StrOpt('log-file',
-               metavar='PATH',
-               deprecated_name='logfile',
-               help='(Optional) Name of log file to output to. '
-                    'If not set, logging will go to stdout.'),
-        StrOpt('log-dir',
-               deprecated_name='logdir',
-               help='(Optional) The directory to keep log files in '
-                    '(will be prepended to --log-file)'),
-        BoolOpt('use-syslog',
-                default=False,
-                help='Use syslog for logging.'),
-        StrOpt('syslog-log-facility',
-               default='LOG_USER',
-               help='syslog facility to receive log lines')
-    ]
-
-    def __init__(self):
-        super(CommonConfigOpts, self).__init__()
-        self.register_cli_opts(self.common_cli_opts)
-        self.register_cli_opts(self.logging_cli_opts)
-
-
-CONF = CommonConfigOpts()
+CONF = ConfigOpts()
index 9ef5441112600b7bced38b4606d94da5323849ff..e6e8414c3988fd0cc9d801cf1180814b1e9db133 100644 (file)
@@ -47,6 +47,67 @@ from quantum.openstack.common import local
 from quantum.openstack.common import notifier
 
 
+_DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
+_DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
+
+common_cli_opts = [
+    cfg.BoolOpt('debug',
+                short='d',
+                default=False,
+                help='Print debugging output (set logging level to '
+                     'DEBUG instead of default WARNING level).'),
+    cfg.BoolOpt('verbose',
+                short='v',
+                default=False,
+                help='Print more verbose output (set logging level to '
+                     'INFO instead of default WARNING level).'),
+]
+
+logging_cli_opts = [
+    cfg.StrOpt('log-config',
+               metavar='PATH',
+               help='If this option is specified, the logging configuration '
+                    'file specified is used and overrides any other logging '
+                    'options specified. Please see the Python logging module '
+                    'documentation for details on logging configuration '
+                    'files.'),
+    cfg.StrOpt('log-format',
+               default=_DEFAULT_LOG_FORMAT,
+               metavar='FORMAT',
+               help='A logging.Formatter log message format string which may '
+                    'use any of the available logging.LogRecord attributes. '
+                    'Default: %(default)s'),
+    cfg.StrOpt('log-date-format',
+               default=_DEFAULT_LOG_DATE_FORMAT,
+               metavar='DATE_FORMAT',
+               help='Format string for %%(asctime)s in log records. '
+                    'Default: %(default)s'),
+    cfg.StrOpt('log-file',
+               metavar='PATH',
+               deprecated_name='logfile',
+               help='(Optional) Name of log file to output to. '
+                    'If not set, logging will go to stdout.'),
+    cfg.StrOpt('log-dir',
+               deprecated_name='logdir',
+               help='(Optional) The directory to keep log files in '
+                    '(will be prepended to --log-file)'),
+    cfg.BoolOpt('use-syslog',
+                default=False,
+                help='Use syslog for logging.'),
+    cfg.StrOpt('syslog-log-facility',
+               default='LOG_USER',
+               help='syslog facility to receive log lines')
+]
+
+generic_log_opts = [
+    cfg.BoolOpt('use_stderr',
+                default=True,
+                help='Log output to standard error'),
+    cfg.StrOpt('logfile_mode',
+               default='0644',
+               help='Default file mode used when creating log files'),
+]
+
 log_opts = [
     cfg.StrOpt('logging_context_format_string',
                default='%(asctime)s.%(msecs)03d %(levelname)s %(name)s '
@@ -94,24 +155,9 @@ log_opts = [
                     'format it like this'),
 ]
 
-
-generic_log_opts = [
-    cfg.StrOpt('logdir',
-               default=None,
-               help='Log output to a per-service log file in named directory'),
-    cfg.StrOpt('logfile',
-               default=None,
-               help='Log output to a named file'),
-    cfg.BoolOpt('use_stderr',
-                default=True,
-                help='Log output to standard error'),
-    cfg.StrOpt('logfile_mode',
-               default='0644',
-               help='Default file mode used when creating log files'),
-]
-
-
 CONF = cfg.CONF
+CONF.register_cli_opts(common_cli_opts)
+CONF.register_cli_opts(logging_cli_opts)
 CONF.register_opts(generic_log_opts)
 CONF.register_opts(log_opts)
 
@@ -149,8 +195,8 @@ def _get_binary_name():
 
 
 def _get_log_file_path(binary=None):
-    logfile = CONF.log_file or CONF.logfile
-    logdir = CONF.log_dir or CONF.logdir
+    logfile = CONF.log_file
+    logdir = CONF.log_dir
 
     if logfile and not logdir:
         return logfile
index 7a26bc04f5e1f7cfbb1474df8217c5b853f115dd..c1fa6851f416cde616c82ae0f69c4682976acd4c 100644 (file)
@@ -56,7 +56,7 @@ cluster_opts = [
 cfg.CONF.register_opts(nvp_opts, "NVP")
 
 
-class ClusterConfigOptions(cfg.CommonConfigOpts):
+class ClusterConfigOptions(cfg.ConfigOpts):
 
     def __init__(self, config_options):
         super(ClusterConfigOptions, self).__init__()
index a7356323d7d66ebb772e0d130dade14b7036b870..1088489f044f0d52776d421e14a3269623f5e9ec 100644 (file)
@@ -35,7 +35,7 @@ HOSTNAME = 'myhost'
 class TestBasicRouterOperations(unittest2.TestCase):
 
     def setUp(self):
-        self.conf = cfg.CommonConfigOpts()
+        self.conf = cfg.ConfigOpts()
         self.conf.register_opts(base_config.core_opts)
         self.conf.register_opts(l3_agent.L3NATAgent.OPTS)
         self.conf.register_opts(interface.OPTS)