Rename "identity" section as "keystone" in tobiko.conf

Move all configuration options related to Keystone
API to [keystone] section.

This change also fixes a bug for configuring user and domain names
for Keystone API V3 protocol by allowing to define them via
a separate option.

Move the code that defines those options to
'tobiko.openstack.keystone' package.

These changes are intended to re-organize code and parameters by the
functionality they perform in package and subpackages that have as less
interdependency as possible in a 'aspect oriented' approach.

Change-Id: I61953150f4e3404b34b1e37310d9f2e35741ada7
This commit is contained in:
Federico Ressi 2019-03-12 15:50:10 +01:00
parent 8101082fb6
commit 0f82027663
5 changed files with 61 additions and 33 deletions

View File

@ -18,12 +18,13 @@ function configure_tobiko {
fi
# See ``lib/keystone`` where these users and tenants are set up
echo_summary "Write identity service options to ${TOBIKO_CONF}"
iniset "${tobiko_conf}" identity auth_url "$(get_auth_url)"
iniset "${tobiko_conf}" identity username "${ADMIN_USERNAME:-admin}"
iniset "${tobiko_conf}" identity password "${ADMIN_PASSWORD:-secret}"
iniset "${tobiko_conf}" identity project "${ADMIN_TENANT_NAME:-admin}"
iniset "${tobiko_conf}" identity domain "${ADMIN_DOMAIN_NAME:-Default}"
echo_summary "Write Keystone service options to ${TOBIKO_CONF}"
iniset "${tobiko_conf}" keystone auth_url "$(get_keystone_auth_url)"
iniset "${tobiko_conf}" keystone username "${ADMIN_USERNAME:-admin}"
iniset "${tobiko_conf}" keystone password "${ADMIN_PASSWORD:-secret}"
iniset "${tobiko_conf}" keystone project_name "${ADMIN_TENANT_NAME:-admin}"
iniset "${tobiko_conf}" keystone user_domain_name "${ADMIN_DOMAIN_NAME:-Default}"
iniset "${tobiko_conf}" keystone project_domain_name "${ADMIN_DOMAIN_NAME:-Default}"
echo_summary "Write compute service options to ${TOBIKO_CONF}"
iniset "${tobiko_conf}" compute image_ref "$(get_image_ref)"
@ -40,8 +41,8 @@ function configure_tobiko {
}
function get_auth_url {
echo "${KEYSTONE_SERVICE_URI_V3:-${KEYSTONE_SERVICE_URI/v2.0/}}"
function get_keystone_auth_url {
echo "${KEYSTONE_AUTH_URI_V3:-${KEYSTONE_AUTH_URI/v2.0}}"
}

View File

@ -33,14 +33,14 @@ def get_default_credentials(api_version=None, username=None, password=None,
username = (username or
config.get_any_option(
'environ.OS_USERNAME',
'tobiko.identity.username',
'tobiko.keystone.username',
'tempest.auth.username',
'tempest.auth.admin_username') or
'admin')
password = (password or
config.get_any_option(
'environ.OS_PASSWORD',
'tobiko.identity.password',
'tobiko.keystone.password',
'tempest.auth.password',
'tempest.auth.admin_password',
'tempest.identity.admin_password'))
@ -48,21 +48,21 @@ def get_default_credentials(api_version=None, username=None, password=None,
config.get_any_option(
'environ.OS_PROJECT_NAME',
'environ.OS_TENANT_NAME',
'tobiko.identity.project_name',
'tobiko.keystone.project_name',
'tempest.auth.project_name',
'tempest.auth.admin_project_name') or
'admin')
if auth_url is None and api_version in [None, 2]:
auth_url = config.get_any_option('environ.OS_AUTH_URL',
'tobiko.identity.auth_url',
'tobiko.keystone.auth_url',
'tempest.identity.uri')
if auth_url and api_version is None:
api_version = get_version_from_url(auth_url)
if auth_url is None:
auth_url = config.get_any_option('environ.OS_AUTH_URL',
'tobiko.identity.auth_url',
'tobiko.keystone.auth_url',
'tempest.identity.uri_v3')
if auth_url and api_version is None:
api_version = 3
@ -81,7 +81,7 @@ def get_default_credentials(api_version=None, username=None, password=None,
user_domain_name or
config.get_any_option(
'environ.OS_USER_DOMAIN_NAME',
'tobiko.identity.user_domain_name',
'tobiko.keystone.user_domain_name',
'tempest.auth.user_domain_name',
'tempest.auth.admin_domain_name') or
'admin'),
@ -89,7 +89,7 @@ def get_default_credentials(api_version=None, username=None, password=None,
project_domain_name or
config.get_any_option(
'environ.OS_PROJECT_DOMAIN_NAME',
'tobiko.identity.project_domain_name'
'tobiko.keystone.project_domain_name'
'tempest.identity.project_domain_name',
'tempest.auth.admin_domain_name',
'tempest.identity.admin_domain_name',

View File

@ -24,7 +24,8 @@ import tobiko
LOG = log.getLogger(__name__)
CONFIG_MODULES = ['tobiko.openstack.config']
CONFIG_MODULES = ['tobiko.openstack.config',
'tobiko.openstack.keystone.config']
CONFIG_DIRS = [os.getcwd(),
os.path.expanduser("~/.tobiko"),

View File

@ -18,23 +18,6 @@ from oslo_config import cfg
def register_tobiko_options(conf):
conf.register_opts(
group=cfg.OptGroup('identity'),
opts=[cfg.IntOpt('api_version',
help="Identity API version"),
cfg.StrOpt('auth_url',
help="Identity service URL"),
cfg.StrOpt('username',
help="Username"),
cfg.StrOpt('password',
help="Password"),
cfg.StrOpt('project_name',
help="Project name"),
cfg.StrOpt('user_domain_name',
help="User domain name"),
cfg.StrOpt('project_domain_name',
help="Project domain name")])
conf.register_opts(
group=cfg.OptGroup('compute'),
opts=[cfg.StrOpt('image_ref',

View File

@ -0,0 +1,43 @@
# Copyright 2019 Red Hat
#
# 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.
from __future__ import absolute_import
from oslo_config import cfg
def register_tobiko_options(conf):
conf.register_opts(
group=cfg.OptGroup('keystone'),
opts=[cfg.StrOpt('auth_url',
default=None,
help="Identity service URL"),
cfg.StrOpt('username',
default=None,
help="Username"),
cfg.StrOpt('project_name',
default=None,
help="Project name"),
cfg.StrOpt('password',
default=None,
help="Password"),
cfg.IntOpt('api_version',
default=None,
help="Identity API version"),
cfg.StrOpt('user_domain_name',
default=None,
help="User domain name"),
cfg.StrOpt('project_domain_name',
default=None,
help="Project domain name")])