Make openrc deployment file work with keystone v3

When using a deployment with keystone v3 the env variable
OS_IDENTITY_API_VERSION=3 is not written to ~/.rally/openrc.
This causes requests by the openstack cli to fail unless the user sets
that variable manually.
This patch fixes this issue by writing OS_IDENTITY_API_VERSION to the
openrc file when using a deployment.

Closes-Bug: #1683820

Change-Id: I591eeacdd96e71d13561a7edade297223da86f73
This commit is contained in:
Daniel Gonzalez 2017-04-18 16:07:32 +02:00
parent f64460817d
commit 055446b060
3 changed files with 9 additions and 10 deletions

View File

@ -290,6 +290,7 @@ class DeploymentCommands(object):
"export OS_USERNAME='%(username)s'\n"
"export OS_PASSWORD='%(password)s'\n"
"export OS_TENANT_NAME='%(tenant_name)s'\n"
"export OS_PROJECT_NAME='%(tenant_name)s'\n"
% credential)
if credential.get("region_name"):
env_file.write("export OS_REGION_NAME='%s'\n" %
@ -305,9 +306,10 @@ class DeploymentCommands(object):
if credential.get("https_cacert"):
env_file.write("export OS_CACERT='%s'\n" %
credential["https_cacert"])
if re.match(r"^/v3/?$", parse.urlparse(
if re.match(r"^[a-zA-Z0-9/\-_]*/v3/?$", parse.urlparse(
credential["auth_url"]).path) is not None:
env_file.write("export OS_USER_DOMAIN_NAME='%s'\n"
env_file.write("export OS_IDENTITY_API_VERSION=3\n"
"export OS_USER_DOMAIN_NAME='%s'\n"
"export OS_PROJECT_DOMAIN_NAME='%s'\n" %
(credential["user_domain_name"],
credential["project_domain_name"]))

View File

@ -34,12 +34,6 @@ function setUp () {
source ~/.rally/openrc admin admin
if [[ $(rally deployment config) == *"project_name"* ]]; then
export OS_IDENTITY_API_VERSION=3
else
export OS_IDENTITY_API_VERSION="2.0"
fi
OPENSTACK_SERVICES=$(openstack service list)
if [[ $OPENSTACK_SERVICES == *"glance"* ]]; then
openstack image list

View File

@ -296,7 +296,8 @@ class DeploymentCommandsTestCase(test.TestCase):
"export OS_AUTH_URL='fake_auth_url'\n"
"export OS_USERNAME='fake_username'\n"
"export OS_PASSWORD='fake_password'\n"
"export OS_TENANT_NAME='fake_tenant_name'\n")
"export OS_TENANT_NAME='fake_tenant_name'\n"
"export OS_PROJECT_NAME='fake_tenant_name'\n")
mock_symlink.assert_called_once_with(
os.path.expanduser("~/.rally/openrc-%s" % deployment_id),
os.path.expanduser("~/.rally/openrc"))
@ -337,8 +338,10 @@ class DeploymentCommandsTestCase(test.TestCase):
"export OS_AUTH_URL='http://localhost:5000/v3'\n"
"export OS_USERNAME='fake_username'\n"
"export OS_PASSWORD='fake_password'\n"
"export OS_TENANT_NAME='fake_tenant_name'\n")
"export OS_TENANT_NAME='fake_tenant_name'\n"
"export OS_PROJECT_NAME='fake_tenant_name'\n")
mock_file.return_value.write.assert_any_call(
"export OS_IDENTITY_API_VERSION=3\n"
"export OS_USER_DOMAIN_NAME='fake_user_domain'\n"
"export OS_PROJECT_DOMAIN_NAME='fake_project_domain'\n")
mock_symlink.assert_called_once_with(