Fix bashate E006 violations

This commit fixes bashate E006 (lines longer than 79 columns) violations
in the OCF scripts.

Partial-Bug: #1550203
Change-Id: Ic208477b2299697a03b641f8272a0946c897fb3e
Signed-off-by: Norbert Illes <norbert.e.illes@ericsson.com>
This commit is contained in:
Norbert Illes 2016-02-29 13:08:26 +01:00
parent b64bdae693
commit 98a54ad759
22 changed files with 655 additions and 354 deletions

View File

@ -178,13 +178,15 @@ nova_start() {
return $OCF_SUCCESS
fi
state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | \
sed -e 's/.*value=//' | tr -d '"' )
if [ "x$state" = x ]; then
: no fencing to recover
elif [ "x$state" = xno ]; then
: has been evacuated, however it could have been 1s ago
ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to" \
"complete"
sleep ${OCF_RESKEY_evacuation_delay}
fence_compute ${fence_options} -o on -n ${NOVA_HOST}
@ -192,11 +194,13 @@ nova_start() {
else
ocf_log info "Waiting for pending evacuations from ${NOVA_HOST}"
while [ "x$state" != "xno" -a "x$state" != x ]; do
state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | \
sed -e 's/.*value=//' | tr -d '"' )
sleep 5
done
ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to" \
"complete"
sleep ${OCF_RESKEY_evacuation_delay}
fence_compute ${fence_options} -o on -n ${NOVA_HOST}
@ -297,7 +301,8 @@ nova_validate() {
fi
if [ -n "${OCF_RESKEY_region_name}" ]; then
fence_options="${fence_options} --region-name ${OCF_RESKEY_region_name}"
fence_options="${fence_options} \
--region-name ${OCF_RESKEY_region_name}"
fi
if [ -n "${OCF_RESKEY_insecure}" ]; then
@ -317,7 +322,8 @@ nova_validate() {
adminURL|publicURL|internalURL)
;;
*)
ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL"
ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type}" \
"not valid. Use adminURL or publicURL or internalURL"
exit $OCF_ERR_CONFIGURED
;;
esac
@ -342,12 +348,14 @@ nova_validate() {
if [ "x${OCF_RESKEY_domain}" != x ]; then
short_host=$(uname -n | awk -F. '{print $1}')
if [ "x$NOVA_HOST" != "x${short_host}" ]; then
ocf_exit_reason "Invalid Nova host name, must be ${short_host} in order for instance recovery to function"
ocf_exit_reason "Invalid Nova host name, must be" \
"${short_host} in order for instance recovery to function"
rc=$OCF_ERR_CONFIGURED
fi
elif [ "x$NOVA_HOST" != "x$(uname -n)" ]; then
ocf_exit_reason "Invalid Nova host name, must be $(uname -n) in order for instance recovery to function"
ocf_exit_reason "Invalid Nova host name, must be $(uname -n) in" \
"order for instance recovery to function"
rc=$OCF_ERR_CONFIGURED
fi
fi

View File

@ -197,12 +197,15 @@ handle_evacuations() {
now=$(date +%s)
if [ $(($now - $when)) -gt 60 ]; then
ocf_log info "Processing partial evacuation of $node by $where at $when"
ocf_log info "Processing partial evacuation of $node by" \
"$where at $when"
need_evacuate=1
else
# Give some time for any in-flight evacuations to either complete or fail
# Nova won't react well if there are two overlapping requests
ocf_log info "Deferring processing partial evacuation of $node by $where at $when"
# Give some time for any in-flight evacuations to either
# complete or fail Nova won't react well if there are two
# overlapping requests
ocf_log info "Deferring processing partial evacuation of" \
"$node by $where at $when"
fi
;;
esac
@ -211,7 +214,8 @@ handle_evacuations() {
found=0
ocf_log notice "Initiating evacuation of $node"
for known in $(fence_compute ${fence_options} -o list | tr -d ','); do
for known in $(fence_compute ${fence_options} -o list | \
tr -d ','); do
if [ ${known} = ${node} ]; then
found=1
break
@ -308,7 +312,8 @@ evacuate_validate() {
fi
if [ -n "${OCF_RESKEY_region_name}" ]; then
fence_options="${fence_options} --region-name ${OCF_RESKEY_region_name}"
fence_options="${fence_options} \
--region-name ${OCF_RESKEY_region_name}"
fi
if [ -n "${OCF_RESKEY_insecure}" ]; then
@ -328,7 +333,8 @@ evacuate_validate() {
adminURL|publicURL|internalURL)
;;
*)
ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL"
ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type}" \
"not valid. Use adminURL or publicURL or internalURL"
exit $OCF_ERR_CONFIGURED
;;
esac

View File

@ -3,7 +3,8 @@
#
# OpenStack Ceilometer Central Agent Service (ceilometer-agent-central)
#
# Description: Manages an OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) process as an HA resource
# Description: Manages an OpenStack Ceilometer Central Agent Service
# (ceilometer-agent-central) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
@ -194,7 +195,8 @@ ceilometer_agent_central_status() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) is not running"
ocf_log info "OpenStack Ceilometer Central Agent" \
"(ceilometer-agent-central) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -205,7 +207,8 @@ ceilometer_agent_central_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Ceilometer Central Agent (ceilometer-agent-central) is not running"
ocf_log info "Old PID file found, but OpenStack Ceilometer Central" \
"Agent (ceilometer-agent-central) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -224,16 +227,20 @@ ceilometer_agent_central_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the scheduler process and not other Cinder process with the same connection behavior (for example cinder-api)
# We are sure to hit the scheduler process and not other Cinder process
# with the same connection behavior (for example cinder-api)
pid=`cat $OCF_RESKEY_pid`
scheduler_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
scheduler_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Central Agent is not connected to the AMQP server : $rc"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Ceilometer Central Agent (ceilometer-agent-central) monitor succeeded"
ocf_log debug "OpenStack Ceilometer Central Agent" \
"(ceilometer-agent-central) monitor succeeded"
return $OCF_SUCCESS
}
@ -243,14 +250,18 @@ ceilometer_agent_central_start() {
ceilometer_agent_central_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) already running"
ocf_log info "OpenStack Ceilometer Central Agent" \
"(ceilometer-agent-central) already running"
return $OCF_SUCCESS
fi
# run the actual ceilometer-agent-central daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual ceilometer-agent-central daemon. Don't use ocf_run as
# we're sending the tool's output straight to /dev/null anyway and using
# ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
@ -258,13 +269,15 @@ ceilometer_agent_central_start() {
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Ceilometer Central Agent (ceilometer-agent-central) start failed"
ocf_log err "OpenStack Ceilometer Central Agent" \
"(ceilometer-agent-central) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) started"
ocf_log info "OpenStack Ceilometer Central Agent \
(ceilometer-agent-central) started"
return $OCF_SUCCESS
}
@ -275,7 +288,8 @@ ceilometer_agent_central_stop() {
ceilometer_agent_central_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) already stopped"
ocf_log info "OpenStack Ceilometer Central Agent \
(ceilometer-agent-central) already stopped"
return $OCF_SUCCESS
fi
@ -284,7 +298,8 @@ ceilometer_agent_central_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Ceilometer Central Agent (ceilometer-agent-central) couldn't be stopped"
ocf_log err "OpenStack Ceilometer Central Agent \
(ceilometer-agent-central) couldn't be stopped"
exit $OCF_ERR_GENERIC
fi
@ -302,19 +317,22 @@ ceilometer_agent_central_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Ceilometer Central Agent (ceilometer-agent-central) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Ceilometer Central Agent \
(ceilometer-agent-central) still hasn't stopped yet. Waiting ..."
done
ceilometer_agent_central_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Ceilometer Central Agent \
(ceilometer-agent-central) failed to stop after \
${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) stopped"
ocf_log info "OpenStack Ceilometer Central Agent \
(ceilometer-agent-central) stopped"
rm -f $OCF_RESKEY_pid

