summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fried <efried@us.ibm.com>2017-07-26 16:04:05 -0500
committerEric Fried <efried@us.ibm.com>2017-07-26 16:16:01 -0500
commit81363eca7903c2dc01d39b4c1569a6750ff13502 (patch)
treeffa66631230510d1b4a0592cde2fe601fd98353f
parent5268d00218282ada986c0f15cf7508913014de19 (diff)
get_conf_options can exclude deprecated opts3.1.0
Add the ability to exclude deprecated conf options from Adapter.get_conf_options via a new kwarg, include_deprecated, which (for backward compatibility) defaults to True. Closes-Bug: #1706775 Change-Id: I9245d2b983482154959ba05d7d8496a947f1c701
Notes
Notes (review): Code-Review+1: Sean McGinnis <sean.mcginnis@gmail.com> Code-Review+2: Lance Bragstad <lbragstad@gmail.com> Code-Review+2: Monty Taylor <mordred@inaugust.com> Workflow+1: Monty Taylor <mordred@inaugust.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 26 Jul 2017 23:42:26 +0000 Reviewed-on: https://review.openstack.org/487590 Project: openstack/keystoneauth Branch: refs/heads/master
-rw-r--r--keystoneauth1/loading/adapter.py32
-rw-r--r--keystoneauth1/tests/unit/loading/test_adapter.py12
2 files changed, 32 insertions, 12 deletions
diff --git a/keystoneauth1/loading/adapter.py b/keystoneauth1/loading/adapter.py
index 24b1055..ccd7039 100644
--- a/keystoneauth1/loading/adapter.py
+++ b/keystoneauth1/loading/adapter.py
@@ -32,7 +32,7 @@ class Adapter(base.BaseLoader):
32 return [] 32 return []
33 33
34 @staticmethod 34 @staticmethod
35 def get_conf_options(): 35 def get_conf_options(include_deprecated=True):
36 """Get oslo_config options that are needed for a :py:class:`.Adapter`. 36 """Get oslo_config options that are needed for a :py:class:`.Adapter`.
37 37
38 These may be useful without being registered for config file generation 38 These may be useful without being registered for config file generation
@@ -63,24 +63,20 @@ class Adapter(base.BaseLoader):
63 range with min_version. Mutually exclusive with 63 range with min_version. Mutually exclusive with
64 version. 64 version.
65 65
66 :param include_deprecated: If True (the default, for backward
67 compatibility), deprecated options are
68 included in the result. If False, they are
69 excluded.
66 :returns: A list of oslo_config options. 70 :returns: A list of oslo_config options.
67 """ 71 """
68 cfg = _utils.get_oslo_config() 72 cfg = _utils.get_oslo_config()
69 73
70 return [cfg.StrOpt('service-type', 74 opts = [cfg.StrOpt('service-type',
71 help='The default service_type for endpoint URL ' 75 help='The default service_type for endpoint URL '
72 'discovery.'), 76 'discovery.'),
73 cfg.StrOpt('service-name', 77 cfg.StrOpt('service-name',
74 help='The default service_name for endpoint URL ' 78 help='The default service_name for endpoint URL '
75 'discovery.'), 79 'discovery.'),
76 cfg.StrOpt('interface',
77 help='The default interface for endpoint URL '
78 'discovery.',
79 deprecated_for_removal=True,
80 deprecated_reason='Using valid-interfaces is'
81 ' preferrable because it is'
82 ' capable of accepting a list of'
83 ' possible interfaces.'),
84 cfg.ListOpt('valid-interfaces', 80 cfg.ListOpt('valid-interfaces',
85 help='List of interfaces, in order of preference, ' 81 help='List of interfaces, in order of preference, '
86 'for endpoint URL.'), 82 'for endpoint URL.'),
@@ -108,6 +104,18 @@ class Adapter(base.BaseLoader):
108 'range with min_version. Mutually exclusive ' 104 'range with min_version. Mutually exclusive '
109 'with version.'), 105 'with version.'),
110 ] 106 ]
107 if include_deprecated:
108 opts += [
109 cfg.StrOpt('interface',
110 help='The default interface for endpoint URL '
111 'discovery.',
112 deprecated_for_removal=True,
113 deprecated_reason='Using valid-interfaces is'
114 ' preferrable because it is'
115 ' capable of accepting a list of'
116 ' possible interfaces.'),
117 ]
118 return opts
111 119
112 def register_conf_options(self, conf, group): 120 def register_conf_options(self, conf, group):
113 """Register the oslo_config options that are needed for an Adapter. 121 """Register the oslo_config options that are needed for an Adapter.
@@ -205,5 +213,5 @@ def load_from_conf_options(*args, **kwargs):
205 return Adapter().load_from_conf_options(*args, **kwargs) 213 return Adapter().load_from_conf_options(*args, **kwargs)
206 214
207 215
208def get_conf_options(): 216def get_conf_options(*args, **kwargs):
209 return Adapter.get_conf_options() 217 return Adapter.get_conf_options(*args, **kwargs)
diff --git a/keystoneauth1/tests/unit/loading/test_adapter.py b/keystoneauth1/tests/unit/loading/test_adapter.py
index 3c7d008..26ead1c 100644
--- a/keystoneauth1/tests/unit/loading/test_adapter.py
+++ b/keystoneauth1/tests/unit/loading/test_adapter.py
@@ -170,3 +170,15 @@ class ConfLoadingTests(utils.TestCase):
170 'region-name', 'endpoint-override', 'version', 170 'region-name', 'endpoint-override', 'version',
171 'min-version', 'max-version'}, 171 'min-version', 'max-version'},
172 {opt.name for opt in opts}) 172 {opt.name for opt in opts})
173
174 def test_get_conf_options_undeprecated(self):
175 opts = loading.get_adapter_conf_options(include_deprecated=False)
176 for opt in opts:
177 if opt.name != 'valid-interfaces':
178 self.assertIsInstance(opt, cfg.StrOpt)
179 else:
180 self.assertIsInstance(opt, cfg.ListOpt)
181 self.assertEqual({'service-type', 'service-name', 'valid-interfaces',
182 'region-name', 'endpoint-override', 'version',
183 'min-version', 'max-version'},
184 {opt.name for opt in opts})