From 765b7d21d82c79baf07786fc99e58fc30823c4b3 Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Thu, 4 Aug 2011 11:10:40 -0700 Subject: [PATCH] Fix up nova_ctl upstart interaction --- hooks/nova-compute-common | 23 +++++++++++++++++++---- hooks/start | 1 + hooks/stop | 1 + metadata.yaml | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) create mode 120000 hooks/start create mode 120000 hooks/stop diff --git a/hooks/nova-compute-common b/hooks/nova-compute-common index 9ae78dc..83752ac 100755 --- a/hooks/nova-compute-common +++ b/hooks/nova-compute-common @@ -29,6 +29,17 @@ function set_or_update { fi } +function nova_ctl_status { + SERVICE=$1 + # workaround upstarts lack of scriptable return codes + STATUS=$(service nova-compute status | cut -d/ -f1 | awk '{ print $2 }') + case $STATUS in + "start") return 0 ;; + "stop") return 1 ;; + *) echo "ERROR: Unexpected status of service $I: $STATUS" && exit 1 ;; + esac +} + function nova_ctl { if [[ $1 == "all" ]] ; then CTL=$SERVICES @@ -41,10 +52,14 @@ function nova_ctl { exit 1 fi for i in $CTL ; do - service $i $ACTION - if [[ $? != 0 ]] ; then - ensemble-log "ERROR nova_ctl: Service $i failed to $ACTION" - fi + case $ACTION in + "start") + nova_ctl_status $i || service $i start ;; + "stop") + nova_ctl_status $i && service $i stop || return 0 ;; + "restart") + nova_ctl_status $i && service $i restart || service $i start ;; + esac done } diff --git a/hooks/start b/hooks/start new file mode 120000 index 0000000..6f9ff4f --- /dev/null +++ b/hooks/start @@ -0,0 +1 @@ +nova-compute-relations \ No newline at end of file diff --git a/hooks/stop b/hooks/stop new file mode 120000 index 0000000..6f9ff4f --- /dev/null +++ b/hooks/stop @@ -0,0 +1 @@ +nova-compute-relations \ No newline at end of file diff --git a/metadata.yaml b/metadata.yaml index 58ce8c8..0868e30 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -1,6 +1,6 @@ ensemble: formula name: nova-compute -revision: 16 +revision: 17 summary: "OpenStack compute" description: | OpenStack Compute, codenamed Nova, is a cloud computing fabric controller. In