View File

@ -3,7 +3,8 @@
#
# OpenStack Cinder API (cinder-api)
#
# Description: Manages an OpenStack Cinder API (cinder-api) process as an HA resource
# Description: Manages an OpenStack Cinder API (cinder-api) process as an HA
# resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova API written by Sebastien Han
@ -39,14 +40,14 @@ OCF_RESKEY_config_default="/etc/cinder/cinder.conf"
OCF_RESKEY_user_default="cinder"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_url_default="http://127.0.0.1:8776/v1/"
OCF_RESKEY_keystone_get_token_url_default="http://127.0.0.1:5000/v2.0/tokens"
OCF_RESKEY_keystone_get_token_url_def="http://127.0.0.1:5000/v2.0/tokens"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_url=${OCF_RESKEY_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_def}}
#######################################################################
@ -127,7 +128,7 @@ The default URL to use to acquire a Cinder API (cinder-api) token for monitoring
of OpenStack Cinder API (cinder-api)
</longdesc>
<shortdesc lang="en">OpenStack Cinder API (cinder-api) url</shortdesc>
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_default}" />
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_def}" />
</parameter>
<parameter name="os_username" unique="0" required="0">
@ -225,7 +226,8 @@ cinder_api_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Cinder API (cinder-api) is not running"
ocf_log info "Old PID file found, but OpenStack Cinder API" \
"(cinder-api) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -245,15 +247,21 @@ cinder_api_monitor() {
# Check detailed information about this specific version of the API.
if [ -n "$OCF_RESKEY_os_username" ] && [ -n "$OCF_RESKEY_os_password" ] \
&& [ -n "$OCF_RESKEY_os_tenant_name" ] && [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": {\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" $OCF_RESKEY_keystone_get_token_url | tr ',' '\n' | grep '"id":' \
| cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null -sH "X-Auth-Token: $token" $OCF_RESKEY_url`
&& [ -n "$OCF_RESKEY_os_tenant_name" ] \
&& [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": \
{\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \
\"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" \
$OCF_RESKEY_keystone_get_token_url | \
tr ',' '\n' | grep '"id":' | cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null \
-sH "X-Auth-Token: $token" $OCF_RESKEY_url`
rc=$?
if [ $rc -ne 0 ] || [ $http_code -ne 200 ]; then
ocf_log err "Failed to connect to the OpenStack Cinder API (cinder-api): $rc and $http_code"
ocf_log err "Failed to connect to the OpenStack Cinder API" \
"(cinder-api): $rc and $http_code"
return $OCF_NOT_RUNNING
fi
fi
@ -272,10 +280,13 @@ cinder_api_start() {
return $OCF_SUCCESS
fi
# run the actual cinder-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual cinder-api daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break
# stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -328,15 +339,16 @@ cinder_api_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Cinder API (cinder-api) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Cinder API (cinder-api) still hasn't" \
"stopped yet. Waiting ..."
done
cinder_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Cinder API (cinder-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Cinder API (cinder-api) failed to stop after" \
"${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,7 +3,8 @@
#
# OpenStack Cinder Scheduler Service (cinder-schedule)
#
# Description: Manages an OpenStack Cinder Scheduler Service (cinder-schedule) process as an HA resource
# Description: Manages an OpenStack Cinder Scheduler Service (cinder-schedule)
# process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
@ -194,7 +195,8 @@ cinder_scheduler_status() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) is not running"
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) is not" \
"running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -205,7 +207,8 @@ cinder_scheduler_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Cinder Scheduler (cinder-schedule) is not running"
ocf_log info "Old PID file found, but OpenStack Cinder Scheduler" \
"(cinder-schedule) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -224,16 +227,21 @@ cinder_scheduler_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the scheduler process and not other Cinder process with the same connection behavior (for example cinder-api)
# We are sure to hit the scheduler process and not other Cinder process
# with the same connection behavior (for example cinder-api)
pid=`cat $OCF_RESKEY_pid`
scheduler_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
scheduler_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Cinder Scheduler is not connected to the AMQP server : $rc"
ocf_log err "Cinder Scheduler is not connected to the AMQP server : " \
"$rc"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Cinder Scheduler (cinder-schedule) monitor succeeded"
ocf_log debug "OpenStack Cinder Scheduler (cinder-schedule) monitor" \
"succeeded"
return $OCF_SUCCESS
}
@ -243,14 +251,18 @@ cinder_scheduler_start() {
cinder_scheduler_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) already running"
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) already" \
"running"
return $OCF_SUCCESS
fi
# run the actual cinder-schedule daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual cinder-schedule daemon. Don't use ocf_run as we're sending
# the tool's output straight to /dev/null anyway and using ocf_run would
# break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
@ -275,7 +287,8 @@ cinder_scheduler_stop() {
cinder_scheduler_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) already stopped"
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) already" \
"stopped"
return $OCF_SUCCESS
fi
@ -284,7 +297,8 @@ cinder_scheduler_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Cinder Scheduler (cinder-schedule) couldn't be stopped"
ocf_log err "OpenStack Cinder Scheduler (cinder-schedule) couldn't" \
"be stopped"
exit $OCF_ERR_GENERIC
fi
@ -302,15 +316,16 @@ cinder_scheduler_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Cinder Scheduler (cinder-schedule) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Cinder Scheduler (cinder-schedule) still" \
"hasn't stopped yet. Waiting ..."
done
cinder_scheduler_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Cinder Scheduler (cinder-schedule) failed to" \
"stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack Cinder Volume (cinder-volume)
#
# Description: Manages an OpenStack Volumes (cinder-volume) process as an HA resource
# Description: Manages an OpenStack Volumes (cinder-volume) process as an HA
# resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Glance API resource agent written by Martin Gerhard
# Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -193,7 +195,8 @@ cinder_volume_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Cinder Volume (cinder-volume) is not running"
ocf_log info "Old PID file found, but OpenStack Cinder Volume" \
"(cinder-volume) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -217,21 +220,28 @@ cinder_volume_monitor() {
if ocf_is_true "$OCF_RESKEY_multibackend"; then
# Grab the child's PIDs
for i in `ps -o pid --no-headers --ppid $pid`; do
volume_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$i" | grep -qs "ESTABLISHED"`
volume_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$i" | \
grep -qs "ESTABLISHED"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "This child process from Cinder Volume is not connected to the AMQP server: $rc"
ocf_log err "This child process from Cinder Volume is not" \
"connected to the AMQP server: $rc"
return $OCF_NOT_RUNNING
fi
done
else
# Check the connections according to the PID
# We are sure to hit the scheduler process and not other nova process with the same connection behavior (for example nova-cert)
# We are sure to hit the scheduler process and not other nova process
# with the same connection behavior (for example nova-cert)
# check the connections according to the PID
volume_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
volume_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Cinder Volume is not connected to the AMQP server: $rc"
ocf_log err "Cinder Volume is not connected to the AMQP server:" \
"$rc"
return $OCF_NOT_RUNNING
fi
fi
@ -250,10 +260,13 @@ cinder_volume_start() {
return $OCF_SUCCESS
fi
# run the actual cinder-volume daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual cinder-volume daemon. Don't use ocf_run as we're sending
# the tool's output straight to /dev/null anyway and using ocf_run would
# break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -288,7 +301,8 @@ cinder_volume_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Cinder Volume (cinder-volume) couldn't be stopped"
ocf_log err "OpenStack Cinder Volume (cinder-volume) couldn't be" \
"stopped"
exit $OCF_ERR_GENERIC
fi
@ -306,15 +320,16 @@ cinder_volume_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Cinder Volume (cinder-volume) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Cinder Volume (cinder-volume) still hasn't" \
"stopped yet. Waiting ..."
done
cinder_volume_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Cinder Volume (cinder-volume) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Cinder Volume (cinder-volume) failed to stop" \
"after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,7 +3,8 @@
#
# OpenStack ImageService (glance-api)
#
# Description: Manages an OpenStack ImageService (glance-api) process as an HA resource
# Description: Manages an OpenStack ImageService (glance-api) process as an HA
# resource
#
# Authors: Martin Gerhard Loschwitz
#
@ -219,7 +220,8 @@ glance_api_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack ImageService (glance-api) is not running"
ocf_log info "Old PID file found, but OpenStack ImageService" \
"(glance-api) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -237,7 +239,8 @@ glance_api_monitor() {
# Monitor the RA by retrieving the image list
if [ -n "$OCF_RESKEY_os_username" ] && [ -n "$OCF_RESKEY_os_password" ] \
&& [ -n "$OCF_RESKEY_os_tenant_name" ] && [ -n "$OCF_RESKEY_os_auth_url" ]; then
&& [ -n "$OCF_RESKEY_os_tenant_name" ] \
&& \ [ -n "$OCF_RESKEY_os_auth_url" ]; then
ocf_run -q $OCF_RESKEY_client_binary \
--os_username "$OCF_RESKEY_os_username" \
--os_password "$OCF_RESKEY_os_password" \
@ -246,7 +249,8 @@ glance_api_monitor() {
index > /dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Failed to connect to the OpenStack ImageService (glance-api): $rc"
ocf_log err "Failed to connect to the OpenStack ImageService" \
"(glance-api): $rc"
return $OCF_NOT_RUNNING
fi
fi
@ -265,10 +269,13 @@ glance_api_start() {
return $OCF_SUCCESS
fi
# run the actual glance-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file $OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual glance-api daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break
# stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file $OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -321,15 +328,16 @@ glance_api_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack ImageService (glance-api) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack ImageService (glance-api) still hasn't" \
"stopped yet. Waiting ..."
done
glance_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack ImageService (glance-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack ImageService (glance-api) failed to stop" \
"after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,7 +3,8 @@
#
# OpenStack ImageService (glance-registry)
#
# Description: Manages an OpenStack ImageService (glance-registry) process as an HA resource
# Description: Manages an OpenStack ImageService (glance-registry) process as
# an HA resource
#
# Authors: Martin Gerhard Loschwitz
#
@ -40,14 +41,14 @@ OCF_RESKEY_config_default="/etc/glance/glance-registry.conf"
OCF_RESKEY_user_default="glance"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_url_default="http://127.0.0.1:9191/images"
OCF_RESKEY_keystone_get_token_url_default="http://127.0.0.1:5000/v2.0/tokens"
OCF_RESKEY_keystone_get_token_url_def="http://127.0.0.1:5000/v2.0/tokens"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_url=${OCF_RESKEY_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_def}}
#######################################################################
@ -128,7 +129,7 @@ The default URL to use to acquire a ImageService (glance-registry) token for mon
of OpenStack ImageService (glance-registry)
</longdesc>
<shortdesc lang="en">OpenStack ImageService (glance-registry) url</shortdesc>
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_default}" />
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_def}" />
</parameter>
<parameter name="os_username" unique="0" required="0">
@ -226,7 +227,8 @@ glance_registry_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack ImageService (glance-registry) is not running"
ocf_log info "Old PID file found, but OpenStack ImageService" \
"(glance-registry) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -247,15 +249,21 @@ glance_registry_monitor() {
# Check whether we are supposed to monitor by logging into glance-registry
# and do it if that's the case.
if [ -n "$OCF_RESKEY_os_username" ] && [ -n "$OCF_RESKEY_os_password" ] \
&& [ -n "$OCF_RESKEY_os_tenant_name" ] && [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": {\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" $OCF_RESKEY_keystone_get_token_url | tr ',' '\n' | grep '"id":' \
| cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null -sH "X-Auth-Token: $token" $OCF_RESKEY_url`
&& [ -n "$OCF_RESKEY_os_tenant_name" ] \
&& [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": \
{\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \
\"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" \
$OCF_RESKEY_keystone_get_token_url | \
tr ',' '\n' | grep '"id":' | cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null \
-sH "X-Auth-Token: $token" $OCF_RESKEY_url`
rc=$?
if [ $rc -ne 0 ] || [ $http_code -ne 200 ]; then
ocf_log err "Failed to connect to the OpenStack ImageService (glance-registry): $rc and $http_code"
ocf_log err "Failed to connect to the OpenStack ImageService" \
"(glance-registry): $rc and $http_code"
return $OCF_NOT_RUNNING
fi
fi
@ -274,10 +282,13 @@ glance_registry_start() {
return $OCF_SUCCESS
fi
# run the actual glance-registry daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file $OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual glance-registry daemon. Don't use ocf_run as we're sending
# the tool's output straight to /dev/null anyway and using ocf_run would
# break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file $OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -312,7 +323,8 @@ glance_registry_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack ImageService (glance-registry) couldn't be stopped"
ocf_log err "OpenStack ImageService (glance-registry) couldn't be" \
"stopped"
exit $OCF_ERR_GENERIC
fi
@ -330,15 +342,16 @@ glance_registry_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack ImageService (glance-registry) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack ImageService (glance-registry) still hasn't" \
"stopped yet. Waiting ..."
done
glance_registry_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack ImageService (glance-registry) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack ImageService (glance-registry) failed to" \
"stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,7 +3,8 @@
#
# OpenStack Orchestration Engine Service (heat-engine)
#
# Description: Manages an OpenStack Orchestration Engine Service (heat-engine) process as an HA resource
# Description: Manages an OpenStack Orchestration Engine Service (heat-engine)
# process as an HA resource
#
# Authors: Emilien Macchi
#
@ -203,7 +204,8 @@ heat_engine_status() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Orchestration Engine (heat-engine) is not running"
ocf_log info "OpenStack Orchestration Engine (heat-engine) is not" \
"running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -214,7 +216,8 @@ heat_engine_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Orchestration Engine (heat-engine) is not running"
ocf_log info "Old PID file found, but OpenStack Orchestration Engine" \
"(heat-engine) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -233,17 +236,22 @@ heat_engine_monitor() {
return $rc
fi
# Check the connections according to the PID.
# We are sure to hit the heat-engine process and not other heat process with the same connection behavior (for example heat-api)
# Check the connections according to the PID. We are sure to hit the
# heat-engine process and not other heat process with the same connection
# behavior (for example heat-api)
pid=`cat $OCF_RESKEY_pid`
engine_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
engine_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_amqp=$?
if [ $rc_amqp -ne 0 ]; then
ocf_log err "Heat Engine is not connected to the AMQP server: AMQP connection test returned $rc_amqp"
ocf_log err "Heat Engine is not connected to the AMQP server: AMQP" \
"connection test returned $rc_amqp"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Orchestration Engine (heat-engine) monitor succeeded"
ocf_log debug "OpenStack Orchestration Engine (heat-engine) monitor" \
"succeeded"
return $OCF_SUCCESS
}
@ -253,14 +261,18 @@ heat_engine_start() {
heat_engine_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Orchestration Engine (heat-engine) already running"
ocf_log info "OpenStack Orchestration Engine (heat-engine) already" \
"running"
return $OCF_SUCCESS
fi
# run the actual heat-engine daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual heat-engine daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break
# stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
@ -285,7 +297,8 @@ heat_engine_stop() {
heat_engine_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Orchestration Engine (heat-engine) already stopped"
ocf_log info "OpenStack Orchestration Engine (heat-engine) already" \
"stopped"
return $OCF_SUCCESS
fi
@ -294,7 +307,8 @@ heat_engine_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Orchestration Engine (heat-engine) couldn't be stopped"
ocf_log err "OpenStack Orchestration Engine (heat-engine) couldn't" \
"be stopped"
exit $OCF_ERR_GENERIC
fi
@ -312,15 +326,16 @@ heat_engine_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Orchestration Engine (heat-engine) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Orchestration Engine (heat-engine) still" \
"hasn't stopped yet. Waiting ..."
done
heat_engine_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Orchestration Engine (heat-engine) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Orchestration Engine (heat-engine) failed to" \
"stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -219,7 +219,8 @@ keystone_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Identity (Keystone) is not running"
ocf_log info "Old PID file found, but OpenStack Identity (Keystone)" \
"is not running"
return $OCF_NOT_RUNNING
fi
}
@ -238,8 +239,9 @@ keystone_monitor() {
# Check whether we are supposed to monitor by logging into Keystone
# and do it if that's the case.
if [ -n "$OCF_RESKEY_client_binary" ] && [ -n "$OCF_RESKEY_os_username" ] \
&& [ -n "$OCF_RESKEY_os_password" ] && [ -n "$OCF_RESKEY_os_tenant_name" ] \
&& [ -n "$OCF_RESKEY_os_auth_url" ]; then
&& [ -n "$OCF_RESKEY_os_password" ] \
&& [ -n "$OCF_RESKEY_os_tenant_name" ] \
&& [ -n "$OCF_RESKEY_os_auth_url" ]; then
ocf_run -q $OCF_RESKEY_client_binary \
--os-username "$OCF_RESKEY_os_username" \
--os-password "$OCF_RESKEY_os_password" \
@ -248,7 +250,8 @@ keystone_monitor() {
user-list > /dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Failed to connect to the OpenStack Identity (Keystone): $rc"
ocf_log err "Failed to connect to the OpenStack Identity" \
"(Keystone): $rc"
return $OCF_NOT_RUNNING
fi
fi
@ -267,10 +270,13 @@ keystone_start() {
return $OCF_SUCCESS
fi
# run the actual keystone daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file $OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual keystone daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break
# stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file $OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -323,15 +329,16 @@ keystone_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Identity (Keystone) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Identity (Keystone) still hasn't stopped" \
"yet. Waiting ..."
done
keystone_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Identity (Keystone) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Identity (Keystone) failed to stop after" \
"${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,7 +3,8 @@
#
# OpenStack Manila API (manila-api)
#
# Description: Manages an OpenStack Manila API (manila-api) process as an HA resource
# Description: Manages an OpenStack Manila API (manila-api) process as an HA
# resource
#
# Authors: Emilian Macchi, Clinton Knight
# Mainly inspired by the Nova API written by Sebastien Han
@ -40,14 +41,14 @@ OCF_RESKEY_config_default="/etc/manila/manila.conf"
OCF_RESKEY_user_default="manila"
OCF_RESKEY_pid_default="$HA_RSCTMP/manila.pid"
OCF_RESKEY_url_default="http://127.0.0.1:8786/v2/"
OCF_RESKEY_keystone_get_token_url_default="http://127.0.0.1:5000/v2.0/tokens"
OCF_RESKEY_keystone_get_token_url_def="http://127.0.0.1:5000/v2.0/tokens"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_url=${OCF_RESKEY_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_def}}
#######################################################################
@ -128,7 +129,7 @@ The default URL to use to acquire a Manila API (manila-api) token for monitoring
of OpenStack Manila API (manila-api)
</longdesc>
<shortdesc lang="en">OpenStack Manila API (manila-api) url</shortdesc>
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_default}" />
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_def}" />
</parameter>
<parameter name="os_username" unique="0" required="0">
@ -233,7 +234,8 @@ manila_api_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Manila API (manila-api) is not running"
ocf_log info "Old PID file found, but OpenStack Manila API" \
"(manila-api) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -253,15 +255,21 @@ manila_api_monitor() {
# Check detailed information about this specific version of the API.
if [ -n "$OCF_RESKEY_os_username" ] && [ -n "$OCF_RESKEY_os_password" ] \
&& [ -n "$OCF_RESKEY_os_tenant_name" ] && [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": {\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" $OCF_RESKEY_keystone_get_token_url | tr ',' '\n' | grep '"id":' \
| cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null -sH "X-Auth-Token: $token" $OCF_RESKEY_url`
&& [ -n "$OCF_RESKEY_os_tenant_name" ] \
&& [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": \
{\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \
\"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" \
$OCF_RESKEY_keystone_get_token_url | \
tr ',' '\n' | grep '"id":' \ | cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null \
-sH "X-Auth-Token: $token" $OCF_RESKEY_url`
rc=$?
if [ $rc -ne 0 ] || [ $http_code -ne 200 ]; then
ocf_log err "Failed to connect to the OpenStack Manila API (manila-api): $rc and $http_code"
ocf_log err "Failed to connect to the OpenStack Manila API" \
"(manila-api): $rc and $http_code"
return $OCF_NOT_RUNNING
fi
fi
@ -280,10 +288,13 @@ manila_api_start() {
return $OCF_SUCCESS
fi
# run the actual manila-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual manila-api daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break
# stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -336,15 +347,16 @@ manila_api_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Manila API (manila-api) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Manila API (manila-api) still hasn't" \
"stopped yet. Waiting ..."
done
manila_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Manila API (manila-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Manila API (manila-api) failed to stop after" \
"${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack DHCP Service (neutron-dhcp-agent)
#
# Description: Manages an OpenStack DHCP Service (neutron-dhcp-agent) process as an HA resource
# Description: Manages an OpenStack DHCP Service (neutron-dhcp-agent) process
# as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Network resource agent written by Emilien Macchi & Sebastien Han
# Mainly inspired by the Nova Network resource agent written by Emilien Macchi
# & Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -184,7 +186,8 @@ neutron_dhcp_agent_status() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) is not running"
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) is not" \
"running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -195,7 +198,8 @@ neutron_dhcp_agent_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack DHCP Server (neutron-dhcp-agent) is not running"
ocf_log info "Old PID file found, but OpenStack DHCP Server" \
"(neutron-dhcp-agent) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -214,17 +218,22 @@ neutron_dhcp_agent_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the scheduler process and not other Neutron process with the same connection behavior (for example neutron-server)
# We are sure to hit the scheduler process and not other Neutron process
# with the same connection behavior (for example neutron-server)
pid=`cat $OCF_RESKEY_pid`
# check the connections according to the PID
network_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
network_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Neutron DHCP Server is not connected to the AMQP server : $rc"
ocf_log err "Neutron DHCP Server is not connected to the AMQP" \
"server : $rc"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack DHCP Server (neutron-dhcp-agent) monitor succeeded"
ocf_log debug "OpenStack DHCP Server (neutron-dhcp-agent) monitor" \
"succeeded"
return $OCF_SUCCESS
}
@ -234,15 +243,20 @@ neutron_dhcp_agent_start() {
neutron_dhcp_agent_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) already running"
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) already" \
"running"
return $OCF_SUCCESS
fi
# run the actual neutron-dhcp-agent daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_plugin_config --log-file=/var/log/neutron/dhcp-agent.log $OCF_RESKEY_additional_parameters"' >> \
/dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual neutron-dhcp-agent daemon. Don't use ocf_run as we're
# sending the tool's output straight to /dev/null anyway and using ocf_run
# would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_plugin_config \
--log-file=/var/log/neutron/dhcp-agent.log \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -268,7 +282,8 @@ neutron_dhcp_agent_stop() {
neutron_dhcp_agent_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) already stopped"
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) already" \
"stopped"
return $OCF_SUCCESS
fi
@ -278,7 +293,8 @@ neutron_dhcp_agent_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack DHCP Server (neutron-dhcp-agent) couldn't be stopped"
ocf_log err "OpenStack DHCP Server (neutron-dhcp-agent) couldn't be" \
"stopped"
exit $OCF_ERR_GENERIC
fi
@ -296,15 +312,16 @@ neutron_dhcp_agent_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack DHCP Server (neutron-dhcp-agent) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack DHCP Server (neutron-dhcp-agent) still" \
"hasn't stopped yet. Waiting ..."
done
neutron_dhcp_agent_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack DHCP Server (neutron-dhcp-agent) failed to" \
"stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack L3 Service (neutron-l3-agent)
#
# Description: Manages an OpenStack L3 Service (neutron-l3-agent) process as an HA resource
# Description: Manages an OpenStack L3 Service (neutron-l3-agent) process as
# an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Network resource agent written by Emilien Macchi & Sebastien Han
# Mainly inspired by the Nova Network resource agent written by Emilien Macchi
# & Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -197,7 +199,8 @@ neutron_l3_agent_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack L3 Server (neutron-l3-agent) is not running"
ocf_log info "Old PID file found, but OpenStack L3 Server" \
"(neutron-l3-agent) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -216,13 +219,17 @@ neutron_l3_agent_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the scheduler process and not other Neutron process with the same connection behavior (for example neutron-server)
# We are sure to hit the scheduler process and not other Neutron process
# with the same connection behavior (for example neutron-server)
pid=`cat $OCF_RESKEY_pid`
# check the connections according to the PID
network_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
network_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Neutron L3 Server is not connected to the Neutron server: $rc"
ocf_log err "Neutron L3 Server is not connected to the Neutron" \
"server: $rc"
return $OCF_NOT_RUNNING
fi
@ -240,11 +247,15 @@ neutron_l3_agent_start() {
return $OCF_SUCCESS
fi
# run the actual neutron-l3-agent daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_plugin_config --log-file=/var/log/neutron/l3-agent.log $OCF_RESKEY_additional_parameters"' >> \
/dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual neutron-l3-agent daemon. Don't use ocf_run as we're
# sending the tool's output straight to /dev/null anyway and using ocf_run
# would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_plugin_config \
--log-file=/var/log/neutron/l3-agent.log \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -279,7 +290,8 @@ neutron_l3_agent_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack L3 Server (neutron-l3-agent) couldn't be stopped"
ocf_log err "OpenStack L3 Server (neutron-l3-agent) couldn't be" \
"stopped"
exit $OCF_ERR_GENERIC
fi
@ -297,15 +309,16 @@ neutron_l3_agent_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack L3 Server (neutron-l3-agent) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack L3 Server (neutron-l3-agent) still hasn't" \
"stopped yet. Waiting ..."
done
neutron_l3_agent_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack L3 Server (neutron-l3-agent) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack L3 Server (neutron-l3-agent) failed to stop" \
"after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -166,7 +166,8 @@ neutron_ha_tool_validate() {
check_binary $OCF_RESKEY_binary
if [ -n "$OCF_RESKEY_os_cacert" ]; then
if [ ! -f "$OCF_RESKEY_os_cacert" ]; then
ocf_log err "Failed to verify CA Certifcate Bundle ($OCF_RESKEY_os_cacert)"
ocf_log err "Failed to verify CA Certifcate Bundle" \
"($OCF_RESKEY_os_cacert)"
return 1
fi
fi
@ -207,7 +208,8 @@ neutron_ha_tool_start() {
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Neutron HA Tool failed to replicate networks to DHCP agents."
ocf_log err "Neutron HA Tool failed to replicate networks to DHCP" \
"agents."
return $OCF_ERR_GENERIC
fi
@ -215,10 +217,12 @@ neutron_ha_tool_start() {
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Neutron HA Tool failed to migrate routers away from offline L3 agents."
ocf_log err "Neutron HA Tool failed to migrate routers away from" \
"offline L3 agents."
return $OCF_ERR_GENERIC
fi
ocf_log debug "Neutron HA Tool (neutron-ha-tool) router migration succeeded."
ocf_log debug "Neutron HA Tool (neutron-ha-tool) router migration" \
"succeeded."
return $OCF_SUCCESS
}

View File

@ -3,10 +3,12 @@
#
# OpenStack Neutron Metadata Agent (neutron-metadata-agent)
#
# Description: Manages an OpenStack Volumes (neutron-metadata-agent) process as an HA resource
# Description: Manages an OpenStack Volumes (neutron-metadata-agent) process
# as an HA resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Glance API resource agent written by Martin Gerhard
# Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -181,7 +183,8 @@ neutron_metadata_agent_status() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent) is not running"
ocf_log info "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -192,7 +195,8 @@ neutron_metadata_agent_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Neutron Metadata Agent (neutron-metadata-agent) is not running"
ocf_log info "Old PID file found, but OpenStack Neutron Metadata" \
"Agent (neutron-metadata-agent) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -202,7 +206,8 @@ neutron_metadata_agent_monitor() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent) is not running"
ocf_log info "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -213,7 +218,8 @@ neutron_metadata_agent_monitor() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Neutron Metadata Agent (neutron-metadata-agent) is not running"
ocf_log info "Old PID file found, but OpenStack Neutron Metadata" \
"Agent (neutron-metadata-agent) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -224,16 +230,21 @@ neutron_metadata_agent_start() {
neutron_metadata_agent_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent) already running"
ocf_log info "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) already running"
return $OCF_SUCCESS
fi
# run the actual neutron-server daemon with correct configurations files (server + plugin)
# Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_agent_config --log-file=/var/log/neutron/metadata.log $OCF_RESKEY_additional_parameters"' >> \
/dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual neutron-server daemon with correct configurations files
# (server + plugin)
# Don't use ocf_run as we're sending the tool's output straight to
# /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_agent_config \
--log-file=/var/log/neutron/metadata.log \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -242,13 +253,15 @@ neutron_metadata_agent_start() {
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Neutron Metadata Agent (neutron-metadata-agent) start failed"
ocf_log err "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent) started"
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent)" \
"started"
return $OCF_SUCCESS
}
@ -259,7 +272,8 @@ neutron_metadata_agent_stop() {
neutron_metadata_agent_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent) already stopped"
ocf_log info "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) already stopped"
return $OCF_SUCCESS
fi
@ -268,7 +282,8 @@ neutron_metadata_agent_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Neutron Metadata Agent (neutron-metadata-agent) couldn't be stopped"
ocf_log err "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) couldn't be stopped"
exit $OCF_ERR_GENERIC
fi
@ -286,19 +301,22 @@ neutron_metadata_agent_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Neutron Metadata Agent (neutron-metadata-agent) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) still hasn't stopped yet. Waiting ..."
done
neutron_metadata_agent_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Neutron Metadata Agent" \
"(neutron-metadata-agent) failed to stop after" \
"${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent) stopped"
ocf_log info "OpenStack Neutron Metadata Agent (neutron-metadata-agent)" \
"stopped"
rm -f $OCF_RESKEY_pid

View File

@ -3,11 +3,13 @@
#
# OpenStack Neutron Server (neutron-server)
#
# Description: Manages an OpenStack Neutron Server (neutron-server) process as an HA resource
# Description: Manages an OpenStack Neutron Server (neutron-server) process as
# an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Neutron API resource agent written by Sebastien Han : http://goo.gl/s8hOU
# Which is also inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Neutron API resource agent written by Sebastien Han:
# http://goo.gl/s8hOU Which is also inspired by the Glance API resource agent
# written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -39,7 +41,8 @@
OCF_RESKEY_binary_default="neutron-server"
OCF_RESKEY_config_default="/etc/neutron/neutron.conf"
OCF_RESKEY_plugin_config_default="/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini"
OCF_RESKEY_plugin_config_default=\
"/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini"
OCF_RESKEY_user_default="neutron"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_url_default="http://127.0.0.1:9696"
@ -240,7 +243,8 @@ neutron_server_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Neutron Server (neutron-server) is not running"
ocf_log info "Old PID file found, but OpenStack Neutron Server" \
"(neutron-server) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -259,10 +263,12 @@ neutron_server_monitor() {
# Check the response code of the "List API versions" call.
# If it's 200, we consider neutron-server is properly running.
if [ -n "$OCF_RESKEY_url" ]; then
http_code=`curl --silent --write-out %{http_code} --output /dev/null -X GET $OCF_RESKEY_url`
http_code=`curl --silent --write-out %{http_code} --output /dev/null \
-X GET $OCF_RESKEY_url`
rc=$?
if [ $rc -ne 0 ] || [ $http_code -ne 200 ]; then
ocf_log err "Failed to connect to the OpenStack Neutron API (neutron-server): $rc and $http_code"
ocf_log err "Failed to connect to the OpenStack Neutron API" \
"(neutron-server): $rc and $http_code"
return $OCF_NOT_RUNNING
fi
fi
@ -277,16 +283,21 @@ neutron_server_start() {
neutron_server_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Neutron Server (neutron-server) already running"
ocf_log info "OpenStack Neutron Server (neutron-server) already" \
"running"
return $OCF_SUCCESS
fi
# run the actual neutron-server daemon with correct configurations files (server + plugin)
# Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_plugin_config --log-file=/var/log/neutron/server.log $OCF_RESKEY_additional_parameters"' >> \
/dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual neutron-server daemon with correct configurations files
# (server + plugin)
# Don't use ocf_run as we're sending the tool's output # straight to
# /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
--config-file=$OCF_RESKEY_plugin_config \
--log-file=/var/log/neutron/server.log \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -312,7 +323,8 @@ neutron_server_stop() {
neutron_server_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Neutron Server (neutron-server) already stopped"
ocf_log info "OpenStack Neutron Server (neutron-server) already" \
"stopped"
return $OCF_SUCCESS
fi
@ -321,7 +333,8 @@ neutron_server_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Neutron Server (neutron-server) couldn't be stopped"
ocf_log err "OpenStack Neutron Server (neutron-server) couldn't be" \
"stopped"
exit $OCF_ERR_GENERIC
fi
@ -339,15 +352,16 @@ neutron_server_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Neutron Server (neutron-server) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Neutron Server (neutron-server) still" \
"hasn't stopped yet. Waiting ..."
done
neutron_server_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Neutron Server (neutron-server) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Neutron Server (neutron-server) failed to" \
"stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack NovaAPI (nova-api)
#
# Description: Manages an OpenStack Nova API (nova-api) process as an HA resource
# Description: Manages an OpenStack Nova API (nova-api) process as an HA
# resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Glance API resource agent written by Martin Gerhard
# Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -39,14 +41,14 @@ OCF_RESKEY_config_default="/etc/nova/nova.conf"
OCF_RESKEY_user_default="nova"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_url_default="http://127.0.0.1:8774/v2/"
OCF_RESKEY_keystone_get_token_url_default="http://127.0.0.1:5000/v2.0/tokens"
OCF_RESKEY_keystone_get_token_url_def="http://127.0.0.1:5000/v2.0/tokens"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_url=${OCF_RESKEY_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_def}}
#######################################################################
@ -127,7 +129,7 @@ The default URL to use to acquire a Nova API (nova-api) token for monitoring thi
of OpenStack Nova API (nova-api)
</longdesc>
<shortdesc lang="en">OpenStack Nova API (nova-api) url</shortdesc>
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_default}" />
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_def}" />
</parameter>
<parameter name="os_username" unique="0" required="0">
@ -225,7 +227,8 @@ nova_api_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova API (nova-api) is not running"
ocf_log info "Old PID file found, but OpenStack Nova API (nova-api)" \
"is not running"
return $OCF_NOT_RUNNING
fi
}
@ -245,15 +248,21 @@ nova_api_monitor() {
# Check detailed information about this specific version of the API.
if [ -n "$OCF_RESKEY_os_username" ] && [ -n "$OCF_RESKEY_os_password" ] \
&& [ -n "$OCF_RESKEY_os_tenant_name" ] && [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": {\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" $OCF_RESKEY_keystone_get_token_url | tr ',' '\n' | grep '"id":' \
| cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null -sH "X-Auth-Token: $token" $OCF_RESKEY_url`
&& [ -n "$OCF_RESKEY_os_tenant_name" ] \
&& [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
token=`curl -s -d "{\"auth\":{\"passwordCredentials\": \
{\"username\": \"$OCF_RESKEY_os_username\", \
\"password\": \"$OCF_RESKEY_os_password\"}, \
\"tenantName\": \"$OCF_RESKEY_os_tenant_name\"}}" \
-H "Content-type: application/json" \
$OCF_RESKEY_keystone_get_token_url | \
tr ',' '\n' | grep '"id":' \ | cut -d'"' -f4 | head --lines 1`
http_code=`curl --write-out %{http_code} --output /dev/null \
-sH "X-Auth-Token: $token" $OCF_RESKEY_url`
rc=$?
if [ $rc -ne 0 ] || [ $http_code -ne 200 ]; then
ocf_log err "Failed to connect to the OpenStack Nova API (nova-api): $rc and $http_code"
ocf_log err "Failed to connect to the OpenStack Nova API" \
"(nova-api): $rc and $http_code"
return $OCF_NOT_RUNNING
fi
fi
@ -272,10 +281,13 @@ nova_api_start() {
return $OCF_SUCCESS
fi
# run the actual nova-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual nova-api daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break
# stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -328,15 +340,16 @@ nova_api_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova API (nova-api) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Nova API (nova-api) still hasn't stopped" \
"yet. Waiting ..."
done
nova_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova API (nova-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Nova API (nova-api) failed to stop after" \
"${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack Nova Cert (nova-cert)
#
# Description: Manages an OpenStack Nova Cert (nova-cert) process as an HA resource
# Description: Manages an OpenStack Nova Cert (nova-cert) process as an HA
# resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Glance API resource agent written by Martin Gerhard
# Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -227,7 +229,8 @@ nova_cert_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova Cert (nova-cert) is not running"
ocf_log info "Old PID file found, but OpenStack Nova Cert" \
"(nova-cert)is not running"
return $OCF_NOT_RUNNING
fi
}
@ -249,24 +252,34 @@ nova_cert_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the cert process and not other nova process with the same connection behavior (for example nova-scheduler)
# We are sure to hit the cert process and not other nova process with the
# same connection behavior (for example nova-scheduler)
if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid`
cert_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
cert_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "Nova Cert is not connected to the database server: $rc_db"
ocf_log err "Nova Cert is not connected to the database server:" \
"$rc_db"
return $OCF_NOT_RUNNING
fi
else
pid=`cat $OCF_RESKEY_pid`
# check the connections according to the PID
cert_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -sq "ESTABLISHED"`
cert_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -sq "ESTABLISHED"`
rc_db=$?
cert_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -sq "ESTABLISHED"`
cert_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -sq "ESTABLISHED"`
rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then
ocf_log err "Nova Cert is not connected to the AMQP server and/or the database server: AMQP connection test returned $rc_amqp and database connection test returned $rc_db"
ocf_log err "Nova Cert is not connected to the AMQP server" \
"and/or the database server: AMQP connection test returned" \
"$rc_amqp and database connection test returned $rc_db"
return $OCF_NOT_RUNNING
fi
fi
@ -285,10 +298,13 @@ nova_cert_start() {
return $OCF_SUCCESS
fi
# run the actual nova-cert daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual nova-cert daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break
# stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -341,15 +357,16 @@ nova_cert_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova Cert (nova-cert) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Nova Cert (nova-cert) still hasn't stopped" \
"yet. Waiting ..."
done
nova_cert_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova Cert (nova-cert) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Nova Cert (nova-cert) failed to stop after" \
"${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack Nova ConsoleAuth (nova-consoleauth)
#
# Description: Manages an OpenStack Nova ConsoleAuth (nova-consoleauth) process as an HA resource
# Description: Manages an OpenStack Nova ConsoleAuth (nova-consoleauth)
# process as an HA resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Glance API resource agent written by Martin Gerhard
# Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -216,7 +218,8 @@ nova_consoleauth_status() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Nova Console Auth (nova-consoleauth) is not running"
ocf_log info "OpenStack Nova Console Auth (nova-consoleauth) is not" \
"running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -227,7 +230,8 @@ nova_consoleauth_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova Console Auth (nova-consoleauth) is not running"
ocf_log info "Old PID file found, but OpenStack Nova Console Auth" \
"(nova-consoleauth) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -249,29 +253,41 @@ nova_consoleauth_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the scheduler process and not other nova process with the same connection behavior (for example nova-scheduler)
# We are sure to hit the scheduler process and not other nova process with
# the same connection behavior (for example nova-scheduler)
if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid`
console_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
console_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "Nova Console Auth is not connected to the database server: $rc_db"
ocf_log err "Nova Console Auth is not connected to the database" \
"server: $rc_db"
return $OCF_NOT_RUNNING
fi
else
pid=`cat $OCF_RESKEY_pid`
# check the connections according to the PID
console_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
console_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_db=$?
console_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | egrep -s "$pid" | grep -qs "ESTABLISHED"`
console_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | egrep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then
ocf_log err "Nova Console Auth is not connected to the AMQP server and/or the database server: AMQP connection test returned $rc_amqp and database connection test returned $rc_db"
ocf_log err "Nova Console Auth is not connected to the AMQP" \
"server and/or the database server: AMQP connection test" \
"returned $rc_amqp and database connection test returned" \
"$rc_db"
return $OCF_NOT_RUNNING
fi
fi
ocf_log debug "OpenStack Nova Console Auth (nova-consoleauth) monitor succeeded"
ocf_log debug "OpenStack Nova Console Auth (nova-consoleauth) monitor" \
"succeeded"
return $OCF_SUCCESS
}
@ -281,14 +297,18 @@ nova_consoleauth_start() {
nova_consoleauth_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Nova ConsoleAuth (nova-consoleauth) already running"
ocf_log info "OpenStack Nova ConsoleAuth (nova-consoleauth) already" \
"running"
return $OCF_SUCCESS
fi
# run the actual nova-consoleauth daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual nova-consoleauth daemon. Don't use ocf_run as we're
# sending the tool's output straight to /dev/null anyway and using ocf_run
# would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -297,7 +317,8 @@ nova_consoleauth_start() {
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Nova ConsoleAuth (nova-consoleauth) start failed"
ocf_log err "OpenStack Nova ConsoleAuth (nova-consoleauth)" \
"start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
@ -314,7 +335,8 @@ nova_consoleauth_stop() {
nova_consoleauth_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Nova ConsoleAuth (nova-consoleauth) already stopped"
ocf_log info "OpenStack Nova ConsoleAuth (nova-consoleauth) already" \
"stopped"
return $OCF_SUCCESS
fi
@ -323,7 +345,8 @@ nova_consoleauth_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Nova ConsoleAuth (nova-consoleauth) couldn't be stopped"
ocf_log err "OpenStack Nova ConsoleAuth (nova-consoleauth) couldn't" \
"be stopped"
exit $OCF_ERR_GENERIC
fi
@ -341,15 +364,17 @@ nova_consoleauth_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova ConsoleAuth (nova-consoleauth) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Nova ConsoleAuth (nova-consoleauth) still" \
"hasn't stopped yet. Waiting ..."
done
nova_consoleauth_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova ConsoleAuth (nova-consoleauth) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Nova ConsoleAuth (nova-consoleauth) failed" \
"to stop after ${shutdown_timeout}s using SIGTERM. Trying" \
"SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,11 +3,13 @@
#
# OpenStack Network Service (nova-network) (replaced by Neutron in Havana)
#
# Description: Manages an OpenStack Network Service (nova-network) process as an HA resource
# Description: Manages an OpenStack Network Service (nova-network) process as
# an HA resource
#
# Authors: Sebastien Han & Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han : http://goo.gl/s8hOU
# Which are also inspired by the resource agents written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien
# Han: http://goo.gl/s8hOU Which are also inspired by the resource agents
# written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -206,7 +208,8 @@ nova_network_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova Network (nova-network) is not running"
ocf_log info "Old PID file found, but OpenStack Nova Network" \
"(nova-network) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -228,24 +231,34 @@ nova_network_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the scheduler process and not other nova process with the same connection behavior (for example nova-cert)
# We are sure to hit the scheduler process and not other nova process with
# the same connection behavior (for example nova-cert)
if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid`
network_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
network_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "Nova Network is not connected to the database server: $rc_db"
ocf_log err "Nova Network is not connected to the database" \
"server: $rc_db"
return $OCF_NOT_RUNNING
fi
else
pid=`cat $OCF_RESKEY_pid`
# check the connections according to the PID
network_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
network_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_db=$?
network_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
network_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then
ocf_log err "Nova Network is not connected to the AMQP server and/or the database server: AMQP connection test returned $rc_amqp and database connection test returned $rc_db"
ocf_log err "Nova Network is not connected to the AMQP server" \
"and/or the database server: AMQP connection test returned" \
"$rc_amqp and database connection test returned $rc_db"
return $OCF_NOT_RUNNING
fi
fi
@ -264,10 +277,13 @@ nova_network_start() {
return $OCF_SUCCESS
fi
# run the actual nova-network daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual nova-network daemon. Don't use ocf_run as we're sending
# the tool's output straight to /dev/null anyway and using ocf_run would
# break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -321,15 +337,16 @@ nova_network_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova Network (nova-network) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Nova Network (nova-network) still hasn't" \
"stopped yet. Waiting ..."
done
nova_network_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova Network (nova-network) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Nova Network (nova-network) failed to stop" \
"after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack Nova VNC Console (nova-novncproxy)
#
# Description: Manages an OpenStack Nova VNC Console (nova-novncproxy) process as an HA resource
# Description: Manages an OpenStack Nova VNC Console (nova-novncproxy) process
# as an HA resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Glance API resource agent written by Martin Gerhard
# Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -183,7 +185,8 @@ nova_vnc_console_status() {
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) is not running"
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) is not" \
"running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
@ -194,7 +197,8 @@ nova_vnc_console_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova VNC Console (nova-novncproxy) is not running"
ocf_log info "Old PID file found, but OpenStack Nova VNC Console" \
"(nova-novncproxy) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -213,14 +217,17 @@ nova_vnc_console_monitor() {
# Check whether we are supposed to monitor by logging into nova-novncproxy
# and do it if that's the case.
vnc_list_check=`netstat -a | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
vnc_list_check=`netstat -a | grep -s "$OCF_RESKEY_console_port" | \
grep -qs "LISTEN"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Nova VNC Console doesn't seem to listen on his default port: $rc"
ocf_log err "Nova VNC Console doesn't seem to listen on his default" \
"port: $rc"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Nova VNC Console (nova-novncproxy) monitor succeeded"
ocf_log debug "OpenStack Nova VNC Console (nova-novncproxy) monitor" \
"succeeded"
return $OCF_SUCCESS
}
@ -230,14 +237,18 @@ nova_vnc_console_start() {
nova_vnc_console_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) already running"
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) already" \
"running"
return $OCF_SUCCESS
fi
# run the actual nova-novncproxy daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config --web /usr/share/novnc/ \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual nova-novncproxy daemon. Don't use ocf_run as we're sending
# the tool's output straight to /dev/null anyway and using ocf_run would
# break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config --web /usr/share/novnc/ \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
@ -263,7 +274,8 @@ nova_vnc_console_stop() {
nova_vnc_console_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) already stopped"
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) already" \
"stopped"
return $OCF_SUCCESS
fi
@ -272,7 +284,8 @@ nova_vnc_console_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Nova VNC Console (nova-novncproxy) couldn't be stopped"
ocf_log err "OpenStack Nova VNC Console (nova-novncproxy) couldn't" \
"be stopped"
exit $OCF_ERR_GENERIC
fi
@ -290,15 +303,16 @@ nova_vnc_console_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova VNC Console (nova-novncproxy) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Nova VNC Console (nova-novncproxy) still" \
"hasn't stopped yet. Waiting ..."
done
nova_vnc_console_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Nova VNC Console (nova-novncproxy) failed to" \
"stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi

View File

@ -3,10 +3,12 @@
#
# OpenStack Scheduler Service (nova-scheduler)
#
# Description: Manages an OpenStack Scheduler Service (nova-scheduler) process as an HA resource
# Description: Manages an OpenStack Scheduler Service (nova-scheduler) process
# as an HA resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
# Mainly inspired by the Glance API resource agent written by Martin Gerhard
# Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
@ -227,7 +229,8 @@ nova_scheduler_status() {
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova Scheduler (nova-scheduler) is not running"
ocf_log info "Old PID file found, but OpenStack Nova Scheduler" \
"(nova-scheduler) is not running"
return $OCF_NOT_RUNNING
fi
}
@ -249,23 +252,33 @@ nova_scheduler_monitor() {
fi
# Check the connections according to the PID.
# We are sure to hit the scheduler process and not other nova process with the same connection behavior (for example nova-cert)
# We are sure to hit the scheduler process and not other nova process with
# the same connection behavior (for example nova-cert)
if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid`
scheduler_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
scheduler_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "Nova Scheduler is not connected to the database server: $rc_db"
ocf_log err "Nova Scheduler is not connected to the database" \
"server: $rc_db"
return $OCF_NOT_RUNNING
fi
else
pid=`cat $OCF_RESKEY_pid`
scheduler_db_check=`netstat -punt | grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
scheduler_db_check=`netstat -punt | \
grep -s "$OCF_RESKEY_database_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_db=$?
scheduler_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
scheduler_amqp_check=`netstat -punt | \
grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | \
grep -qs "ESTABLISHED"`
rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then
ocf_log err "Nova Scheduler is not connected to the AMQP server and/or the database server: AMQP connection test returned $rc_amqp and database connection test returned $rc_db"
ocf_log err "Nova Scheduler is not connected to the AMQP server" \
"and/or the database server: AMQP connection test returned" \
"$rc_amqp and database connection test returned $rc_db"
return $OCF_NOT_RUNNING
fi
fi
@ -280,14 +293,18 @@ nova_scheduler_start() {
nova_scheduler_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Nova Scheduler (nova-scheduler) already running"
ocf_log info "OpenStack Nova Scheduler (nova-scheduler) already" \
"running"
return $OCF_SUCCESS
fi
# run the actual nova-scheduler daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# run the actual nova-scheduler daemon. Don't use ocf_run as we're sending
# the tool's output straight to /dev/null anyway and using ocf_run would
# break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} \
--config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' \
> $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
@ -312,7 +329,8 @@ nova_scheduler_stop() {
nova_scheduler_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Nova Scheduler (nova-scheduler) already stopped"
ocf_log info "OpenStack Nova Scheduler (nova-scheduler) already" \
"stopped"
return $OCF_SUCCESS
fi
@ -321,7 +339,8 @@ nova_scheduler_stop() {
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Nova Scheduler (nova-scheduler) couldn't be stopped"
ocf_log err "OpenStack Nova Scheduler (nova-scheduler) couldn't be" \
"stopped"
exit $OCF_ERR_GENERIC
fi
@ -339,15 +358,16 @@ nova_scheduler_stop() {
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova Scheduler (nova-scheduler) still hasn't stopped yet. Waiting ..."
ocf_log debug "OpenStack Nova Scheduler (nova-scheduler) still" \
"hasn't stopped yet. Waiting ..."
done
nova_scheduler_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova Scheduler (nova-scheduler) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_log info "OpenStack Nova Scheduler (nova-scheduler) failed to" \
"stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi