Fix bashate E002 violations

This commit fixes bashate E002 (indents are only spaces, and not hard
tabs) violations

Partial-Bug: #1550203
Change-Id: I7d156d47023781be74e6fa8daef6ffc311b55d9d
Signed-off-by: Norbert Illes <norbert.e.illes@ericsson.com>
This commit is contained in:
Norbert Illes 2016-02-25 16:29:29 +01:00
parent 6ad8eb01ae
commit 4397355193
12 changed files with 291 additions and 257 deletions

View File

@ -38,7 +38,7 @@
####################################################################### #######################################################################
meta_data() { meta_data() {
cat <<END cat <<END
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="NovaCompute" version="1.0"> <resource-agent name="NovaCompute" version="1.0">
@ -156,12 +156,12 @@ END
# don't exit on TERM, to test that lrmd makes sure that we do exit # don't exit on TERM, to test that lrmd makes sure that we do exit
trap sigterm_handler TERM trap sigterm_handler TERM
sigterm_handler() { sigterm_handler() {
ocf_log info "They use TERM to bring us down. No such luck." ocf_log info "They use TERM to bring us down. No such luck."
return return
} }
nova_usage() { nova_usage() {
cat <<END cat <<END
usage: $0 {start|stop|monitor|validate-all|meta-data} usage: $0 {start|stop|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set. Expects to have a fully populated OCF RA-compliant environment set.
@ -175,32 +175,32 @@ nova_pid() {
nova_start() { nova_start() {
nova_monitor nova_monitor
if [ $? = $OCF_SUCCESS ]; then if [ $? = $OCF_SUCCESS ]; then
return $OCF_SUCCESS return $OCF_SUCCESS
fi 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 if [ "x$state" = x ]; then
: no fencing to recover : no fencing to recover
elif [ "x$state" = xno ]; then elif [ "x$state" = xno ]; then
: has been evacuated, however it could have been 1s ago : 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} sleep ${OCF_RESKEY_evacuation_delay}
fence_compute ${fence_options} -o on -n ${NOVA_HOST} fence_compute ${fence_options} -o on -n ${NOVA_HOST}
attrd_updater -p -n evacuate -N ${NOVA_HOST} -D attrd_updater -p -n evacuate -N ${NOVA_HOST} -D
else else
ocf_log info "Waiting for pending evacuations from ${NOVA_HOST}" ocf_log info "Waiting for pending evacuations from ${NOVA_HOST}"
while [ "x$state" != "xno" -a "x$state" != x ]; do 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 sleep 5
done 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} sleep ${OCF_RESKEY_evacuation_delay}
fence_compute ${fence_options} -o on -n ${NOVA_HOST} fence_compute ${fence_options} -o on -n ${NOVA_HOST}
attrd_updater -p -n evacuate -N ${NOVA_HOST} -D attrd_updater -p -n evacuate -N ${NOVA_HOST} -D
fi fi
export LIBGUESTFS_ATTACH_METHOD=appliance export LIBGUESTFS_ATTACH_METHOD=appliance
@ -209,8 +209,8 @@ nova_start() {
rc=$OCF_NOT_RUNNING rc=$OCF_NOT_RUNNING
ocf_log info "Waiting for nova to start" ocf_log info "Waiting for nova to start"
while [ $rc != $OCF_SUCCESS ]; do while [ $rc != $OCF_SUCCESS ]; do
nova_monitor nova_monitor
rc=$? rc=$?
done done
return $OCF_SUCCESS return $OCF_SUCCESS
@ -219,12 +219,12 @@ nova_start() {
nova_stop() { nova_stop() {
pid=$(nova_pid) pid=$(nova_pid)
if [ "x$pid" != x ]; then if [ "x$pid" != x ]; then
su nova -c "kill -TERM $pid" -s /bin/bash su nova -c "kill -TERM $pid" -s /bin/bash
fi fi
while [ "x$pid" != x ]; do while [ "x$pid" != x ]; do
sleep 1 sleep 1
pid=$(nova_pid) pid=$(nova_pid)
done done
return $OCF_SUCCESS return $OCF_SUCCESS
@ -233,16 +233,16 @@ nova_stop() {
nova_monitor() { nova_monitor() {
pid=$(nova_pid) pid=$(nova_pid)
if [ "x$pid" != x ]; then if [ "x$pid" != x ]; then
## TEMPORARY disable call to fence_compute to avoid noise on first ## TEMPORARY disable call to fence_compute to avoid noise on first
## first startup due to nova-compute not being fast enough to populate ## first startup due to nova-compute not being fast enough to populate
## the db and fence_compute checking if node exists and it's enabled ## the db and fence_compute checking if node exists and it's enabled
#state=$(fence_compute ${fence_options} -o status -n $NOVA_HOST | grep Status) #state=$(fence_compute ${fence_options} -o status -n $NOVA_HOST | grep Status)
#if [ "x$state" = "xStatus: ON" ]; then #if [ "x$state" = "xStatus: ON" ]; then
return $OCF_SUCCESS return $OCF_SUCCESS
#else #else
# ocf_exit_reason "Nova status: $state" # ocf_exit_reason "Nova status: $state"
# return $OCF_ERR_GENERIC # return $OCF_ERR_GENERIC
#fi #fi
fi fi
return $OCF_NOT_RUNNING return $OCF_NOT_RUNNING
@ -260,67 +260,68 @@ nova_validate() {
check_binary nova-compute check_binary nova-compute
if [ ! -f /etc/nova/nova.conf ]; then if [ ! -f /etc/nova/nova.conf ]; then
ocf_exit_reason "/etc/nova/nova.conf not found" ocf_exit_reason "/etc/nova/nova.conf not found"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
if [ -z "${OCF_RESKEY_auth_url}" ]; then if [ -z "${OCF_RESKEY_auth_url}" ]; then
ocf_exit_reason "auth_url not configured" ocf_exit_reason "auth_url not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}" fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
if [ -z "${OCF_RESKEY_username}" ]; then if [ -z "${OCF_RESKEY_username}" ]; then
ocf_exit_reason "username not configured" ocf_exit_reason "username not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -l ${OCF_RESKEY_username}" fence_options="${fence_options} -l ${OCF_RESKEY_username}"
if [ -z "${OCF_RESKEY_password}" ]; then if [ -z "${OCF_RESKEY_password}" ]; then
ocf_exit_reason "password not configured" ocf_exit_reason "password not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -p ${OCF_RESKEY_password}" fence_options="${fence_options} -p ${OCF_RESKEY_password}"
if [ -z "${OCF_RESKEY_tenant_name}" ]; then if [ -z "${OCF_RESKEY_tenant_name}" ]; then
ocf_exit_reason "tenant_name not configured" ocf_exit_reason "tenant_name not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}" fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
if [ -n "${OCF_RESKEY_domain}" ]; then if [ -n "${OCF_RESKEY_domain}" ]; then
fence_options="${fence_options} -d ${OCF_RESKEY_domain}" fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
fi fi
if [ -n "${OCF_RESKEY_region_name}" ]; then 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 fi
if [ -n "${OCF_RESKEY_insecure}" ]; then if [ -n "${OCF_RESKEY_insecure}" ]; then
if ocf_is_true "${OCF_RESKEY_insecure}"; then if ocf_is_true "${OCF_RESKEY_insecure}"; then
fence_options="${fence_options} --insecure" fence_options="${fence_options} --insecure"
fi fi
fi fi
if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
fence_options="${fence_options} --no-shared-storage" fence_options="${fence_options} --no-shared-storage"
fi fi
fi fi
if [ -n "${OCF_RESKEY_endpoint_type}" ]; then if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
case ${OCF_RESKEY_endpoint_type} in case ${OCF_RESKEY_endpoint_type} in
adminURL|publicURL|internalURL) ;; adminURL|publicURL|internalURL)
*) ;;
ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL" *)
exit $OCF_ERR_CONFIGURED ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL"
;; exit $OCF_ERR_CONFIGURED
esac ;;
fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}" esac
fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}"
fi fi
# we take a chance here and hope that host is either not configured # we take a chance here and hope that host is either not configured
@ -328,54 +329,69 @@ nova_validate() {
NOVA_HOST=$(crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null) NOVA_HOST=$(crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null)
if [ $? = 1 ]; then if [ $? = 1 ]; then
if [ "x${OCF_RESKEY_domain}" != x ]; then if [ "x${OCF_RESKEY_domain}" != x ]; then
NOVA_HOST=$(uname -n | awk -F. '{print $1}') NOVA_HOST=$(uname -n | awk -F. '{print $1}')
else else
NOVA_HOST=$(uname -n) NOVA_HOST=$(uname -n)
fi fi
fi fi
# We only need to check a configured value, calculated ones are fine # We only need to check a configured value, calculated ones are fine
crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null
if [ $? = 0 ]; then if [ $? = 0 ]; then
if [ "x${OCF_RESKEY_domain}" != x ]; then if [ "x${OCF_RESKEY_domain}" != x ]; then
short_host=$(uname -n | awk -F. '{print $1}') short_host=$(uname -n | awk -F. '{print $1}')
if [ "x$NOVA_HOST" != "x${short_host}" ]; then 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 rc=$OCF_ERR_CONFIGURED
fi fi
elif [ "x$NOVA_HOST" != "x$(uname -n)" ]; then 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 rc=$OCF_ERR_CONFIGURED
fi fi
fi fi
if [ $rc != $OCF_SUCCESS ]; then if [ $rc != $OCF_SUCCESS ]; then
exit $rc exit $rc
fi fi
return $rc return $rc
} }
: ${OCF_RESKEY_evacuation_delay=120} : ${OCF_RESKEY_evacuation_delay=120}
case $__OCF_ACTION in case $__OCF_ACTION in
meta-data) meta_data meta-data)
exit $OCF_SUCCESS meta_data
;; exit $OCF_SUCCESS
usage|help) nova_usage ;;
exit $OCF_SUCCESS usage|help)
;; nova_usage
exit $OCF_SUCCESS
;;
esac esac
case $__OCF_ACTION in case $__OCF_ACTION in
start) nova_validate; nova_start;; start)
stop) nova_stop;; nova_validate
monitor) nova_validate; nova_monitor;; nova_start
notify) nova_notify;; ;;
validate-all) exit $OCF_SUCCESS;; stop)
*) nova_usage nova_stop
exit $OCF_ERR_UNIMPLEMENTED ;;
;; monitor)
nova_validate
nova_monitor
;;
notify)
nova_notify
;;
validate-all)
exit $OCF_SUCCESS
;;
*)
nova_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac esac
rc=$? rc=$?
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"

View File

@ -38,7 +38,7 @@
####################################################################### #######################################################################
meta_data() { meta_data() {
cat <<END cat <<END
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="NovaEvacuate" version="1.0"> <resource-agent name="NovaEvacuate" version="1.0">
@ -144,12 +144,12 @@ END
# don't exit on TERM, to test that lrmd makes sure that we do exit # don't exit on TERM, to test that lrmd makes sure that we do exit
trap sigterm_handler TERM trap sigterm_handler TERM
sigterm_handler() { sigterm_handler() {
ocf_log info "They use TERM to bring us down. No such luck." ocf_log info "They use TERM to bring us down. No such luck."
return return
} }
evacuate_usage() { evacuate_usage() {
cat <<END cat <<END
usage: $0 {start|stop|monitor|validate-all|meta-data} usage: $0 {start|stop|monitor|validate-all|meta-data}
Expects to have a fully populated OCF RA-compliant environment set. Expects to have a fully populated OCF RA-compliant environment set.
@ -171,71 +171,75 @@ update_evacuation() {
attrd_updater -p -n evacuate -Q -N ${1} -U ${2} attrd_updater -p -n evacuate -Q -N ${1} -U ${2}
arc=$? arc=$?
if [ ${arc} != 0 ]; then if [ ${arc} != 0 ]; then
ocf_log warn "Can not set evacuation state of ${1} to ${2}: ${arc}" ocf_log warn "Can not set evacuation state of ${1} to ${2}: ${arc}"
fi fi
return ${arc} return ${arc}
} }
handle_evacuations() { handle_evacuations() {
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
node=$1 node=$1
state=$2 state=$2
shift; shift; shift; shift;
need_evacuate=0 need_evacuate=0
case $state in case $state in
"") ;; "")
no) ocf_log debug "$node is either fine or already handled";; ;;
yes) need_evacuate=1;; no)
*@*) ocf_log debug "$node is either fine or already handled"
where=$(echo $state | awk -F@ '{print $1}') ;;
when=$(echo $state | awk -F@ '{print $2}') yes) need_evacuate=1
now=$(date +%s) ;;
*@*)
where=$(echo $state | awk -F@ '{print $1}')
when=$(echo $state | awk -F@ '{print $2}')
now=$(date +%s)
if [ $(($now - $when)) -gt 60 ]; then 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 need_evacuate=1
else else
# Give some time for any in-flight evacuations to either complete or fail # Give some time for any in-flight evacuations to either complete or fail
# Nova won't react well if there are two overlapping requests # Nova won't react well if there are two overlapping requests
ocf_log info "Deferring processing partial evacuation of $node by $where at $when" ocf_log info "Deferring processing partial evacuation of $node by $where at $when"
fi fi
;; ;;
esac esac
if [ $need_evacuate = 1 ]; then if [ $need_evacuate = 1 ]; then
found=0 found=0
ocf_log notice "Initiating evacuation of $node" 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 if [ ${known} = ${node} ]; then
found=1 found=1
break break
fi fi
done done
if [ $found = 0 ]; then if [ $found = 0 ]; then
ocf_log info "Nova does not know about ${node}" ocf_log info "Nova does not know about ${node}"
# Dont mark as no because perhaps nova is unavailable right now # Dont mark as no because perhaps nova is unavailable right now
continue continue
fi fi
update_evacuation ${node} "$(uname -n)@$(date +%s)" update_evacuation ${node} "$(uname -n)@$(date +%s)"
if [ $? != 0 ]; then if [ $? != 0 ]; then
return $OCF_SUCCESS return $OCF_SUCCESS
fi fi
fence_compute ${fence_options} -o off -n $node fence_compute ${fence_options} -o off -n $node
rc=$? rc=$?
if [ $rc = 0 ]; then if [ $rc = 0 ]; then
update_evacuation ${node} no update_evacuation ${node} no
ocf_log notice "Completed evacuation of $node" ocf_log notice "Completed evacuation of $node"
else else
ocf_log warn "Evacuation of $node failed: $rc" ocf_log warn "Evacuation of $node failed: $rc"
update_evacuation ${node} yes update_evacuation ${node} yes
fi fi
fi fi
done done
return $OCF_SUCCESS return $OCF_SUCCESS
@ -243,7 +247,7 @@ handle_evacuations() {
evacuate_monitor() { evacuate_monitor() {
if [ ! -f "$statefile" ]; then if [ ! -f "$statefile" ]; then
return $OCF_NOT_RUNNING return $OCF_NOT_RUNNING
fi fi
handle_evacuations $( handle_evacuations $(
@ -266,72 +270,73 @@ evacuate_validate() {
state_dir=$(dirname $statefile) state_dir=$(dirname $statefile)
touch "$state_dir/$$" touch "$state_dir/$$"
if [ $? != 0 ]; then if [ $? != 0 ]; then
ocf_exit_reason "Invalid state directory: $state_dir" ocf_exit_reason "Invalid state directory: $state_dir"
return $OCF_ERR_ARGS return $OCF_ERR_ARGS
fi fi
rm -f "$state_dir/$$" rm -f "$state_dir/$$"
if [ -z "${OCF_RESKEY_auth_url}" ]; then if [ -z "${OCF_RESKEY_auth_url}" ]; then
ocf_exit_reason "auth_url not configured" ocf_exit_reason "auth_url not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}" fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
if [ -z "${OCF_RESKEY_username}" ]; then if [ -z "${OCF_RESKEY_username}" ]; then
ocf_exit_reason "username not configured" ocf_exit_reason "username not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -l ${OCF_RESKEY_username}" fence_options="${fence_options} -l ${OCF_RESKEY_username}"
if [ -z "${OCF_RESKEY_password}" ]; then if [ -z "${OCF_RESKEY_password}" ]; then
ocf_exit_reason "password not configured" ocf_exit_reason "password not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -p ${OCF_RESKEY_password}" fence_options="${fence_options} -p ${OCF_RESKEY_password}"
if [ -z "${OCF_RESKEY_tenant_name}" ]; then if [ -z "${OCF_RESKEY_tenant_name}" ]; then
ocf_exit_reason "tenant_name not configured" ocf_exit_reason "tenant_name not configured"
exit $OCF_ERR_CONFIGURED exit $OCF_ERR_CONFIGURED
fi fi
fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}" fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
if [ -n "${OCF_RESKEY_domain}" ]; then if [ -n "${OCF_RESKEY_domain}" ]; then
fence_options="${fence_options} -d ${OCF_RESKEY_domain}" fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
fi fi
if [ -n "${OCF_RESKEY_region_name}" ]; then 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 fi
if [ -n "${OCF_RESKEY_insecure}" ]; then if [ -n "${OCF_RESKEY_insecure}" ]; then
if ocf_is_true "${OCF_RESKEY_insecure}"; then if ocf_is_true "${OCF_RESKEY_insecure}"; then
fence_options="${fence_options} --insecure" fence_options="${fence_options} --insecure"
fi fi
fi fi
if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
fence_options="${fence_options} --no-shared-storage" fence_options="${fence_options} --no-shared-storage"
fi fi
fi fi
if [ -n "${OCF_RESKEY_endpoint_type}" ]; then if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
case ${OCF_RESKEY_endpoint_type} in case ${OCF_RESKEY_endpoint_type} in
adminURL|publicURL|internalURL) ;; adminURL|publicURL|internalURL)
*) ;;
ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL" *)
exit $OCF_ERR_CONFIGURED ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL"
;; exit $OCF_ERR_CONFIGURED
esac ;;
fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}" esac
fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}"
fi fi
if [ $rc != $OCF_SUCCESS ]; then if [ $rc != $OCF_SUCCESS ]; then
exit $rc exit $rc
fi fi
return $rc return $rc
} }
@ -339,19 +344,32 @@ evacuate_validate() {
statefile="${HA_RSCTMP}/${OCF_RESOURCE_INSTANCE}.active" statefile="${HA_RSCTMP}/${OCF_RESOURCE_INSTANCE}.active"
case $__OCF_ACTION in case $__OCF_ACTION in
start) evacuate_validate; evacuate_start;; start)
stop) evacuate_stop;; evacuate_validate
monitor) evacuate_validate; evacuate_monitor;; evacuate_start
meta-data) meta_data ;;
exit $OCF_SUCCESS stop)
;; evacuate_stop
usage|help) evacuate_usage ;;
exit $OCF_SUCCESS monitor)
;; evacuate_validate
validate-all) exit $OCF_SUCCESS;; evacuate_monitor
*) evacuate_usage ;;
exit $OCF_ERR_UNIMPLEMENTED meta-data)
;; meta_data
exit $OCF_SUCCESS
;;
usage|help)
evacuate_usage
exit $OCF_SUCCESS
;;
validate-all)
exit $OCF_SUCCESS
;;
*)
evacuate_usage
exit $OCF_ERR_UNIMPLEMENTED
;;
esac esac
rc=$? rc=$?
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"

View File

@ -238,7 +238,7 @@ glance_api_monitor() {
# Monitor the RA by retrieving the image list # Monitor the RA by retrieving the image list
if [ -n "$OCF_RESKEY_os_username" ] && [ -n "$OCF_RESKEY_os_password" ] \ 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 \ ocf_run -q $OCF_RESKEY_client_binary \
--os_username "$OCF_RESKEY_os_username" \ --os_username "$OCF_RESKEY_os_username" \
--os_password "$OCF_RESKEY_os_password" \ --os_password "$OCF_RESKEY_os_password" \
--os_tenant_name "$OCF_RESKEY_os_tenant_name" \ --os_tenant_name "$OCF_RESKEY_os_tenant_name" \

View File

@ -219,10 +219,10 @@ neutron_dhcp_agent_monitor() {
# check the connections according to the 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=$? rc=$?
if [ $rc -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi 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 return $OCF_SUCCESS
@ -242,7 +242,7 @@ neutron_dhcp_agent_start() {
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here. # 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 \ 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"' >> \ --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 /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up. # Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required # Let the CRM/LRM time us out if required

View File

@ -221,10 +221,10 @@ neutron_l3_agent_monitor() {
# check the connections according to the 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=$? rc=$?
if [ $rc -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
ocf_log debug "OpenStack L3 Server (neutron-l3-agent) monitor succeeded" ocf_log debug "OpenStack L3 Server (neutron-l3-agent) monitor succeeded"
return $OCF_SUCCESS return $OCF_SUCCESS
@ -244,7 +244,7 @@ neutron_l3_agent_start() {
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here. # 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 \ 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"' >> \ --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 /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up. # Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required # Let the CRM/LRM time us out if required

View File

@ -232,8 +232,8 @@ neutron_metadata_agent_start() {
# Don't use ocf_run as we're sending the tool's output # 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. # 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 \ 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"' >> \ --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 /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up. # Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required # Let the CRM/LRM time us out if required

View File

@ -285,8 +285,8 @@ neutron_server_start() {
# Don't use ocf_run as we're sending the tool's output # 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. # 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 \ 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"' >> \ --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 /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up. # Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required # Let the CRM/LRM time us out if required

View File

@ -250,26 +250,26 @@ nova_cert_monitor() {
# Check the connections according to the PID. # 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 if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid` 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=$? rc_db=$?
if [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
else else
pid=`cat $OCF_RESKEY_pid` pid=`cat $OCF_RESKEY_pid`
# check the connections according to the 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=$? 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=$? rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
fi fi
ocf_log debug "OpenStack Nova Cert (nova-cert) monitor succeeded" ocf_log debug "OpenStack Nova Cert (nova-cert) monitor succeeded"
return $OCF_SUCCESS return $OCF_SUCCESS

View File

@ -250,26 +250,26 @@ nova_consoleauth_monitor() {
# Check the connections according to the PID. # 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 if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid` 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=$? rc_db=$?
if [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
else else
pid=`cat $OCF_RESKEY_pid` pid=`cat $OCF_RESKEY_pid`
# check the connections according to the 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=$? 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=$? rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
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 return $OCF_SUCCESS

View File

@ -229,26 +229,26 @@ nova_network_monitor() {
# Check the connections according to the PID. # 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 if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid` 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=$? rc_db=$?
if [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
else else
pid=`cat $OCF_RESKEY_pid` pid=`cat $OCF_RESKEY_pid`
# check the connections according to the 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=$? 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=$? rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
fi fi
ocf_log debug "OpenStack Nova Network (nova-network) monitor succeeded" ocf_log debug "OpenStack Nova Network (nova-network) monitor succeeded"
return $OCF_SUCCESS return $OCF_SUCCESS

View File

@ -213,7 +213,7 @@ nova_vnc_console_monitor() {
# Check whether we are supposed to monitor by logging into nova-novncproxy # Check whether we are supposed to monitor by logging into nova-novncproxy
# and do it if that's the case. # 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=$? rc=$?
if [ $rc -ne 0 ]; then 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"

View File

@ -251,24 +251,24 @@ nova_scheduler_monitor() {
# Check the connections according to the PID. # 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 if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid` 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=$? rc_db=$?
if [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
else else
pid=`cat $OCF_RESKEY_pid` 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=$? 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=$? rc_amqp=$?
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then 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 return $OCF_NOT_RUNNING
fi fi
fi fi
ocf_log debug "OpenStack Nova Scheduler (nova-scheduler) monitor succeeded" ocf_log debug "OpenStack Nova Scheduler (nova-scheduler) monitor succeeded"
return $OCF_SUCCESS return $OCF_SUCCESS