From 2d2a562194d2d5792b91c156879c9494184cb3d2 Mon Sep 17 00:00:00 2001 From: Sam Morrison Date: Thu, 7 Sep 2017 12:12:18 +1000 Subject: [PATCH] Set PROJECT_DOMAIN_NAME in generated v3 openrc Change-Id: I97435d2137b5bd74cd9f8ebfb927e4e28a0dc00a Closes-bug: 1715525 --- .../api_access/templates/api_access/openrc.sh.template | 2 ++ openstack_dashboard/dashboards/project/api_access/views.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/openstack_dashboard/dashboards/project/api_access/templates/api_access/openrc.sh.template b/openstack_dashboard/dashboards/project/api_access/templates/api_access/openrc.sh.template index 1c27c30571..ff576a0998 100644 --- a/openstack_dashboard/dashboards/project/api_access/templates/api_access/openrc.sh.template +++ b/openstack_dashboard/dashboards/project/api_access/templates/api_access/openrc.sh.template @@ -19,6 +19,8 @@ export OS_PROJECT_ID={{ tenant_id }} export OS_PROJECT_NAME="{{ tenant_name|shellfilter }}" export OS_USER_DOMAIN_NAME="{{ user_domain_name|shellfilter }}" if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi +export OS_PROJECT_DOMAIN_ID="{{ project_domain_id|shellfilter }}" +if [ -z "$OS_PROJECT_DOMAIN_ID" ]; then unset OS_PROJECT_DOMAIN_ID; fi # unset v2.0 items in case set unset OS_TENANT_ID diff --git a/openstack_dashboard/dashboards/project/api_access/views.py b/openstack_dashboard/dashboards/project/api_access/views.py index 9456f63384..4ef9c6df3d 100644 --- a/openstack_dashboard/dashboards/project/api_access/views.py +++ b/openstack_dashboard/dashboards/project/api_access/views.py @@ -136,6 +136,11 @@ def download_rc_file(request): # make v3 specific changes context['user_domain_name'] = request.user.user_domain_name + try: + project_domain_id = request.user.token.project['domain_id'] + except KeyError: + project_domain_id = '' + context['project_domain_id'] = project_domain_id # sanity fix for removing v2.0 from the url if present context['auth_url'], _ = utils.fix_auth_url_version_prefix( context['auth_url'])