Can not set auth_endpoint in runtime
In rumtime castellan should be able to set auth_endpoint using options.set_defaults() which is critical for application to be able to adjust endpoint in runtime. https://bugs.launchpad.net/castellan/+bug/1515388 Change-Id: Ie918dcc4d28ec3507559e1b0c218995f6809c364 Closes-Bug: 1515388
This commit is contained in:
parent
d7e7bf3ac0
commit
132200244f
@ -21,7 +21,8 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
def set_defaults(conf, api_class=None, barbican_endpoint=None,
|
def set_defaults(conf, api_class=None, barbican_endpoint=None,
|
||||||
barbican_api_version=None):
|
barbican_api_version=None, auth_endpoint=None,
|
||||||
|
retry_delay=None, number_of_retries=None):
|
||||||
'''Set defaults for configuration values.
|
'''Set defaults for configuration values.
|
||||||
|
|
||||||
Overrides the default options values.
|
Overrides the default options values.
|
||||||
@ -33,6 +34,12 @@ def set_defaults(conf, api_class=None, barbican_endpoint=None,
|
|||||||
:param barbican_endpoint: Use this endpoint to connect to Barbican.
|
:param barbican_endpoint: Use this endpoint to connect to Barbican.
|
||||||
|
|
||||||
:param barbican_api_version: Version of the Barbican API.
|
:param barbican_api_version: Version of the Barbican API.
|
||||||
|
|
||||||
|
:param auth_endpoint: Use this endpoint to connect to Keystone.
|
||||||
|
|
||||||
|
:param retry_delay: Use this attribute to set retry delay.
|
||||||
|
|
||||||
|
:param number_of_retries: Use this attribute to set number of retries.
|
||||||
'''
|
'''
|
||||||
conf.register_opts(km.key_manager_opts, group='key_manager')
|
conf.register_opts(km.key_manager_opts, group='key_manager')
|
||||||
if bkm:
|
if bkm:
|
||||||
@ -46,6 +53,17 @@ def set_defaults(conf, api_class=None, barbican_endpoint=None,
|
|||||||
if bkm is not None and barbican_api_version is not None:
|
if bkm is not None and barbican_api_version is not None:
|
||||||
conf.set_default('barbican_api_version', barbican_api_version,
|
conf.set_default('barbican_api_version', barbican_api_version,
|
||||||
group=bkm.BARBICAN_OPT_GROUP)
|
group=bkm.BARBICAN_OPT_GROUP)
|
||||||
|
if bkm is not None and auth_endpoint is not None:
|
||||||
|
conf.set_default('auth_endpoint', auth_endpoint,
|
||||||
|
group=bkm.BARBICAN_OPT_GROUP)
|
||||||
|
|
||||||
|
if bkm is not None and retry_delay is not None:
|
||||||
|
conf.set_default('retry_delay', retry_delay,
|
||||||
|
group=bkm.BARBICAN_OPT_GROUP)
|
||||||
|
|
||||||
|
if bkm is not None and number_of_retries is not None:
|
||||||
|
conf.set_default('number_of_retries', number_of_retries,
|
||||||
|
group=bkm.BARBICAN_OPT_GROUP)
|
||||||
|
|
||||||
|
|
||||||
def list_opts():
|
def list_opts():
|
||||||
|
@ -38,3 +38,18 @@ class TestOptions(base.TestCase):
|
|||||||
options.set_defaults(conf, barbican_api_version=barbican_api_version)
|
options.set_defaults(conf, barbican_api_version=barbican_api_version)
|
||||||
self.assertEqual(barbican_api_version,
|
self.assertEqual(barbican_api_version,
|
||||||
conf.get(bkm.BARBICAN_OPT_GROUP).barbican_api_version)
|
conf.get(bkm.BARBICAN_OPT_GROUP).barbican_api_version)
|
||||||
|
|
||||||
|
auth_endpoint = 'http://test-server.org:5000/'
|
||||||
|
options.set_defaults(conf, auth_endpoint=auth_endpoint)
|
||||||
|
self.assertEqual(auth_endpoint,
|
||||||
|
conf.get(bkm.BARBICAN_OPT_GROUP).auth_endpoint)
|
||||||
|
|
||||||
|
retry_delay = 3
|
||||||
|
options.set_defaults(conf, retry_delay=retry_delay)
|
||||||
|
self.assertEqual(retry_delay,
|
||||||
|
conf.get(bkm.BARBICAN_OPT_GROUP).retry_delay)
|
||||||
|
|
||||||
|
number_of_retries = 10
|
||||||
|
options.set_defaults(conf, number_of_retries=number_of_retries)
|
||||||
|
self.assertEqual(number_of_retries,
|
||||||
|
conf.get(bkm.BARBICAN_OPT_GROUP).number_of_retries)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user