From 2773ea9edda7ed24ba8ee780c7d6a2736dab5bdf Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Mon, 23 Jul 2018 17:00:26 +0800 Subject: [PATCH] Add opts file Added opts file added [oslo_limit] group. keystoneauth options and "endpoint_id" are in this group. Change-Id: I31e8f7c9f97b7175a7580f720383228e6f355f9a --- lower-constraints.txt | 2 ++ oslo_limit/opts.py | 55 ++++++++++++++++++++++++++++++++++ oslo_limit/tests/test_limit.py | 3 +- requirements.txt | 2 ++ setup.cfg | 4 +++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 oslo_limit/opts.py diff --git a/lower-constraints.txt b/lower-constraints.txt index 66d073e..3c1e64e 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -1,5 +1,7 @@ bandit==1.4.0 hacking==0.12.0 +keystoneauth1==3.9.0 +oslo.config==5.2.0 oslo.i18n==3.15.3 openstackdocstheme==1.20.0 oslotest==3.2.0 diff --git a/oslo_limit/opts.py b/oslo_limit/opts.py new file mode 100644 index 0000000..e42eac7 --- /dev/null +++ b/oslo_limit/opts.py @@ -0,0 +1,55 @@ +# 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. + +__all__ = [ + 'list_opts', + 'register_opts', +] + +import copy + +from keystoneauth1 import loading +from oslo_config import cfg + +from oslo_limit._i18n import _ + +CONF = cfg.CONF + +endpoint_id = cfg.StrOpt( + 'endpoint_id', + help=_("The service's endpoint id which is registered in Keystone.")) + +_options = [ + endpoint_id, +] + +_option_group = 'oslo_limit' + + +def list_opts(): + """Return a list of oslo.config options available in the library. + + :returns: a list of (group_name, opts) tuples + """ + + return [(_option_group, + copy.deepcopy(_options) + + loading.get_session_conf_options() + + loading.get_adapter_conf_options(include_deprecated=False) + )] + + +def register_opts(conf): + loading.register_session_conf_options(CONF, _option_group) + loading.register_adapter_conf_options(CONF, _option_group, + include_deprecated=False) + conf.register_opts(_options, group=_option_group) diff --git a/oslo_limit/tests/test_limit.py b/oslo_limit/tests/test_limit.py index 7205fc9..04e010a 100644 --- a/oslo_limit/tests/test_limit.py +++ b/oslo_limit/tests/test_limit.py @@ -21,9 +21,10 @@ Tests for `limit` module. import uuid -from oslo_limit import limit from oslotest import base +from oslo_limit import limit + class TestProjectClaim(base.BaseTestCase): diff --git a/requirements.txt b/requirements.txt index 3becfd9..d42afb2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. +keystoneauth1>=3.9.0 # Apache-2.0 +oslo.config>=5.2.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index c35a876..ebe66b7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,10 @@ classifier = packages = oslo_limit +[entry_points] +oslo.config.opts = + oslo.limit = oslo_limit.opts:list_opts + [compile_catalog] directory = oslo_limit/locale domain = oslo_limit