summaryrefslogtreecommitdiff
path: root/oslo_middleware
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-08-27 12:53:18 +0000
committerGerrit Code Review <review@openstack.org>2015-08-27 12:53:18 +0000
commitb73aa5c3abcea74716e236e8fd41475a5dc8dbdd (patch)
tree1c1b46b494368bbe92d1c1bdb0bde910aa47de19 /oslo_middleware
parent6e7167cf63e1b45ad95cf63b3b9d3d8d3312b7a0 (diff)
parentea893e8ba417aeb13455acfda30b8337159b8536 (diff)
downloadoslo-middleware-2.8.0.tar.gz
Merge "Split option discovery function by middleware"2.8.0
Diffstat (limited to 'oslo_middleware')
-rw-r--r--oslo_middleware/opts.py83
-rw-r--r--oslo_middleware/tests/test_opts.py31
2 files changed, 112 insertions, 2 deletions
diff --git a/oslo_middleware/opts.py b/oslo_middleware/opts.py
index c19f272..883fb90 100644
--- a/oslo_middleware/opts.py
+++ b/oslo_middleware/opts.py
@@ -15,10 +15,14 @@
__all__ = [
'list_opts',
+ 'list_opts_sizelimit',
+ 'list_opts_ssl',
+ 'list_opts_cors'
]
import copy
+import itertools
from oslo_middleware import cors
from oslo_middleware import sizelimit
@@ -26,7 +30,83 @@ from oslo_middleware import ssl
def list_opts():
- """Return a list of oslo.config options available in the library.
+ """Return a list of oslo.config options for ALL of the middleware classes.
+
+ The returned list includes all oslo.config options which may be registered
+ at runtime by the library.
+
+ Each element of the list is a tuple. The first element is the name of the
+ group under which the list of elements in the second element will be
+ registered. A group name of None corresponds to the [DEFAULT] group in
+ config files.
+
+ This function is also discoverable via the 'oslo.concurrency' entry point
+ under the 'oslo.config.opts' namespace.
+
+ The purpose of this is to allow tools like the Oslo sample config file
+ generator to discover the options exposed to users by this library.
+
+ :returns: a list of (group_name, opts) tuples
+ """
+ return list(
+ itertools.chain(
+ list_opts_sizelimit(),
+ list_opts_ssl(),
+ list_opts_cors(),
+ )
+ )
+
+
+def list_opts_sizelimit():
+ """Return a list of oslo.config options for the sizelimit middleware.
+
+ The returned list includes all oslo.config options which may be registered
+ at runtime by the library.
+
+ Each element of the list is a tuple. The first element is the name of the
+ group under which the list of elements in the second element will be
+ registered. A group name of None corresponds to the [DEFAULT] group in
+ config files.
+
+ This function is also discoverable via the 'oslo.concurrency' entry point
+ under the 'oslo.config.opts' namespace.
+
+ The purpose of this is to allow tools like the Oslo sample config file
+ generator to discover the options exposed to users by this library.
+
+ :returns: a list of (group_name, opts) tuples
+ """
+ return [
+ ('oslo_middleware', copy.deepcopy(sizelimit._opts)),
+ ]
+
+
+def list_opts_ssl():
+ """Return a list of oslo.config options for the sizelimit middleware.
+
+ The returned list includes all oslo.config options which may be registered
+ at runtime by the library.
+
+ Each element of the list is a tuple. The first element is the name of the
+ group under which the list of elements in the second element will be
+ registered. A group name of None corresponds to the [DEFAULT] group in
+ config files.
+
+ This function is also discoverable via the 'oslo.concurrency' entry point
+ under the 'oslo.config.opts' namespace.
+
+ The purpose of this is to allow tools like the Oslo sample config file
+ generator to discover the options exposed to users by this library.
+
+ :returns: a list of (group_name, opts) tuples
+ """
+ return [
+ ('oslo_middleware', copy.deepcopy(ssl.OPTS)),
+ ]
+
+
+def list_opts_cors():
+ """Return a list of oslo.config options for the cors middleware.
The returned list includes all oslo.config options which may be registered
at runtime by the library.
@@ -45,7 +125,6 @@ def list_opts():
:returns: a list of (group_name, opts) tuples
"""
return [
- ('oslo_middleware', copy.deepcopy(sizelimit._opts + ssl.OPTS)),
('cors', copy.deepcopy(cors.CORS_OPTS)),
('cors.subdomain', copy.deepcopy(cors.CORS_OPTS))
]
diff --git a/oslo_middleware/tests/test_opts.py b/oslo_middleware/tests/test_opts.py
new file mode 100644
index 0000000..763d550
--- /dev/null
+++ b/oslo_middleware/tests/test_opts.py
@@ -0,0 +1,31 @@
+# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
+#
+# 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.
+
+from oslo_middleware import opts
+from oslotest.base import BaseTestCase
+
+
+class TestOptionDiscovery(BaseTestCase):
+
+ def test_all(self):
+ opts.list_opts()
+
+ def test_sizelimit(self):
+ opts.list_opts_sizelimit()
+
+ def test_cors(self):
+ opts.list_opts_cors()
+
+ def test_ssl(self):
+ opts.list_opts_ssl()