Read OS credentials from tobiko.conf
Change-Id: Ica0edc527397bfc04a3f5b4f081f641b544fc2a9
This commit is contained in:
parent
2f9b287b74
commit
194b5eb0b2
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@
|
||||
.test
|
||||
.testrepository
|
||||
.tox
|
||||
.vagrant
|
||||
.venv
|
||||
|
||||
__pycache__
|
||||
|
@ -5,23 +5,72 @@ TOBIKO_PLUGIN_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
|
||||
function tobiko_install {
|
||||
setup_dev_lib "tobiko"
|
||||
echo_summary "Installing tobiko-plugin"
|
||||
|
||||
setup_dev_lib "tobiko"
|
||||
}
|
||||
|
||||
|
||||
function tobiko_test_config {
|
||||
echo "TODO(fressi): generate tobiko.conf here"
|
||||
local tobiko_conf=$(mktemp)
|
||||
if [ -f "${TOBIKO_CONF}" ]; then
|
||||
cp "${TOBIKO_CONF}" "${tobiko_conf}"
|
||||
fi
|
||||
|
||||
# See ``lib/keystone`` where these users and tenants are set up
|
||||
echo_summary "Write identity 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 compute options to ${TOBIKO_CONF}"
|
||||
iniset "${tobiko_conf}" compute image_ref "$(get_image_ref)"
|
||||
iniset "${tobiko_conf}" compute flavor_ref "$(get_flavor_ref)"
|
||||
|
||||
echo_summary "Write network options to ${TOBIKO_CONF}"
|
||||
iniset "${tobiko_conf}" network floating_network_name \
|
||||
"$(get_floating_network_name)"
|
||||
|
||||
echo_summary "Apply changes to ${TOBIKO_CONF} file."
|
||||
sudo mkdir -p $(dirname "${TOBIKO_CONF}")
|
||||
sudo cp "${tobiko_conf}" "${TOBIKO_CONF}"
|
||||
}
|
||||
|
||||
|
||||
function get_auth_url {
|
||||
echo "${KEYSTONE_SERVICE_URI_V3:-${KEYSTONE_SERVICE_URI/v2.0/}}"
|
||||
}
|
||||
|
||||
function get_image_ref {
|
||||
local image_ids=( $(openstack image list -f value -c ID \
|
||||
--property status=active) )
|
||||
echo "${image_ids[0]}"
|
||||
}
|
||||
|
||||
|
||||
function get_flavor_ref {
|
||||
local flavor_ids=( $(openstack flavor list -f value -c ID \
|
||||
--public) )
|
||||
echo "${flavor_ids[0]}"
|
||||
}
|
||||
|
||||
|
||||
function get_floating_network_name {
|
||||
local networks=( $(openstack network list -f value -c Name \
|
||||
--enable --status ACTIVE \
|
||||
--provider-network-type flat) )
|
||||
echo "${networks[0]}"
|
||||
}
|
||||
|
||||
|
||||
if [[ "$1" == "stack" ]]; then
|
||||
case "$2" in
|
||||
install)
|
||||
echo_summary "Installing tobiko-plugin"
|
||||
tobiko_install
|
||||
;;
|
||||
test-config)
|
||||
echo_summary "Configuring tobiko options"
|
||||
tobiko_test_config
|
||||
;;
|
||||
esac
|
||||
|
@ -1,3 +1,5 @@
|
||||
GITREPO["tobiko"]=${TOBIKO_REPO:-${GIT_BASE}/openstack/tobiko.git}
|
||||
GITDIR["tobiko"]=$DEST/tobiko
|
||||
GITBRANCH["tobiko"]=master
|
||||
|
||||
TOBIKO_CONF=/etc/tobiko/tobiko.conf
|
||||
|
@ -46,30 +46,36 @@ def get_default_credentials(api_version=None, username=None, password=None,
|
||||
username = (username or
|
||||
config.get_any_option(
|
||||
'environ.OS_USERNAME',
|
||||
'tobiko.identity.username',
|
||||
'tempest.auth.username',
|
||||
'tempest.auth.admin_username') or
|
||||
'admin')
|
||||
password = (password or
|
||||
config.get_any_option(
|
||||
'environ.OS_PASSWORD',
|
||||
'tobiko.identity.password',
|
||||
'tempest.auth.password',
|
||||
'tempest.auth.admin_password'))
|
||||
project_name = (project_name or
|
||||
config.get_any_option(
|
||||
'environ.OS_PROJECT_NAME',
|
||||
'environ.OS_TENANT_NAME',
|
||||
'tobiko.identity.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', 'tempest.identity.uri')
|
||||
auth_url = config.get_any_option('environ.OS_AUTH_URL',
|
||||
'tobiko.identity.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('tempest.identity.uri_v3')
|
||||
auth_url = config.get_any_option('environ.OS_AUTH_URL',
|
||||
'tobiko.identity.auth_url',
|
||||
'tempest.identity.uri_v3')
|
||||
if auth_url and api_version is None:
|
||||
api_version = 3
|
||||
if auth_url is None:
|
||||
@ -87,6 +93,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',
|
||||
'tempest.auth.user_domain_name',
|
||||
'tempest.auth.admin_domain_name') or
|
||||
'admin'),
|
||||
@ -94,6 +101,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'
|
||||
'tempest.identity.project_domain_name',
|
||||
'tempest.auth.admin_domain_name',
|
||||
'tempest.identity.admin_domain_name',
|
||||
|
@ -17,12 +17,28 @@ from oslo_config import cfg
|
||||
|
||||
|
||||
def register_tobiko_options(conf):
|
||||
|
||||
conf.register_opts(
|
||||
group=cfg.OptGroup('identity'),
|
||||
opts=[cfg.StrOpt('auth_url',
|
||||
help="Default identity service URL"),
|
||||
cfg.StrOpt('username',
|
||||
help="Default username"),
|
||||
cfg.StrOpt('password',
|
||||
help="Default password"),
|
||||
cfg.StrOpt('domain_name',
|
||||
help="Default domain name"),
|
||||
cfg.StrOpt('project_name',
|
||||
help="Default project name"),
|
||||
])
|
||||
|
||||
conf.register_opts(
|
||||
group=cfg.OptGroup('compute'),
|
||||
opts=[cfg.StrOpt('image_ref',
|
||||
help="Default image reference"),
|
||||
cfg.StrOpt('flavor_ref',
|
||||
help="Default flavor reference")])
|
||||
|
||||
conf.register_opts(
|
||||
group=cfg.OptGroup('network'),
|
||||
opts=[cfg.StrOpt('floating_network_name',
|
||||
|
Loading…
Reference in New Issue
Block a user