From ea62a12407366f890b1a83d439e15072f5f4734c Mon Sep 17 00:00:00 2001 From: Mihai Prica Date: Thu, 25 Jul 2013 17:02:46 +0300 Subject: python-cinder: Update cinder-volume initscript and postinstall Cinder-volume requires the cinder-volumes volume group created. The backing file for this volume is created in the postinstall with a size of 2G on the first boot and the volume group is created at boot time in the cinder-volume initscript. Signed-off-by: Mihai Prica --- .../python/python-cinder/cinder-volume | 79 ++++++++++++++++++++++ .../python/python-cinder_2013.1.1.bb | 7 +- 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 meta-openstack/recipes-devtools/python/python-cinder/cinder-volume diff --git a/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume new file mode 100644 index 0000000..cdad401 --- /dev/null +++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume @@ -0,0 +1,79 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: cinder-volume +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Should-Start: postgresql rabbitmq-server +# Should-Stop: postgresql rabbitmq-server +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: OpenStack Block Storage (Cinder) - Volume +# Description: OpenStack Block Storage (Cinder) - Volume +### END INIT INFO + +DESC="cinder-volume" +DAEMON="/usr/bin/cinder-volume" +PIDFILE="/var/run/cinder-volume.pid" + +start() +{ + if [ -e $PIDFILE ]; then + PIDDIR=/proc/$(cat $PIDFILE) + if [ -d ${PIDDIR} ]; then + echo "$DESC already running." + exit 1 + else + echo "Removing stale PID file $PIDFILE" + rm -f $PIDFILE + fi + fi + + #Load volume group + DEV=`losetup -f --show /etc/cinder/volumes-backing` + if ! vgs cinder-volumes &> /dev/null ; then + vgcreate cinder-volumes $DEV + fi + + echo -n "Starting $DESC..." + + start-stop-daemon --start --quiet --background \ + --pidfile ${PIDFILE} --make-pidfile --exec ${DAEMON} + + if [ $? -eq 0 ]; then + echo "done." + else + echo "failed." + fi +} + +stop() +{ + echo -n "Stopping $DESC..." + start-stop-daemon --stop --quiet --pidfile $PIDFILE + if [ $? -eq 0 ]; then + echo "done." + else + echo "failed." + fi + rm -f $PIDFILE +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|force-reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|force-reload|restart}" + exit 1 + ;; +esac + +exit 0 diff --git a/meta-openstack/recipes-devtools/python/python-cinder_2013.1.1.bb b/meta-openstack/recipes-devtools/python/python-cinder_2013.1.1.bb index 95fa45b..83d583d 100644 --- a/meta-openstack/recipes-devtools/python/python-cinder_2013.1.1.bb +++ b/meta-openstack/recipes-devtools/python/python-cinder_2013.1.1.bb @@ -10,6 +10,7 @@ SRCNAME = "cinder" SRC_URI = "https://launchpad.net/${SRCNAME}/grizzly/${PV}/+download/${SRCNAME}-${PV}.tar.gz \ file://cinder.conf \ file://cinder.init \ + file://cinder-volume \ " SRC_URI[md5sum] = "8fbfbd8aad5f1a6d5e2a239b7801966d" @@ -41,8 +42,7 @@ do_install_append() { install -d ${D}${sysconfdir}/init.d sed 's:@suffix@:api:' < ${WORKDIR}/cinder.init >${WORKDIR}/cinder-api.init.sh install -m 0755 ${WORKDIR}/cinder-api.init.sh ${D}${sysconfdir}/init.d/cinder-api - sed 's:@suffix@:volume:' < ${WORKDIR}/cinder.init >${WORKDIR}/cinder-volume.init.sh - install -m 0755 ${WORKDIR}/cinder-volume.init.sh ${D}${sysconfdir}/init.d/cinder-volume + install -m 0755 ${WORKDIR}/cinder-volume ${D}${sysconfdir}/init.d/cinder-volume fi } @@ -61,6 +61,9 @@ pkg_postinst_${SRCNAME} () { sudo -u postgres createdb cinder cinder-manage db sync + + #Create cinder volume group backing file + [[ -f /etc/cinder/volumes-backing ]] || truncate -s 2G /etc/cinder/volumes-backing echo "include /etc/cinder/data/volumes/*" >> /etc/tgt/targets.conf } -- cgit v1.2.3-54-g00ecf