4d2e554f68
* Import all providers, specs and tests to this module * Use corosync module to actually install paceamker Fuel-CI: disable Change-Id: I9a16ad1453b694aa0a3e78d079f9c57365a5fcf1
134 lines
2.1 KiB
Plaintext
134 lines
2.1 KiB
Plaintext
#!/bin/sh
|
|
export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
|
|
export OCF_ROOT='<%= @ocf_root_path %>'
|
|
export OCF_RA_VERSION_MAJOR='1'
|
|
export OCF_RA_VERSION_MINOR='0'
|
|
export OCF_RESOURCE_INSTANCE='<%= @primitive_name %>'
|
|
|
|
# OCF Parameters
|
|
<% if @parameters.is_a? Hash -%>
|
|
<% @parameters.each do |k,v| -%>
|
|
<% v = v.to_s -%>
|
|
<% v = v + "'" unless v.end_with? "'" -%>
|
|
<% v = "'" + v unless v.start_with? "'" -%>
|
|
<%= "export OCF_RESKEY_#{k}=#{v}" %>
|
|
<% end -%>
|
|
<% end -%>
|
|
|
|
help() {
|
|
cat<<EOF
|
|
OCF wrapper for <%= @service_name %> Pacemaker primitive
|
|
|
|
Usage: <%= @ocf_handler_name %> [-dh] (action)
|
|
|
|
Options:
|
|
-d - Use set -x to debug the shell script
|
|
-h - Show this help
|
|
|
|
Main actions:
|
|
* start
|
|
* stop
|
|
* monitor
|
|
* meta-data
|
|
* validate-all
|
|
|
|
Multistate:
|
|
* promote
|
|
* demote
|
|
* notify
|
|
|
|
Migration:
|
|
* migrate_to
|
|
* migrate_from
|
|
|
|
Optional and unused:
|
|
* usage
|
|
* help
|
|
* status
|
|
* reload
|
|
* restart
|
|
* recover
|
|
EOF
|
|
}
|
|
|
|
color() {
|
|
'/bin/echo' -e "\033[${1}m${2}\033[0m"
|
|
}
|
|
|
|
red() {
|
|
color 31 "${1}"
|
|
}
|
|
|
|
green() {
|
|
color 32 "${1}"
|
|
}
|
|
|
|
blue() {
|
|
color 34 "${1}"
|
|
}
|
|
|
|
ec2error() {
|
|
case "${1}" in
|
|
0) green 'Success' ;;
|
|
1) red 'Error: Generic' ;;
|
|
2) red 'Error: Arguments' ;;
|
|
3) red 'Error: Unimplemented' ;;
|
|
4) red 'Error: Permissions' ;;
|
|
5) red 'Error: Installation' ;;
|
|
6) red 'Error: Configuration' ;;
|
|
7) blue 'Not Running' ;;
|
|
8) green 'Master Running' ;;
|
|
9) red 'Master Failed' ;;
|
|
*) red "Unknown" ;;
|
|
esac
|
|
}
|
|
|
|
DEBUG='0'
|
|
while getopts ':dh' opt; do
|
|
case $opt in
|
|
d)
|
|
DEBUG='1'
|
|
;;
|
|
h)
|
|
help
|
|
exit 0
|
|
;;
|
|
\?)
|
|
echo "Invalid option: -${OPTARG}" >&2
|
|
help
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift "$((OPTIND - 1))"
|
|
|
|
ACTION="${1}"
|
|
|
|
# set default action to monitor
|
|
if [ "${ACTION}" = '' ]; then
|
|
ACTION='monitor'
|
|
fi
|
|
|
|
# alias status to monitor
|
|
if [ "${ACTION}" = 'status' ]; then
|
|
ACTION='monitor'
|
|
fi
|
|
|
|
# view defined OCF parameters
|
|
if [ "${ACTION}" = 'params' ]; then
|
|
env | grep 'OCF_'
|
|
exit 0
|
|
fi
|
|
|
|
if [ "${DEBUG}" = '1' ]; then
|
|
bash -x <%= @ocf_script_path %> "${ACTION}"
|
|
else
|
|
<%= @ocf_script_path %> "${ACTION}"
|
|
fi
|
|
ec="${?}"
|
|
|
|
message="$(ec2error ${ec})"
|
|
echo "Exit status: ${message} (${ec})"
|
|
exit "${ec}"
|