Populate tenant information in client

Python-muranoclient uses tenant id when talking to glare to avoid
importing the same package twice. However tenant information was not
available in the CLI and tenant id defaulted to None.
This led to a situation, where it was possible to
import the same package multiple times if it was not public.

This patch fixes the issue by acquiring package information from
keystoneauth or from user-supplied values in case no-auth is enforced.

Murano dashboard was not affected by this issue.

Change-Id: I72ad006c76945bf5707172ab128a89f1f6a7b112
Closes-Bug: #1624943
(cherry picked from commit 9f8e6c3286)
This commit is contained in:
Kirill Zaitsev 2016-09-19 01:17:46 +03:00 committed by Valerii Kovalchuk
parent 0531b863da
commit 2600d963ff
2 changed files with 22 additions and 3 deletions

View File

@ -322,6 +322,17 @@ class MuranoShell(object):
" set murano-packages-service to 'glance'"
" you must also specify a glance glare API URL"
" via either --glare-url or env[GLARE_API]")
if (not any([args.os_tenant_id, args.os_project_id]) and
args.murano_packages_service == 'glare'):
# TODO(kzaitsev): see if we can use project's name here
# NOTE(kzaitsev): glare v0.1 needs project_id to operate
# correctly
raise exc.CommandError(
"If you specify --os-no-client-auth and"
" set murano-packages-service to 'glare'"
" you must also specify your project's id"
" via either --os-project-id or env[OS_PROJECT_ID] or"
" --os-tenant-id or env[OS_TENANT_ID]")
else:
# Tenant name or ID is needed to make keystoneclient retrieve a
@ -353,7 +364,8 @@ class MuranoShell(object):
'auth_url': args.os_auth_url,
'token': args.os_auth_token,
'insecure': args.insecure,
'timeout': args.api_timeout
'timeout': args.api_timeout,
'tenant': args.os_project_id or args.os_tenant_id,
}
glance_kwargs = kwargs.copy()
@ -395,11 +407,13 @@ class MuranoShell(object):
'session': keystone_session,
'auth': keystone_auth,
'service_type': service_type,
'endpoint_type': endpoint_type,
'region_name': args.os_region_name,
}
glance_kwargs = kwargs.copy()
del glance_kwargs['endpoint_type']
# glance doesn't need endpoint_type
kwargs['endpoint_type'] = endpoint_type
kwargs['tenant'] = keystone_auth.get_project_id(keystone_session)
if args.api_timeout:
kwargs['timeout'] = args.api_timeout

View File

@ -0,0 +1,5 @@
---
fixes:
- It was possible to import the same murano package from the CLI into the same
project multiple times if glare was used and the package was imported as a
private one. The issue is now fixed.