From 8e404859a965ffc2165de689f388baa8a00033fe Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Sun, 22 May 2016 12:40:04 -0500 Subject: [PATCH] Add options to generated config sample Change-Id: I7b0447768c17805df0419968e028ac7c23615b78 --- .gitignore | 5 ++- etc/higgins/higgins-config-generator.conf | 8 +++++ higgins/api/middleware/auth_token.py | 2 +- higgins/api/middleware/parsable_error.py | 2 +- higgins/cmd/conductor.py | 2 +- higgins/common/keystone.py | 2 +- higgins/common/utils.py | 43 +++++++++++++++++++++++ higgins/objects/__init__.py | 0 higgins/opts.py | 17 ++++++++- 9 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 higgins/common/utils.py create mode 100644 higgins/objects/__init__.py diff --git a/.gitignore b/.gitignore index 3f1ed681f..bcea83544 100644 --- a/.gitignore +++ b/.gitignore @@ -56,4 +56,7 @@ ChangeLog *.DS_Store # Files created by releasenotes build -releasenotes/build \ No newline at end of file +releasenotes/build + +# generated config file +etc/higgins/higgins.conf.sample diff --git a/etc/higgins/higgins-config-generator.conf b/etc/higgins/higgins-config-generator.conf index ba1bb819f..878b64b46 100644 --- a/etc/higgins/higgins-config-generator.conf +++ b/etc/higgins/higgins-config-generator.conf @@ -3,3 +3,11 @@ output_file = etc/higgins/higgins.conf.sample wrap_width = 79 namespace = higgins +namespace = keystonemiddleware.auth_token +namespace = oslo.concurrency +namespace = oslo.db +namespace = oslo.log +namespace = oslo.messaging +namespace = oslo.policy +namespace = oslo.service.periodic_task +namespace = oslo.service.service diff --git a/higgins/api/middleware/auth_token.py b/higgins/api/middleware/auth_token.py index 470718c34..052674dbd 100644 --- a/higgins/api/middleware/auth_token.py +++ b/higgins/api/middleware/auth_token.py @@ -16,8 +16,8 @@ from keystonemiddleware import auth_token from oslo_log import log from higgins.common import exception +from higgins.common.i18n import _ from higgins.common import utils -from higgins.i18n import _ LOG = log.getLogger(__name__) diff --git a/higgins/api/middleware/parsable_error.py b/higgins/api/middleware/parsable_error.py index 5995f4aa0..e0fd9c344 100644 --- a/higgins/api/middleware/parsable_error.py +++ b/higgins/api/middleware/parsable_error.py @@ -21,7 +21,7 @@ Based on pecan.middleware.errordocument import json import six -from higgins.i18n import _ +from higgins.common.i18n import _ class ParsableErrorMiddleware(object): diff --git a/higgins/cmd/conductor.py b/higgins/cmd/conductor.py index 3f7a525a0..86335231e 100644 --- a/higgins/cmd/conductor.py +++ b/higgins/cmd/conductor.py @@ -19,11 +19,11 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_service import service +from higgins.common.i18n import _LI from higgins.common import rpc_service from higgins.common import service as higgins_service from higgins.common import short_id from higgins.conductor.handlers import default as default_handler -from higgins.i18n import _LI LOG = logging.getLogger(__name__) diff --git a/higgins/common/keystone.py b/higgins/common/keystone.py index 4fb174960..2b5986584 100644 --- a/higgins/common/keystone.py +++ b/higgins/common/keystone.py @@ -19,7 +19,7 @@ from oslo_config import cfg from oslo_log import log as logging from higgins.common import exception -from higgins.i18n import _LE +from higgins.common.i18n import _LE CONF = cfg.CONF CFG_GROUP = 'keystone_auth' diff --git a/higgins/common/utils.py b/higgins/common/utils.py new file mode 100644 index 000000000..2acd2839e --- /dev/null +++ b/higgins/common/utils.py @@ -0,0 +1,43 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# It's based on oslo.i18n usage in OpenStack Keystone project and +# recommendations from http://docs.openstack.org/developer/oslo.i18n/usage.html + +"""Utilities and helper functions.""" + +from oslo_log import log as logging +import six + +from higgins.common.i18n import _LW + + +LOG = logging.getLogger(__name__) + + +def safe_rstrip(value, chars=None): + """Removes trailing characters from a string if that does not make it empty + + :param value: A string value that will be stripped. + :param chars: Characters to remove. + :return: Stripped value. + + """ + if not isinstance(value, six.string_types): + LOG.warning(_LW( + "Failed to remove trailing character. Returning original object. " + "Supplied object is not a string: %s," + ), value) + return value + + return value.rstrip(chars) or value diff --git a/higgins/objects/__init__.py b/higgins/objects/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/higgins/opts.py b/higgins/opts.py index 016443ef8..2246c0ec9 100644 --- a/higgins/opts.py +++ b/higgins/opts.py @@ -10,6 +10,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import itertools + +import higgins.api.app +import higgins.common.keystone +import higgins.common.service +import higgins.conductor.config + def list_opts(): - return [] + return [ + ('DEFAULT', + itertools.chain( + higgins.common.service.service_opts, + )), + ('api', higgins.api.app.API_SERVICE_OPTS), + ('conductor', higgins.conductor.config.SERVICE_OPTS), + ('keystone_auth', higgins.common.keystone.keystone_auth_opts), + ]