From 426055c48e3afcdb4aa5b68b7247a074e2f8ddf5 Mon Sep 17 00:00:00 2001
From: liyuanzhen
Date: Fri, 3 Jun 2016 07:00:15 +0100
Subject: [PATCH] OS_TENANT_NAME is not required when we have OS_PROJECT_NAME
Cinder support both v2 and v3 auth. Use v3 if possible.
In consideration of backwards compatibility, when we have
OS_PROJECT_NAME, the v2 auth should be ok because
tenant_name can be set by env[OS_PROJECT_NAME].
Change-Id: I9eed9c41a9deb5ecafa8d9e12f6d1b50d34f986d
Closes-Bug: #1588261
---
cinderclient/shell.py | 8 ++++++--
cinderclient/tests/functional/base.py | 3 ++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/cinderclient/shell.py b/cinderclient/shell.py
index 9b9513e6f..401e5f06b 100644
--- a/cinderclient/shell.py
+++ b/cinderclient/shell.py
@@ -265,6 +265,7 @@ class OpenStackCinderShell(object):
parser.add_argument('--os-tenant-name',
metavar='',
default=utils.env('OS_TENANT_NAME',
+ 'OS_PROJECT_NAME',
'CINDER_PROJECT_ID'),
help='Tenant name. '
'Default=env[OS_TENANT_NAME].')
@@ -274,6 +275,7 @@ class OpenStackCinderShell(object):
parser.add_argument('--os-tenant-id',
metavar='',
default=utils.env('OS_TENANT_ID',
+ 'OS_PROJECT_ID',
'CINDER_TENANT_ID'),
help='ID for the tenant. '
'Default=env[OS_TENANT_ID].')
@@ -732,8 +734,10 @@ class OpenStackCinderShell(object):
username = self.options.os_username
password = self.options.os_password
- tenant_id = self.options.os_tenant_id
- tenant_name = self.options.os_tenant_name
+ tenant_id = (self.options.os_tenant_id
+ or self.options.os_project_id)
+ tenant_name = (self.options.os_tenant_name
+ or self.options.os_project_name)
return v2_auth.Password(
v2_auth_url,
diff --git a/cinderclient/tests/functional/base.py b/cinderclient/tests/functional/base.py
index de8f665e0..8b291b661 100644
--- a/cinderclient/tests/functional/base.py
+++ b/cinderclient/tests/functional/base.py
@@ -34,7 +34,8 @@ def credentials():
username = os.environ.get('OS_USERNAME')
password = os.environ.get('OS_PASSWORD')
- tenant_name = os.environ.get('OS_TENANT_NAME')
+ tenant_name = (os.environ.get('OS_TENANT_NAME')
+ or os.environ.get('OS_PROJECT_NAME'))
auth_url = os.environ.get('OS_AUTH_URL')
config = six.moves.configparser.RawConfigParser()