Fix issue related to keystone version check

Update the keystone version check logic to use version
attribute to detect the keystone version. The current
check breaks the driver sync logic if the attribute
isn't present in the keystone client object.

Change-Id: I271f39b320aec080e84c47b41b53d32be6879af2
Closes-Bug: #1754589
This commit is contained in:
arunmani 2018-03-09 03:21:04 -05:00
parent 9ed13036de
commit 7f8aabe246
1 changed files with 6 additions and 4 deletions

View File

@ -779,11 +779,13 @@ class Utils(object):
constants.DEFAULT_STAGING_PROJECT_NAME
try:
projects = []
if hasattr(ks_client, 'v2') or hasattr(ks_client, 'v2.0'):
# For keystone V2
if hasattr(ks_client, 'version') and (ks_client.version
in ['v2', 'v2.0']):
# For keystone v2 version
projects = ks_client.tenants.list()
elif hasattr(ks_client, 'v3') or hasattr(ks_client, 'v3.0'):
# For keystone V3
elif hasattr(ks_client, 'version') and (ks_client.version
in ['v3', 'v3.0']:
# For keystone v3 version
projects = ks_client.projects.list()
for tenant in projects:
projectname = tenant.name