From 9a74961bafabc404f015fc5d8a9da969d263dad3 Mon Sep 17 00:00:00 2001 From: Amy Fong Date: Mon, 17 Mar 2014 14:14:48 -0400 Subject: OpenStack: Add to missing functionality in sysvinit scripts Add status/reload to sysvinit scripts Modify tgtd to make start/stop work better (borrowed from Debian's implementation) Signed-off-by: Amy Fong Signed-off-by: Bruce Ashfield --- .../python/python-ceilometer/ceilometer.init | 19 ++++- .../python/python-cinder/cinder-volume | 19 ++++- .../python/python-cinder/cinder.init | 19 ++++- .../python/python-glance/glance.init | 20 ++++- .../recipes-devtools/python/python-heat/heat.init | 19 ++++- .../python/python-horizon/horizon.init | 19 ++++- .../python/python-keystone/keystone | 19 ++++- .../python/python-neutron/neutron-agent.init | 19 ++++- .../python/python-neutron/neutron-server.init | 19 ++++- .../recipes-devtools/python/python-nova/nova-all | 19 ++++- .../python/python-nova/nova-consoleauth | 19 ++++- .../python/python-nova/nova-novncproxy | 19 ++++- .../recipes-devtools/python/python-nova/nova.init | 19 ++++- meta-openstack/recipes-support/tgt/files/tgtd.init | 86 +++++++++++++++------- 14 files changed, 281 insertions(+), 53 deletions(-) (limited to 'meta-openstack') diff --git a/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init b/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init index c726855..23ca780 100644 --- a/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init +++ b/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init @@ -58,6 +58,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -65,12 +77,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume index 3cc2aa3..2c9334e 100644 --- a/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume +++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume @@ -56,6 +56,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -63,12 +75,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-cinder/cinder.init b/meta-openstack/recipes-devtools/python/python-cinder/cinder.init index 7ae3dbf..0a3923a 100644 --- a/meta-openstack/recipes-devtools/python/python-cinder/cinder.init +++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder.init @@ -54,6 +54,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -61,12 +73,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-glance/glance.init b/meta-openstack/recipes-devtools/python/python-glance/glance.init index c61abaa..def500f 100644 --- a/meta-openstack/recipes-devtools/python/python-glance/glance.init +++ b/meta-openstack/recipes-devtools/python/python-glance/glance.init @@ -4,6 +4,7 @@ # Provides: # Required-Start: $remote_fs $network $syslog # Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Glance API server # Description: OpenStack Image Service (code-named Glance) API server @@ -57,6 +58,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -64,12 +77,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-heat/heat.init b/meta-openstack/recipes-devtools/python/python-heat/heat.init index a7a168d..e37c4c8 100644 --- a/meta-openstack/recipes-devtools/python/python-heat/heat.init +++ b/meta-openstack/recipes-devtools/python/python-heat/heat.init @@ -64,6 +64,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -71,12 +83,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-horizon/horizon.init b/meta-openstack/recipes-devtools/python/python-horizon/horizon.init index 65b96e4..994fbec 100644 --- a/meta-openstack/recipes-devtools/python/python-horizon/horizon.init +++ b/meta-openstack/recipes-devtools/python/python-horizon/horizon.init @@ -54,6 +54,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -61,12 +73,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-keystone/keystone b/meta-openstack/recipes-devtools/python/python-keystone/keystone index a5529df..463b05f 100644 --- a/meta-openstack/recipes-devtools/python/python-keystone/keystone +++ b/meta-openstack/recipes-devtools/python/python-keystone/keystone @@ -51,6 +51,18 @@ stop () rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -58,12 +70,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init b/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init index f575746..e02ea9e 100644 --- a/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init +++ b/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init @@ -50,6 +50,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -57,12 +69,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init b/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init index 387f602..bd1fe86 100644 --- a/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init +++ b/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init @@ -53,6 +53,18 @@ stop() rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -60,12 +72,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova-all b/meta-openstack/recipes-devtools/python/python-nova/nova-all index 5891759..b3ff40e 100644 --- a/meta-openstack/recipes-devtools/python/python-nova/nova-all +++ b/meta-openstack/recipes-devtools/python/python-nova/nova-all @@ -53,6 +53,18 @@ stop () rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -60,12 +72,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth b/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth index 13ad285..56561db 100644 --- a/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth +++ b/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth @@ -43,6 +43,19 @@ if ! [ -x ${DAEMON} ] ; then exit 0 fi +DESC="nova console" +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) test "$ENABLED" = "true" || exit 0 @@ -56,7 +69,7 @@ case "$1" in start-stop-daemon --stop --oknodo --pidfile ${PIDFILE} log_end_msg $? ;; - restart|force-reload) + restart|force-reload|reload) test "$ENABLED" = "true" || exit 1 $0 stop sleep 1 @@ -64,10 +77,10 @@ case "$1" in ;; status) test "$ENABLED" = "true" || exit 0 - status_of_proc -p $PIDFILE $DAEMON nova-consoleauth && exit 0 || exit $? + status ;; *) - echo "Usage: /etc/init.d/nova-consoleauth {start|stop|restart|force-reload|status}" + echo "Usage: /etc/init.d/nova-consoleauth {start|stop|restart|force-reload|status|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy b/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy index 76cd1df..c976194 100644 --- a/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy +++ b/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy @@ -40,6 +40,19 @@ if ! [ -x ${DAEMON} ] ; then exit 0 fi +DESC="nova vnc proxy" +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) test "$ENABLED" = "true" || exit 0 @@ -53,7 +66,7 @@ case "$1" in start-stop-daemon --stop --oknodo --pidfile ${PIDFILE} log_end_msg $? ;; - restart|force-reload) + restart|force-reload|reload) test "$ENABLED" = "true" || exit 1 $0 stop sleep 1 @@ -61,10 +74,10 @@ case "$1" in ;; status) test "$ENABLED" = "true" || exit 0 - status_of_proc -p $PIDFILE $DAEMON nova-novncproxy && exit 0 || exit $? + status ;; *) - echo "Usage: /etc/init.d/nova-novncproxy {start|stop|restart|force-reload|status}" + echo "Usage: /etc/init.d/nova-novncproxy {start|stop|restart|force-reload|status|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova.init b/meta-openstack/recipes-devtools/python/python-nova/nova.init index c317f84..5d298fd 100644 --- a/meta-openstack/recipes-devtools/python/python-nova/nova.init +++ b/meta-openstack/recipes-devtools/python/python-nova/nova.init @@ -57,6 +57,18 @@ stop () rm -f $PIDFILE } +status() +{ + pid=`cat $PIDFILE 2>/dev/null` + if [ -n "$pid" ]; then + if ps -p $pid >&- ; then + echo "$DESC is running" + return + fi + fi + echo "$DESC is not running" +} + case "$1" in start) start @@ -64,12 +76,15 @@ case "$1" in stop) stop ;; - restart|force-reload) + restart|force-reload|reload) stop start ;; + status) + status + ;; *) - echo "Usage: $0 {start|stop|force-reload|restart}" + echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac diff --git a/meta-openstack/recipes-support/tgt/files/tgtd.init b/meta-openstack/recipes-support/tgt/files/tgtd.init index 3408645..ab91190 100644 --- a/meta-openstack/recipes-support/tgt/files/tgtd.init +++ b/meta-openstack/recipes-support/tgt/files/tgtd.init @@ -12,43 +12,73 @@ DESC="tgtd" DAEMON="/usr/sbin/tgtd" -PIDFILE="/var/run/tgtd.pid" +TGTD_CONFIG=/etc/tgt/targets.conf 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 - echo -n "Starting $DESC..." - - start-stop-daemon --start --quiet --pidfile ${PIDFILE} \ - --make-pidfile --exec ${DAEMON} - - if [ $? -eq 0 ]; then - echo "done." - else + # Start tgtd first + $DAEMON &>/dev/null + RETVAL=$? + if [ "$RETVAL" -ne 0 ]; then echo "failed." + exit 1 fi + + # Put tgtd into "offline" state until all the targets are configured. + # We don't want initiators to (re)connect and fail the connection + # if it's not ready. + tgtadm --op update --mode sys --name State -v offline + # Configure the targets. + tgt-admin -e -c $TGTD_CONFIG + # Put tgtd into "ready" state. + tgtadm --op update --mode sys --name State -v ready + + echo "done." } stop () { echo -n "Stopping $DESC..." - start-stop-daemon --stop --quiet --pidfile $PIDFILE - if [ $? -eq 0 ]; then - echo "done." - else - echo "failed." + + # Remove all targets. It only removes targets which are not in use. + tgt-admin --update ALL -c /dev/null &>/dev/null + # tgtd will exit if all targets were removed + tgtadm --op delete --mode system &>/dev/null + RETVAL=$? + if [ "$RETVAL" -eq 107 ] ; then + if [ "$TASK" != "restart" ] ; then + exit 1 + fi + elif [ "$RETVAL" -ne 0 ] ; then + echo "Some initiators are still connected - could not stop tgtd" + exit 2 fi - rm -f $PIDFILE + echo -n +} + +reload() +{ + echo "Reloading configuration of $DESC" "$NAME" + # Update configuration for targets. Only targets which + # are not in use will be updated. + tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null + RETVAL=$? + if [ "$RETVAL" -eq 107 ] ; then + echo "tgtd is not running" + exit 1 + fi +} + +status() +{ + tgt-admin -s >/dev/null 2>&1 + RETVAL=$? + if [ "$RETVAL" -eq 107 ] ; then + echo "tgtd is not running" + else + echo "tgtd is running" + fi } case "$1" in @@ -62,6 +92,12 @@ case "$1" in stop start ;; + reload) + reload + ;; + status) + status + ;; *) echo "Usage: $0 {start|stop|force-reload|restart}" exit 1 -- cgit v1.2.3-54-g00ecf