enable Keystone v3 support for http_check detection plugin

To properly support Keystone V3, we must also properly convey
the domain information to the Keystone authentication plugins.

Change-Id: I8c6539cf692e090290cfdf104eb22530a625aadb
story: 2004655
This commit is contained in:
Guang Yee 2018-12-20 18:29:12 -08:00
parent 785b769179
commit dd5441cd40
2 changed files with 59 additions and 0 deletions

View File

@ -32,9 +32,15 @@ class HttpCheck(monasca_setup.detection.ArgsPlugin):
monasca-setup -d HttpCheck --detection_args \
"keystone_url=http://192.168.10.6/identity \
keystone_project=proj \
keystone_project_domain=Default \
keystone_user=usr \
keystone_user_domain=Default \
keystone_password=pass \
url=https://192.168.10.6"
NOTE: keystone_project_domain and keystone_user_domain are required
for Keystone V3. They are used to convey the project's domain name and
user's domain name respectively.
"""
def _detect(self):
@ -52,7 +58,9 @@ class HttpCheck(monasca_setup.detection.ArgsPlugin):
'name', 'use_keystone', 'collect_response_time'])
init_config = {'keystone_config': self._build_instance(['keystone_url',
'keystone_project',
'keystone_project_domain',
'keystone_user',
'keystone_user_domain',
'keystone_password'])}
# Normalize any boolean parameters
@ -69,9 +77,15 @@ class HttpCheck(monasca_setup.detection.ArgsPlugin):
if 'keystone_project' in init_config['keystone_config']:
init_config['keystone_config']['project_name'] = init_config['keystone_config']\
.pop('keystone_project')
if 'keystone_project_domain' in init_config['keystone_config']:
init_config['keystone_config']['project_domain_name'] = \
init_config['keystone_config'].pop('keystone_project_domain')
if 'keystone_user' in init_config['keystone_config']:
init_config['keystone_config']['username'] = init_config['keystone_config']\
.pop('keystone_user')
if 'keystone_user_domain' in init_config['keystone_config']:
init_config['keystone_config']['user_domain_name'] = \
init_config['keystone_config'].pop('keystone_user_domain')
if 'keystone_password' in init_config['keystone_config']:
init_config['keystone_config']['password'] = init_config['keystone_config']\
.pop('keystone_password')

View File

@ -0,0 +1,45 @@
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
# (C) Copyright 2018 SUSE LLC
# 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.
import unittest
from monasca_setup.detection.plugins.http_check import HttpCheck
class TestHttpCheck(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
def test_processs_keystone_global_args(self):
args = ('keystone_url=https://my.keystone.host.com/identity '
'keystone_user=foo keystone_password=testpasswd '
'keystone_project=test_project keystone_project_domain=bar '
'keystone_user_domain=bar use_keystone=True '
'url=https://myurl.com')
plugin = HttpCheck(None, args=args)
conf = plugin.build_config()
self.assertTrue('keystone_config' in conf['http_check']['init_config'])
expected_keystone_config = {
'keystone_url': 'https://my.keystone.host.com/identity',
'username': 'foo',
'password': 'testpasswd',
'project_name': 'test_project',
'project_domain_name': 'bar',
'user_domain_name': 'bar'
}
self.assertDictEqual(
expected_keystone_config,
conf['http_check']['init_config']['keystone_config'])