2525
2626# #
2727# README.
28- #
28+ #
2929# This agent only supports being configured as a multistate Master
3030# resource.
3131#
4949# pcs resource create db galera enable_creation=true \
5050# wsrep_cluster_address="gcomm://rhel7-auto1,rhel7-auto2,rhel7-auto3" meta master-max=3 --master
5151#
52- # By setting the 'enable_creation' option, the database will be automatically
52+ # By setting the 'enable_creation' option, the database will be automatically
5353# generated at startup. The meta attribute 'master-max=3' means that all 3
5454# nodes listed in the wsrep_cluster_address list will be allowed to connect
5555# to the galera cluster and perform replication.
5656#
5757# NOTE: If you have more nodes in the pacemaker cluster then you wish
5858# to have in the galera cluster, make sure to use location contraints to prevent
5959# pacemaker from attempting to place a galera instance on a node that is
60- # not in the 'wsrep_cluster_address" list.
60+ # not in the 'wsrep_cluster_address" list.
6161#
6262# #
6363
6666
6767: ${OCF_FUNCTIONS_DIR=${OCF_ROOT} / lib/ heartbeat}
6868. ${OCF_FUNCTIONS_DIR} /ocf-shellfuncs
69- . ${OCF_FUNCTIONS_DIR} /mysql-common.sh
7069
71- NODENAME=$( ocf_attribute_target)
70+ if [ " $__OCF_ACTION " != " meta-data" ]; then
71+ . ${OCF_FUNCTIONS_DIR} /mysql-common.sh
72+ NODENAME=$( ocf_attribute_target)
73+ fi
7274
7375# It is common for some galera instances to store
7476# check user that can be used to query status
99101}
100102
101103meta_data () {
102- cat << END
104+ extra_parameters=" $1 "
105+
106+ cat << END
103107<?xml version="1.0"?>
104108<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
105109<resource-agent name="galera">
@@ -247,6 +251,8 @@ Cluster check user password
247251<content type="string" default="" />
248252</parameter>
249253
254+ ${extra_parameters}
255+
250256</parameters>
251257
252258<actions>
@@ -329,7 +335,7 @@ get_last_commit()
329335
330336 if [ -z " $node " ]; then
331337 ${HA_SBIN_DIR} /crm_attribute -N $NODENAME -l reboot --name " ${INSTANCE_ATTR_NAME} -last-committed" --quiet 2> /dev/null
332- else
338+ else
333339 ${HA_SBIN_DIR} /crm_attribute -N $node -l reboot --name " ${INSTANCE_ATTR_NAME} -last-committed" --quiet 2> /dev/null
334340 fi
335341}
@@ -418,7 +424,7 @@ clear_master_score()
418424 local node=$( ocf_attribute_target $1 )
419425 if [ -z " $node " ]; then
420426 $CRM_MASTER -D
421- else
427+ else
422428 $CRM_MASTER -D -N $node
423429 fi
424430}
@@ -429,7 +435,7 @@ set_master_score()
429435
430436 if [ -z " $node " ]; then
431437 $CRM_MASTER -v 100
432- else
438+ else
433439 $CRM_MASTER -N $node -v 100
434440 fi
435441}
@@ -912,64 +918,70 @@ galera_validate()
912918 mysql_common_validate
913919}
914920
915- case " $1 " in
916- meta-data) meta_data
917- exit $OCF_SUCCESS ;;
918- usage|help) usage
919- exit $OCF_SUCCESS ;;
920- esac
921-
922- galera_validate
923- rc=$?
924- LSB_STATUS_STOPPED=3
925- if [ $rc -ne 0 ]; then
921+ cmd_main () {
926922 case " $1 " in
927- stop) exit $OCF_SUCCESS ;;
928- monitor) exit $OCF_NOT_RUNNING ;;
929- status) exit $LSB_STATUS_STOPPED ;;
930- * ) exit $rc ;;
923+ meta-data) meta_data
924+ exit $OCF_SUCCESS ;;
925+ usage|help) usage
926+ exit $OCF_SUCCESS ;;
931927 esac
932- fi
933928
934- if [ -z " ${OCF_RESKEY_check_passwd} " ]; then
935- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
936- OCF_RESKEY_check_passwd=${MYSQL_PASSWORD}
937- fi
938- if [ -z " ${OCF_RESKEY_check_user} " ]; then
939- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
940- OCF_RESKEY_check_user=${MYSQL_USERNAME}
941- fi
942- : ${OCF_RESKEY_check_user=" root" }
929+ galera_validate
930+ rc=$?
931+ LSB_STATUS_STOPPED=3
932+ if [ $rc -ne 0 ]; then
933+ case " $1 " in
934+ stop) exit $OCF_SUCCESS ;;
935+ monitor) exit $OCF_NOT_RUNNING ;;
936+ status) exit $LSB_STATUS_STOPPED ;;
937+ * ) exit $rc ;;
938+ esac
939+ fi
943940
944- MYSQL_OPTIONS_CHECK=" -nNE --user=${OCF_RESKEY_check_user} "
945- if [ -n " ${OCF_RESKEY_check_passwd} " ]; then
946- MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK --password=${OCF_RESKEY_check_passwd} "
947- fi
941+ if [ -z " ${OCF_RESKEY_check_passwd} " ]; then
942+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
943+ OCF_RESKEY_check_passwd=${MYSQL_PASSWORD}
944+ fi
945+ if [ -z " ${OCF_RESKEY_check_user} " ]; then
946+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
947+ OCF_RESKEY_check_user=${MYSQL_USERNAME}
948+ fi
949+ : ${OCF_RESKEY_check_user=" root" }
948950
949- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
950- if [ -n " ${MYSQL_HOST } " ]; then
951- MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -h ${MYSQL_HOST }"
952- fi
951+ MYSQL_OPTIONS_CHECK= " -nNE --user= ${OCF_RESKEY_check_user} "
952+ if [ -n " ${OCF_RESKEY_check_passwd } " ]; then
953+ MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK --password= ${OCF_RESKEY_check_passwd }"
954+ fi
953955
954- # This value is automatically sourced from /etc/sysconfig/checkcluster if available
955- if [ -n " ${MYSQL_PORT } " ]; then
956- MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -P ${MYSQL_PORT } "
957- fi
956+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
957+ if [ -n " ${MYSQL_HOST } " ]; then
958+ MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -h ${MYSQL_HOST } "
959+ fi
958960
961+ # This value is automatically sourced from /etc/sysconfig/checkcluster if available
962+ if [ -n " ${MYSQL_PORT} " ]; then
963+ MYSQL_OPTIONS_CHECK=" $MYSQL_OPTIONS_CHECK -P ${MYSQL_PORT} "
964+ fi
959965
966+ # What kind of method was invoked?
967+ case " $1 " in
968+ start) galera_start;;
969+ stop) galera_stop;;
970+ status) mysql_common_status err;;
971+ monitor) galera_monitor;;
972+ promote) galera_promote;;
973+ demote) galera_demote;;
974+ validate-all) exit $OCF_SUCCESS ;;
975+
976+ * ) usage
977+ exit $OCF_ERR_UNIMPLEMENTED ;;
978+ esac
979+ }
960980
961- # What kind of method was invoked?
962- case " $1 " in
963- start) galera_start;;
964- stop) galera_stop;;
965- status) mysql_common_status err;;
966- monitor) galera_monitor;;
967- promote) galera_promote;;
968- demote) galera_demote;;
969- validate-all) exit $OCF_SUCCESS ;;
981+ # run 'main' if we aren't "sourceonly"
982+ if [ $1 != " sourceonly" ]; then
983+ cmd_main " $@ "
984+ fi
970985
971- * ) usage
972- exit $OCF_ERR_UNIMPLEMENTED ;;
973- esac
974986
975987# vi:sw=4:ts=4:et:
0 commit comments