diff --git a/castellan/options.py b/castellan/options.py index 6d450300..4a1b3653 100644 --- a/castellan/options.py +++ b/castellan/options.py @@ -21,7 +21,8 @@ except ImportError: 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. 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_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') 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: conf.set_default('barbican_api_version', barbican_api_version, 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(): diff --git a/castellan/tests/unit/test_options.py b/castellan/tests/unit/test_options.py index f0acb26d..2e445b11 100644 --- a/castellan/tests/unit/test_options.py +++ b/castellan/tests/unit/test_options.py @@ -38,3 +38,18 @@ class TestOptions(base.TestCase): options.set_defaults(conf, barbican_api_version=barbican_api_version) self.assertEqual(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)