openstack-helm/nova/templates/bin/_ceph-secret-define.sh.tpl
Pete Birley 0251c099ba Nova: Support Cinder Volume Attachement using Ceph Backend
This PS enables cinder volume attachment for nova when used with ceph.

Change-Id: I9772f38fb3a1a9af26bd92ee18a651d3372de64c
2017-08-25 14:07:34 -05:00

59 lines
1.6 KiB
Smarty

#!/bin/bash
{{/*
Copyright 2017 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 -x
LIBVIRT_SECRET_DEF=$(mktemp --suffix .xml)
function cleanup {
rm -f ${LIBVIRT_SECRET_DEF}
}
trap cleanup EXIT
set -ex
# Wait for the libvirtd is up
TIMEOUT=60
while [[ ! -f /var/run/libvirtd.pid ]]; do
if [[ ${TIMEOUT} -gt 0 ]]; then
let TIMEOUT-=1
sleep 1
else
echo "ERROR: Libvirt did not start in time"
exit 1
fi
done
if [ -z "${LIBVIRT_CEPH_SECRET_UUID}" ] ; then
echo "ERROR: No Libvirt Secret UUID Supplied"
exit 1
fi
if [ -z "${CEPH_CINDER_KEYRING}" ] ; then
CEPH_CINDER_KEYRING=$(sed -n 's/^[[:space:]]*key[[:blank:]]\+=[[:space:]]\(.*\)/\1/p' /etc/ceph/ceph.client.${CEPH_CINDER_USER}.keyring)
fi
cat > ${LIBVIRT_SECRET_DEF} <<EOF
<secret ephemeral='no' private='no'>
<uuid>${LIBVIRT_CEPH_SECRET_UUID}</uuid>
<usage type='ceph'>
<name>client.${CEPH_CINDER_USER}. secret</name>
</usage>
</secret>
EOF
virsh secret-define --file ${LIBVIRT_SECRET_DEF}
virsh secret-set-value --secret "${LIBVIRT_CEPH_SECRET_UUID}" --base64 "${CEPH_CINDER_KEYRING}"