Compatibility patch with python-cinder-12.0.2

Fixes "AttributeError: 'Namespace' object has no attribute 'os_tenant_id'"
for both Cinder checks.

Change-Id: I0f583d67a4f6e53ddc6763aae29600fabb93f249
This commit is contained in:
Martin Mágr 2018-04-27 16:19:55 +02:00
parent 1a3ca01844
commit bd5fafd74b
2 changed files with 16 additions and 5 deletions

View File

@ -41,7 +41,11 @@ def _check_cinder_api():
def quotas_list():
try:
return client.quotas.get(options.os_tenant_name)
return client.quotas.get(
getattr(options, 'os_project_name',
getattr(options, 'os_tenant_name', None)
)
)
except Exception as ex:
utils.critical(str(ex))
@ -95,8 +99,7 @@ class CinderUtils(object):
if not self.connection_done or force:
try:
# force a connection to the server
self.connection_done = self.client.limits.get(
tenant_id=self.project)
self.connection_done = self.client.limits.get()
except Exception as e:
utils.critical("Cannot connect to cinder: %s" % e)

View File

@ -238,8 +238,16 @@ class Cinder(object):
client = client.get_client_class(api_version)(
options.os_username,
options.os_password,
options.os_tenant_name,
tenant_id=options.os_tenant_id,
tenant_name=getattr(
options, 'os_project_name', getattr(
options, 'os_tenant_name', None
)
),
tenant_id=getattr(
options, 'os_project_id', getattr(
options, 'os_tenant_id', None
)
),
auth_url=options.os_auth_url,
region_name=options.os_region_name,
cacert=options.os_cacert,