diff options
Diffstat (limited to 'extras/ganesha/ocf/ganesha_grace')
| -rw-r--r-- | extras/ganesha/ocf/ganesha_grace | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/extras/ganesha/ocf/ganesha_grace b/extras/ganesha/ocf/ganesha_grace index a82c9af417a..825f7164597 100644 --- a/extras/ganesha/ocf/ganesha_grace +++ b/extras/ganesha/ocf/ganesha_grace @@ -30,17 +30,17 @@ . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs if [ -n "$OCF_DEBUG_LIBRARY" ]; then - . $OCF_DEBUG_LIBRARY + . $OCF_DEBUG_LIBRARY else - : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} -. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} + . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs fi OCF_RESKEY_grace_active_default="grace-active" : ${OCF_RESKEY_grace_active=${OCF_RESKEY_grace_active_default}} ganesha_meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="ganesha_grace"> @@ -93,9 +93,23 @@ esac ganesha_grace_start() { - rc=${OCF_ERR_GENERIC} + local rc=${OCF_ERR_GENERIC} + local host=$(hostname -s) + ocf_log debug "ganesha_grace_start()" - attr=$(attrd_updater -Q -n ${OCF_RESKEY_grace_active}) + # give ganesha_mon RA a chance to set the crm_attr first + # I mislike the sleep, but it's not clear that looping + # with a small sleep is necessarily better + # start has a 40sec timeout, so a 5sec sleep here is okay + sleep 5 + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null) + if [ $? -ne 0 ]; then + host=$(hostname) + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null ) + if [ $? -ne 0 ]; then + ocf_log info "grace start: crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} failed" + fi + fi # Three possibilities: # 1. There is no attribute at all and attr_updater returns @@ -116,7 +130,7 @@ ganesha_grace_start() fi # case 2 - if [[ "${attr}" = *"value=\"1\"" ]]; then + if [[ "${attr}" = *"value=1" ]]; then return ${OCF_SUCCESS} fi @@ -133,10 +147,11 @@ ganesha_grace_stop() ganesha_grace_notify() { + # since this is a clone RA we should only ever see pre-start + # or post-stop mode="${OCF_RESKEY_CRM_meta_notify_type}-${OCF_RESKEY_CRM_meta_notify_operation}" - case "$mode" in - post-stop) - ocf_log debug "stop_uname:${OCF_RESKEY_CRM_meta_notify_stop_uname}" + case "${mode}" in + pre-start | post-stop) dbus-send --print-reply --system --dest=org.ganesha.nfsd /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.grace string:${OCF_RESKEY_CRM_meta_notify_stop_uname} if [ $? -ne 0 ]; then ocf_log info "dbus-send --print-reply --system --dest=org.ganesha.nfsd /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.grace string:${OCF_RESKEY_CRM_meta_notify_stop_uname} failed" @@ -149,10 +164,18 @@ ganesha_grace_notify() ganesha_grace_monitor() { - rc=${OCF_ERR_GENERIC} + local host=$(hostname -s) + ocf_log debug "monitor" - attr=$(attrd_updater -Q -n ${OCF_RESKEY_grace_active}) + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null) + if [ $? -ne 0 ]; then + host=$(hostname) + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null) + if [ $? -ne 0 ]; then + ocf_log info "crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} failed" + fi + fi # if there is no attribute (yet), maybe it's because # this RA started before ganesha_mon (nfs-mon) has had @@ -162,11 +185,11 @@ ganesha_grace_monitor() return ${OCF_SUCCESS} fi - if [[ "${attr}" = *"value=\"1\"" ]]; then - rc=${OCF_SUCCESS} + if [[ "${attr}" = *"value=1" ]]; then + return ${OCF_SUCCESS} fi - return ${rc} + return ${OCF_NOT_RUNNING} } ganesha_grace_validate() @@ -187,8 +210,8 @@ status|monitor) ganesha_grace_monitor notify) ganesha_grace_notify ;; *) ganesha_grace_usage - exit ${OCF_ERR_UNIMPLEMENTED} - ;; + exit ${OCF_ERR_UNIMPLEMENTED} + ;; esac rc=$? @@ -196,4 +219,3 @@ rc=$? # The resource agent may optionally log a debug message ocf_log debug "${OCF_RESOURCE_INSTANCE} ${__OCF_ACTION} returned $rc" exit $rc - |
