Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Fix bashate E006 violations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Norbert Illes committed Mar 2, 2016
1 parent b64bdae commit 98a54ad
Show file tree
Hide file tree
Showing 22 changed files with 655 additions and 354 deletions.
24 changes: 16 additions & 8 deletions ocf/NovaCompute
Expand Up @@ -178,25 +178,29 @@ 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}
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 '"' )
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}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 13 additions & 7 deletions ocf/NovaEvacuate
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
56 changes: 37 additions & 19 deletions ocf/ceilometer-agent-central
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand All @@ -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
}
Expand All @@ -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
}

Expand All @@ -243,28 +250,34 @@ 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
ceilometer_agent_central_monitor
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
}

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
50 changes: 31 additions & 19 deletions ocf/cinder-api
Expand Up @@ -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
Expand Down Expand Up @@ -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}}

#######################################################################

Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 98a54ad

Please sign in to comment.