Merge "libvirt: fix secret so that volume attach works"

This commit is contained in:
Jenkins 2017-10-04 04:52:18 +00:00 committed by Gerrit Code Review
commit 5422465a6a
2 changed files with 5 additions and 17 deletions

View File

@ -30,12 +30,12 @@ if [[ -c /dev/kvm ]]; then
chown root:kvm /dev/kvm chown root:kvm /dev/kvm
fi fi
if [ "x${LIBVIRT_CEPH_ENABLED}" == "xTrue" ] ; then if [ -n "${LIBVIRT_CEPH_SECRET_UUID}" ] ; then
libvirtd --listen & libvirtd --listen &
LIBVIRT_SECRET_DEF=$(mktemp --suffix .xml) tmpsecret=$(mktemp --suffix .xml)
function cleanup { function cleanup {
rm -f ${LIBVIRT_SECRET_DEF} rm -f "${tmpsecret}"
} }
trap cleanup EXIT trap cleanup EXIT
@ -64,16 +64,11 @@ if [ "x${LIBVIRT_CEPH_ENABLED}" == "xTrue" ] ; then
fi fi
done done
if [ -z "${LIBVIRT_CEPH_SECRET_UUID}" ] ; then
echo "ERROR: No libvirt Secret UUID Supplied"
exit 1
fi
if [ -z "${CEPH_CINDER_KEYRING}" ] ; then 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) CEPH_CINDER_KEYRING=$(sed -n 's/^[[:space:]]*key[[:blank:]]\+=[[:space:]]\(.*\)/\1/p' /etc/ceph/ceph.client.${CEPH_CINDER_USER}.keyring)
fi fi
cat > ${LIBVIRT_SECRET_DEF} <<EOF cat > ${tmpsecret} <<EOF
<secret ephemeral='no' private='no'> <secret ephemeral='no' private='no'>
<uuid>${LIBVIRT_CEPH_SECRET_UUID}</uuid> <uuid>${LIBVIRT_CEPH_SECRET_UUID}</uuid>
<usage type='ceph'> <usage type='ceph'>
@ -82,7 +77,7 @@ if [ "x${LIBVIRT_CEPH_ENABLED}" == "xTrue" ] ; then
</secret> </secret>
EOF EOF
virsh secret-define --file ${LIBVIRT_SECRET_DEF} virsh secret-define --file ${tmpsecret}
virsh secret-set-value --secret "${LIBVIRT_CEPH_SECRET_UUID}" --base64 "${CEPH_CINDER_KEYRING}" virsh secret-set-value --secret "${LIBVIRT_CEPH_SECRET_UUID}" --base64 "${CEPH_CINDER_KEYRING}"
# rejoin libvirtd # rejoin libvirtd

View File

@ -46,9 +46,6 @@ spec:
securityContext: securityContext:
runAsUser: 0 runAsUser: 0
env: env:
{{- if .Values.ceph.enabled }}
- name: LIBVIRT_CEPH_ENABLED
value: "True"
- name: CEPH_CINDER_USER - name: CEPH_CINDER_USER
value: "{{ .Values.ceph.cinder_user }}" value: "{{ .Values.ceph.cinder_user }}"
{{- if .Values.ceph.cinder_keyring }} {{- if .Values.ceph.cinder_keyring }}
@ -57,10 +54,6 @@ spec:
{{ end }} {{ end }}
- name: LIBVIRT_CEPH_SECRET_UUID - name: LIBVIRT_CEPH_SECRET_UUID
value: "{{ .Values.ceph.secret_uuid }}" value: "{{ .Values.ceph.secret_uuid }}"
{{- else }}
- name: LIBVIRT_CEPH_ENABLED
value: "False"
{{- end }}
command: command:
- /tmp/ceph-keyring.sh - /tmp/ceph-keyring.sh
volumeMounts: volumeMounts: