Merge "Fix bashate E002 violations"
This commit is contained in:
commit
076ae60516
196
ocf/NovaCompute
196
ocf/NovaCompute
@ -38,7 +38,7 @@
|
||||
#######################################################################
|
||||
|
||||
meta_data() {
|
||||
cat <<END
|
||||
cat <<END
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
|
||||
<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
|
||||
trap sigterm_handler TERM
|
||||
sigterm_handler() {
|
||||
ocf_log info "They use TERM to bring us down. No such luck."
|
||||
return
|
||||
ocf_log info "They use TERM to bring us down. No such luck."
|
||||
return
|
||||
}
|
||||
|
||||
nova_usage() {
|
||||
cat <<END
|
||||
cat <<END
|
||||
usage: $0 {start|stop|monitor|validate-all|meta-data}
|
||||
|
||||
Expects to have a fully populated OCF RA-compliant environment set.
|
||||
@ -175,32 +175,32 @@ nova_pid() {
|
||||
nova_start() {
|
||||
nova_monitor
|
||||
if [ $? = $OCF_SUCCESS ]; then
|
||||
return $OCF_SUCCESS
|
||||
return $OCF_SUCCESS
|
||||
fi
|
||||
|
||||
state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
|
||||
if [ "x$state" = x ]; then
|
||||
: no fencing to recover
|
||||
: 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"
|
||||
sleep ${OCF_RESKEY_evacuation_delay}
|
||||
: has been evacuated, however it could have been 1s ago
|
||||
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}
|
||||
attrd_updater -p -n evacuate -N ${NOVA_HOST} -D
|
||||
fence_compute ${fence_options} -o on -n ${NOVA_HOST}
|
||||
attrd_updater -p -n evacuate -N ${NOVA_HOST} -D
|
||||
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 '"' )
|
||||
sleep 5
|
||||
done
|
||||
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 '"' )
|
||||
sleep 5
|
||||
done
|
||||
|
||||
ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
|
||||
sleep ${OCF_RESKEY_evacuation_delay}
|
||||
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}
|
||||
attrd_updater -p -n evacuate -N ${NOVA_HOST} -D
|
||||
fence_compute ${fence_options} -o on -n ${NOVA_HOST}
|
||||
attrd_updater -p -n evacuate -N ${NOVA_HOST} -D
|
||||
fi
|
||||
|
||||
export LIBGUESTFS_ATTACH_METHOD=appliance
|
||||
@ -209,8 +209,8 @@ nova_start() {
|
||||
rc=$OCF_NOT_RUNNING
|
||||
ocf_log info "Waiting for nova to start"
|
||||
while [ $rc != $OCF_SUCCESS ]; do
|
||||
nova_monitor
|
||||
rc=$?
|
||||
nova_monitor
|
||||
rc=$?
|
||||
done
|
||||
|
||||
return $OCF_SUCCESS
|
||||
@ -219,12 +219,12 @@ nova_start() {
|
||||
nova_stop() {
|
||||
pid=$(nova_pid)
|
||||
if [ "x$pid" != x ]; then
|
||||
su nova -c "kill -TERM $pid" -s /bin/bash
|
||||
su nova -c "kill -TERM $pid" -s /bin/bash
|
||||
fi
|
||||
|
||||
while [ "x$pid" != x ]; do
|
||||
sleep 1
|
||||
pid=$(nova_pid)
|
||||
sleep 1
|
||||
pid=$(nova_pid)
|
||||
done
|
||||
|
||||
return $OCF_SUCCESS
|
||||
@ -233,16 +233,16 @@ nova_stop() {
|
||||
nova_monitor() {
|
||||
pid=$(nova_pid)
|
||||
if [ "x$pid" != x ]; then
|
||||
## TEMPORARY disable call to fence_compute to avoid noise on first
|
||||
## 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
|
||||
#state=$(fence_compute ${fence_options} -o status -n $NOVA_HOST | grep Status)
|
||||
#if [ "x$state" = "xStatus: ON" ]; then
|
||||
return $OCF_SUCCESS
|
||||
#else
|
||||
# ocf_exit_reason "Nova status: $state"
|
||||
# return $OCF_ERR_GENERIC
|
||||
#fi
|
||||
## TEMPORARY disable call to fence_compute to avoid noise on first
|
||||
## 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
|
||||
#state=$(fence_compute ${fence_options} -o status -n $NOVA_HOST | grep Status)
|
||||
#if [ "x$state" = "xStatus: ON" ]; then
|
||||
return $OCF_SUCCESS
|
||||
#else
|
||||
# ocf_exit_reason "Nova status: $state"
|
||||
# return $OCF_ERR_GENERIC
|
||||
#fi
|
||||
fi
|
||||
|
||||
return $OCF_NOT_RUNNING
|
||||
@ -260,67 +260,68 @@ nova_validate() {
|
||||
check_binary nova-compute
|
||||
|
||||
if [ ! -f /etc/nova/nova.conf ]; then
|
||||
ocf_exit_reason "/etc/nova/nova.conf not found"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "/etc/nova/nova.conf not found"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
if [ -z "${OCF_RESKEY_auth_url}" ]; then
|
||||
ocf_exit_reason "auth_url not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "auth_url not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
|
||||
|
||||
if [ -z "${OCF_RESKEY_username}" ]; then
|
||||
ocf_exit_reason "username not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "username not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -l ${OCF_RESKEY_username}"
|
||||
|
||||
if [ -z "${OCF_RESKEY_password}" ]; then
|
||||
ocf_exit_reason "password not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "password not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -p ${OCF_RESKEY_password}"
|
||||
|
||||
if [ -z "${OCF_RESKEY_tenant_name}" ]; then
|
||||
ocf_exit_reason "tenant_name not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "tenant_name not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
|
||||
|
||||
if [ -n "${OCF_RESKEY_domain}" ]; then
|
||||
fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
|
||||
fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
|
||||
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
|
||||
if ocf_is_true "${OCF_RESKEY_insecure}"; then
|
||||
fence_options="${fence_options} --insecure"
|
||||
fi
|
||||
if ocf_is_true "${OCF_RESKEY_insecure}"; then
|
||||
fence_options="${fence_options} --insecure"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
|
||||
if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
|
||||
fence_options="${fence_options} --no-shared-storage"
|
||||
fi
|
||||
if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
|
||||
fence_options="${fence_options} --no-shared-storage"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
|
||||
case ${OCF_RESKEY_endpoint_type} in
|
||||
adminURL|publicURL|internalURL) ;;
|
||||
*)
|
||||
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}"
|
||||
case ${OCF_RESKEY_endpoint_type} in
|
||||
adminURL|publicURL|internalURL)
|
||||
;;
|
||||
*)
|
||||
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}"
|
||||
fi
|
||||
|
||||
# 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)
|
||||
if [ $? = 1 ]; then
|
||||
if [ "x${OCF_RESKEY_domain}" != x ]; then
|
||||
NOVA_HOST=$(uname -n | awk -F. '{print $1}')
|
||||
else
|
||||
NOVA_HOST=$(uname -n)
|
||||
fi
|
||||
if [ "x${OCF_RESKEY_domain}" != x ]; then
|
||||
NOVA_HOST=$(uname -n | awk -F. '{print $1}')
|
||||
else
|
||||
NOVA_HOST=$(uname -n)
|
||||
fi
|
||||
fi
|
||||
|
||||
# We only need to check a configured value, calculated ones are fine
|
||||
crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null
|
||||
if [ $? = 0 ]; then
|
||||
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"
|
||||
rc=$OCF_ERR_CONFIGURED
|
||||
fi
|
||||
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"
|
||||
rc=$OCF_ERR_CONFIGURED
|
||||
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"
|
||||
rc=$OCF_ERR_CONFIGURED
|
||||
fi
|
||||
rc=$OCF_ERR_CONFIGURED
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $rc != $OCF_SUCCESS ]; then
|
||||
exit $rc
|
||||
exit $rc
|
||||
fi
|
||||
return $rc
|
||||
}
|
||||
|
||||
: ${OCF_RESKEY_evacuation_delay=120}
|
||||
case $__OCF_ACTION in
|
||||
meta-data) meta_data
|
||||
exit $OCF_SUCCESS
|
||||
;;
|
||||
usage|help) nova_usage
|
||||
exit $OCF_SUCCESS
|
||||
;;
|
||||
meta-data)
|
||||
meta_data
|
||||
exit $OCF_SUCCESS
|
||||
;;
|
||||
usage|help)
|
||||
nova_usage
|
||||
exit $OCF_SUCCESS
|
||||
;;
|
||||
esac
|
||||
|
||||
case $__OCF_ACTION in
|
||||
start) nova_validate; nova_start;;
|
||||
stop) nova_stop;;
|
||||
monitor) nova_validate; nova_monitor;;
|
||||
notify) nova_notify;;
|
||||
validate-all) exit $OCF_SUCCESS;;
|
||||
*) nova_usage
|
||||
exit $OCF_ERR_UNIMPLEMENTED
|
||||
;;
|
||||
start)
|
||||
nova_validate
|
||||
nova_start
|
||||
;;
|
||||
stop)
|
||||
nova_stop
|
||||
;;
|
||||
monitor)
|
||||
nova_validate
|
||||
nova_monitor
|
||||
;;
|
||||
notify)
|
||||
nova_notify
|
||||
;;
|
||||
validate-all)
|
||||
exit $OCF_SUCCESS
|
||||
;;
|
||||
*)
|
||||
nova_usage
|
||||
exit $OCF_ERR_UNIMPLEMENTED
|
||||
;;
|
||||
esac
|
||||
rc=$?
|
||||
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
|
||||
|
210
ocf/NovaEvacuate
210
ocf/NovaEvacuate
@ -38,7 +38,7 @@
|
||||
#######################################################################
|
||||
|
||||
meta_data() {
|
||||
cat <<END
|
||||
cat <<END
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
|
||||
<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
|
||||
trap sigterm_handler TERM
|
||||
sigterm_handler() {
|
||||
ocf_log info "They use TERM to bring us down. No such luck."
|
||||
return
|
||||
ocf_log info "They use TERM to bring us down. No such luck."
|
||||
return
|
||||
}
|
||||
|
||||
evacuate_usage() {
|
||||
cat <<END
|
||||
cat <<END
|
||||
usage: $0 {start|stop|monitor|validate-all|meta-data}
|
||||
|
||||
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}
|
||||
arc=$?
|
||||
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
|
||||
return ${arc}
|
||||
}
|
||||
|
||||
handle_evacuations() {
|
||||
while [ $# -gt 0 ]; do
|
||||
node=$1
|
||||
state=$2
|
||||
shift; shift;
|
||||
need_evacuate=0
|
||||
node=$1
|
||||
state=$2
|
||||
shift; shift;
|
||||
need_evacuate=0
|
||||
|
||||
case $state in
|
||||
"") ;;
|
||||
no) ocf_log debug "$node is either fine or already handled";;
|
||||
yes) need_evacuate=1;;
|
||||
*@*)
|
||||
where=$(echo $state | awk -F@ '{print $1}')
|
||||
when=$(echo $state | awk -F@ '{print $2}')
|
||||
now=$(date +%s)
|
||||
case $state in
|
||||
"")
|
||||
;;
|
||||
no)
|
||||
ocf_log debug "$node is either fine or already handled"
|
||||
;;
|
||||
yes) need_evacuate=1
|
||||
;;
|
||||
*@*)
|
||||
where=$(echo $state | awk -F@ '{print $1}')
|
||||
when=$(echo $state | awk -F@ '{print $2}')
|
||||
now=$(date +%s)
|
||||
|
||||
if [ $(($now - $when)) -gt 60 ]; then
|
||||
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"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ $(($now - $when)) -gt 60 ]; then
|
||||
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"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $need_evacuate = 1 ]; then
|
||||
found=0
|
||||
ocf_log notice "Initiating evacuation of $node"
|
||||
if [ $need_evacuate = 1 ]; then
|
||||
found=0
|
||||
ocf_log notice "Initiating evacuation of $node"
|
||||
|
||||
for known in $(fence_compute ${fence_options} -o list | tr -d ','); do
|
||||
if [ ${known} = ${node} ]; then
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
for known in $(fence_compute ${fence_options} -o list | tr -d ','); do
|
||||
if [ ${known} = ${node} ]; then
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $found = 0 ]; then
|
||||
ocf_log info "Nova does not know about ${node}"
|
||||
# Dont mark as no because perhaps nova is unavailable right now
|
||||
continue
|
||||
fi
|
||||
if [ $found = 0 ]; then
|
||||
ocf_log info "Nova does not know about ${node}"
|
||||
# Dont mark as no because perhaps nova is unavailable right now
|
||||
continue
|
||||
fi
|
||||
|
||||
update_evacuation ${node} "$(uname -n)@$(date +%s)"
|
||||
if [ $? != 0 ]; then
|
||||
return $OCF_SUCCESS
|
||||
fi
|
||||
update_evacuation ${node} "$(uname -n)@$(date +%s)"
|
||||
if [ $? != 0 ]; then
|
||||
return $OCF_SUCCESS
|
||||
fi
|
||||
|
||||
fence_compute ${fence_options} -o off -n $node
|
||||
rc=$?
|
||||
fence_compute ${fence_options} -o off -n $node
|
||||
rc=$?
|
||||
|
||||
if [ $rc = 0 ]; then
|
||||
update_evacuation ${node} no
|
||||
ocf_log notice "Completed evacuation of $node"
|
||||
else
|
||||
ocf_log warn "Evacuation of $node failed: $rc"
|
||||
update_evacuation ${node} yes
|
||||
fi
|
||||
fi
|
||||
if [ $rc = 0 ]; then
|
||||
update_evacuation ${node} no
|
||||
ocf_log notice "Completed evacuation of $node"
|
||||
else
|
||||
ocf_log warn "Evacuation of $node failed: $rc"
|
||||
update_evacuation ${node} yes
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
return $OCF_SUCCESS
|
||||
@ -243,7 +247,7 @@ handle_evacuations() {
|
||||
|
||||
evacuate_monitor() {
|
||||
if [ ! -f "$statefile" ]; then
|
||||
return $OCF_NOT_RUNNING
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
|
||||
handle_evacuations $(
|
||||
@ -266,72 +270,73 @@ evacuate_validate() {
|
||||
state_dir=$(dirname $statefile)
|
||||
touch "$state_dir/$$"
|
||||
if [ $? != 0 ]; then
|
||||
ocf_exit_reason "Invalid state directory: $state_dir"
|
||||
return $OCF_ERR_ARGS
|
||||
ocf_exit_reason "Invalid state directory: $state_dir"
|
||||
return $OCF_ERR_ARGS
|
||||
fi
|
||||
rm -f "$state_dir/$$"
|
||||
|
||||
if [ -z "${OCF_RESKEY_auth_url}" ]; then
|
||||
ocf_exit_reason "auth_url not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "auth_url not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
|
||||
|
||||
if [ -z "${OCF_RESKEY_username}" ]; then
|
||||
ocf_exit_reason "username not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "username not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -l ${OCF_RESKEY_username}"
|
||||
|
||||
if [ -z "${OCF_RESKEY_password}" ]; then
|
||||
ocf_exit_reason "password not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "password not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -p ${OCF_RESKEY_password}"
|
||||
|
||||
if [ -z "${OCF_RESKEY_tenant_name}" ]; then
|
||||
ocf_exit_reason "tenant_name not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
ocf_exit_reason "tenant_name not configured"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
|
||||
fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
|
||||
|
||||
if [ -n "${OCF_RESKEY_domain}" ]; then
|
||||
fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
|
||||
fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
|
||||
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
|
||||
if ocf_is_true "${OCF_RESKEY_insecure}"; then
|
||||
fence_options="${fence_options} --insecure"
|
||||
fi
|
||||
if ocf_is_true "${OCF_RESKEY_insecure}"; then
|
||||
fence_options="${fence_options} --insecure"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
|
||||
if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
|
||||
fence_options="${fence_options} --no-shared-storage"
|
||||
fi
|
||||
if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
|
||||
fence_options="${fence_options} --no-shared-storage"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
|
||||
case ${OCF_RESKEY_endpoint_type} in
|
||||
adminURL|publicURL|internalURL) ;;
|
||||
*)
|
||||
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}"
|
||||
case ${OCF_RESKEY_endpoint_type} in
|
||||
adminURL|publicURL|internalURL)
|
||||
;;
|
||||
*)
|
||||
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}"
|
||||
fi
|
||||
|
||||
if [ $rc != $OCF_SUCCESS ]; then
|
||||
exit $rc
|
||||
exit $rc
|
||||
fi
|
||||
return $rc
|
||||
}
|
||||
@ -339,19 +344,32 @@ evacuate_validate() {
|
||||
statefile="${HA_RSCTMP}/${OCF_RESOURCE_INSTANCE}.active"
|
||||
|
||||
case $__OCF_ACTION in
|
||||
start) evacuate_validate; evacuate_start;;
|
||||
stop) evacuate_stop;;
|
||||
monitor) evacuate_validate; evacuate_monitor;;
|
||||
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
|
||||
;;
|
||||
start)
|
||||
evacuate_validate
|
||||
evacuate_start
|
||||
;;
|
||||
stop)
|
||||
evacuate_stop
|
||||
;;
|
||||
monitor)
|
||||
evacuate_validate
|
||||
evacuate_monitor
|
||||
;;
|
||||
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
|
||||
rc=$?
|
||||
ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
|
||||
|
@ -238,7 +238,7 @@ 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
|
||||
ocf_run -q $OCF_RESKEY_client_binary \
|
||||
ocf_run -q $OCF_RESKEY_client_binary \
|
||||
--os_username "$OCF_RESKEY_os_username" \
|
||||
--os_password "$OCF_RESKEY_os_password" \
|
||||
--os_tenant_name "$OCF_RESKEY_os_tenant_name" \
|
||||
|
@ -219,10 +219,10 @@ neutron_dhcp_agent_monitor() {
|
||||
# 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"`
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "Neutron DHCP Server is not connected to the AMQP server : $rc"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
if [ $rc -ne 0 ]; then
|
||||
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"
|
||||
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.
|
||||
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
|
||||
/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
|
||||
|
@ -221,10 +221,10 @@ neutron_l3_agent_monitor() {
|
||||
# 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"`
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "Neutron L3 Server is not connected to the Neutron server: $rc"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "Neutron L3 Server is not connected to the Neutron server: $rc"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
|
||||
ocf_log debug "OpenStack L3 Server (neutron-l3-agent) monitor succeeded"
|
||||
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.
|
||||
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
|
||||
/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
|
||||
|
@ -232,8 +232,8 @@ neutron_metadata_agent_start() {
|
||||
# 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
|
||||
--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
|
||||
|
@ -285,8 +285,8 @@ neutron_server_start() {
|
||||
# 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
|
||||
--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
|
||||
|
@ -250,26 +250,26 @@ nova_cert_monitor() {
|
||||
|
||||
# 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)
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
ocf_log err "Nova Cert is not connected to the database server: $rc_db"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
else
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
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"`
|
||||
rc_db=$?
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
|
||||
ocf_log debug "OpenStack Nova Cert (nova-cert) monitor succeeded"
|
||||
return $OCF_SUCCESS
|
||||
|
@ -250,26 +250,26 @@ nova_consoleauth_monitor() {
|
||||
|
||||
# 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)
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
ocf_log err "Nova Console Auth is not connected to the database server: $rc_db"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
else
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
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"`
|
||||
rc_db=$?
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
|
||||
ocf_log debug "OpenStack Nova Console Auth (nova-consoleauth) monitor succeeded"
|
||||
return $OCF_SUCCESS
|
||||
|
@ -229,26 +229,26 @@ nova_network_monitor() {
|
||||
|
||||
# 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)
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
ocf_log err "Nova Network is not connected to the database server: $rc_db"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
else
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
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"`
|
||||
rc_db=$?
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
|
||||
ocf_log debug "OpenStack Nova Network (nova-network) monitor succeeded"
|
||||
return $OCF_SUCCESS
|
||||
|
@ -213,7 +213,7 @@ 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"
|
||||
|
@ -251,24 +251,24 @@ nova_scheduler_monitor() {
|
||||
# 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)
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
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"`
|
||||
rc_db=$?
|
||||
if [ $rc_db -ne 0 ]; then
|
||||
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"`
|
||||
rc_db=$?
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
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"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
fi
|
||||
|
||||
ocf_log debug "OpenStack Nova Scheduler (nova-scheduler) monitor succeeded"
|
||||
return $OCF_SUCCESS
|
||||
|
Loading…
x
Reference in New Issue
Block a user