From d1c8e778a733539695d89c21ed4746265e0f1edf Mon Sep 17 00:00:00 2001 From: Liang Fang Date: Mon, 25 Mar 2019 10:29:42 -0400 Subject: [PATCH] Add internal tenant id in conf Cinder raw cache feature requires internal tenant id be set in /etc/cinder/cinder.conf, something like: cinder_internal_tenant_project_id = b7455b8974bb4064ad247c8f375eae6c cinder_internal_tenant_user_id = f46924c112a14c80ab0a24a613d95eef This patch get or create if not exist intenal user id and project id, and then set in cinder.conf reference: Cinder cache feature: https://docs.openstack.org/cinder/latest/admin/blockstorage-image-volume-cache.html Story: 2004869 Task: 29121 Change-Id: I07954d2efa905a56ca8482d0ec147534c97d01ea Signed-off-by: Liang Fang --- cinder/templates/bin/_cinder-volume.sh.tpl | 3 +- .../bin/_create-internal-tenant-id.sh.tpl | 31 +++++++ .../bin/_retrieve-internal-tenant-id.sh.tpl | 32 +++++++ cinder/templates/configmap-bin.yaml | 4 + cinder/templates/deployment-volume.yaml | 31 +++++++ .../templates/job-create-internal-tenant.yaml | 83 +++++++++++++++++++ cinder/values.yaml | 4 + 7 files changed, 187 insertions(+), 1 deletion(-) create mode 100755 cinder/templates/bin/_create-internal-tenant-id.sh.tpl create mode 100755 cinder/templates/bin/_retrieve-internal-tenant-id.sh.tpl create mode 100644 cinder/templates/job-create-internal-tenant.yaml diff --git a/cinder/templates/bin/_cinder-volume.sh.tpl b/cinder/templates/bin/_cinder-volume.sh.tpl index 64aa3828aa..a248f35284 100644 --- a/cinder/templates/bin/_cinder-volume.sh.tpl +++ b/cinder/templates/bin/_cinder-volume.sh.tpl @@ -19,4 +19,5 @@ limitations under the License. set -ex exec cinder-volume \ --config-file /etc/cinder/cinder.conf \ - --config-file /etc/cinder/conf/backends.conf + --config-file /etc/cinder/conf/backends.conf \ + --config-file /tmp/pod-shared/internal_tenant.conf diff --git a/cinder/templates/bin/_create-internal-tenant-id.sh.tpl b/cinder/templates/bin/_create-internal-tenant-id.sh.tpl new file mode 100755 index 0000000000..105825644c --- /dev/null +++ b/cinder/templates/bin/_create-internal-tenant-id.sh.tpl @@ -0,0 +1,31 @@ +#!/bin/bash + +{{/* +Copyright 2019 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +set -ex + + +USER_PROJECT_ID=$(openstack project create --or-show --enable -f value -c id \ + --domain="${PROJECT_DOMAIN_ID}" \ + "${INTERNAL_PROJECT_NAME}"); + +USER_ID=$(openstack user create --or-show --enable -f value -c id \ + --domain="${USER_DOMAIN_ID}" \ + --project-domain="${PROJECT_DOMAIN_ID}" \ + --project="${USER_PROJECT_ID}" \ + "${INTERNAL_USER_NAME}"); + diff --git a/cinder/templates/bin/_retrieve-internal-tenant-id.sh.tpl b/cinder/templates/bin/_retrieve-internal-tenant-id.sh.tpl new file mode 100755 index 0000000000..b85f69fdc4 --- /dev/null +++ b/cinder/templates/bin/_retrieve-internal-tenant-id.sh.tpl @@ -0,0 +1,32 @@ +#!/bin/bash + +{{/* +Copyright 2019 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +set -ex + + +USER_PROJECT_ID=$(openstack project show -f value -c id \ + "${INTERNAL_PROJECT_NAME}"); + +USER_ID=$(openstack user show -f value -c id \ + "${INTERNAL_USER_NAME}"); + +tee /tmp/pod-shared/internal_tenant.conf <