From f98bda2cbb2f91041f6536254fd159f4fedb1095 Mon Sep 17 00:00:00 2001 From: Lan Qi song Date: Tue, 28 Jul 2015 15:56:58 +0800 Subject: [PATCH] Add keystone V3 support for service credentials Currently, service credentials don't support to specify the keystone V3 related options. This lead to alarm-evaluator service can't work well. This patch give the ability to specify os_user_domain_id, os_project_name, os_project_domain_id options to support keystone V3. Change-Id: I93dc8360de7fc04ff55661c44d4ad74be5b3de07 Closes-Bug: #1478796 --- aodh/evaluator/threshold.py | 3 +++ aodh/service.py | 9 +++++++++ aodh/tests/evaluator/test_threshold.py | 24 ++++++++++++++---------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/aodh/evaluator/threshold.py b/aodh/evaluator/threshold.py index e281c55e..d3aab584 100644 --- a/aodh/evaluator/threshold.py +++ b/aodh/evaluator/threshold.py @@ -66,6 +66,9 @@ class ThresholdEvaluator(evaluator.Evaluator): os_endpoint_type=auth_config.os_endpoint_type, insecure=auth_config.insecure, timeout=cfg.CONF.http_timeout, + os_user_domain_id=auth_config.os_user_domain_id, + os_project_name=auth_config.os_project_name, + os_project_domain_id=auth_config.os_project_domain_id, ) self.api_client = ceiloclient.get_client(2, **creds) return self.api_client diff --git a/aodh/service.py b/aodh/service.py index 1c11e877..b338f764 100644 --- a/aodh/service.py +++ b/aodh/service.py @@ -89,6 +89,15 @@ CLI_OPTS = [ default=False, help='Disables X.509 certificate validation when an ' 'SSL connection to Identity Service is established.'), + cfg.StrOpt('os-user-domain-id', + default=os.environ.get('OS_USER_DOMAIN_ID', 'default'), + help='The domain id of the user'), + cfg.StrOpt('os-project-domain-id', + default=os.environ.get('OS_PROJECT_DOMAIN_ID', 'default'), + help='The domain id of the user project'), + cfg.StrOpt('os-project-name', + default=os.environ.get('OS_PROJECT_NAME', 'admin'), + help='The user project name'), ] cfg.CONF.register_cli_opts(CLI_OPTS, group="service_credentials") diff --git a/aodh/tests/evaluator/test_threshold.py b/aodh/tests/evaluator/test_threshold.py index 7843e7a2..f2a651cb 100644 --- a/aodh/tests/evaluator/test_threshold.py +++ b/aodh/tests/evaluator/test_threshold.py @@ -421,16 +421,20 @@ class TestEvaluate(base.TestEvaluatorBase): self.evaluator.api_client = None self._evaluate_all_alarms() conf = self.conf.service_credentials - expected = [mock.call(2, - os_auth_url=conf.os_auth_url, - os_region_name=conf.os_region_name, - os_tenant_name=conf.os_tenant_name, - os_password=conf.os_password, - os_username=conf.os_username, - os_cacert=conf.os_cacert, - os_endpoint_type=conf.os_endpoint_type, - timeout=self.conf.http_timeout, - insecure=conf.insecure)] + expected = [mock.call( + 2, + os_auth_url=conf.os_auth_url, + os_region_name=conf.os_region_name, + os_tenant_name=conf.os_tenant_name, + os_password=conf.os_password, + os_username=conf.os_username, + os_cacert=conf.os_cacert, + os_endpoint_type=conf.os_endpoint_type, + timeout=self.conf.http_timeout, + insecure=conf.insecure, + os_user_domain_id=conf.os_user_domain_id, + os_project_name=conf.os_project_name, + os_project_domain_id=conf.os_project_domain_id)] actual = client.call_args_list self.assertEqual(expected, actual)