From 9f8e6c3286c51f0c49b89c37e83de70ce93396b6 Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Mon, 19 Sep 2016 01:17:46 +0300 Subject: [PATCH] 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 --- muranoclient/shell.py | 20 ++++++++++++++++--- ...e-packages-glare-fix-b82a473ad976028f.yaml | 5 +++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/multiple-packages-glare-fix-b82a473ad976028f.yaml diff --git a/muranoclient/shell.py b/muranoclient/shell.py index 9c6b7236..e92d5b70 100644 --- a/muranoclient/shell.py +++ b/muranoclient/shell.py @@ -331,6 +331,17 @@ class MuranoShell(object): " set murano-packages-service to 'glare'" " you must also specify a 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 @@ -362,7 +373,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() @@ -404,11 +416,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 diff --git a/releasenotes/notes/multiple-packages-glare-fix-b82a473ad976028f.yaml b/releasenotes/notes/multiple-packages-glare-fix-b82a473ad976028f.yaml new file mode 100644 index 00000000..bdfced0b --- /dev/null +++ b/releasenotes/notes/multiple-packages-glare-fix-b82a473ad976028f.yaml @@ -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.