180 lines
5.1 KiB
Diff
180 lines
5.1 KiB
Diff
|
From da326b0fc4d97eb8ef5dad0469933c1b63e0a0c9 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
||
|
Date: Wed, 2 Mar 2016 19:38:46 +0100
|
||
|
Subject: [PATCH 6/6] Feature: alternative logger (in service-runnable script)
|
||
|
|
||
|
This effectively eliminates the last dependency on glue project as such.
|
||
|
---
|
||
|
Makefile.am | 2 +-
|
||
|
configure.ac | 2 ++
|
||
|
script/service-runnable | 62 ----------------------------------------------
|
||
|
script/service-runnable.in | 61 +++++++++++++++++++++++++++++++++++++++++++++
|
||
|
4 files changed, 64 insertions(+), 63 deletions(-)
|
||
|
delete mode 100755 script/service-runnable
|
||
|
create mode 100755 script/service-runnable.in
|
||
|
|
||
|
diff --git a/Makefile.am b/Makefile.am
|
||
|
index 5f360c4..3ab326b 100644
|
||
|
--- a/Makefile.am
|
||
|
+++ b/Makefile.am
|
||
|
@@ -66,7 +66,7 @@ bootharbitrator_SCRIPTS = script/lsb/booth-arbitrator
|
||
|
|
||
|
boothnoarchdir = $(datadir)/$(PACKAGE_NAME)
|
||
|
|
||
|
-boothnoarch_SCRIPTS = script/service-runnable
|
||
|
+nodist_boothnoarch_SCRIPTS = script/service-runnable
|
||
|
|
||
|
sbin_SCRIPTS = script/booth-keygen
|
||
|
|
||
|
diff --git a/configure.ac b/configure.ac
|
||
|
index 937f563..c50c553 100644
|
||
|
--- a/configure.ac
|
||
|
+++ b/configure.ac
|
||
|
@@ -147,6 +147,8 @@ AC_CONFIG_FILES([Makefile
|
||
|
src/Makefile
|
||
|
docs/Makefile])
|
||
|
|
||
|
+AC_CONFIG_FILES([script/service-runnable], [chmod +x script/service-runnable])
|
||
|
+
|
||
|
# ===============================================
|
||
|
# Helpers
|
||
|
# ===============================================
|
||
|
diff --git a/script/service-runnable b/script/service-runnable
|
||
|
deleted file mode 100755
|
||
|
index ed90c5e..0000000
|
||
|
--- a/script/service-runnable
|
||
|
+++ /dev/null
|
||
|
@@ -1,62 +0,0 @@
|
||
|
-#!/bin/bash
|
||
|
-# This script is part of Booth.
|
||
|
-# It checks whether the given resource (service) still has a chance
|
||
|
-# to run on the local cluster, so that booth knows whether to
|
||
|
-# acquire the ticket here.
|
||
|
-
|
||
|
-service="${1:?Need a resource name as first argument.}"
|
||
|
-if [ -z "$service" ]; then
|
||
|
- ha_logger "$0: bad usage: no resource name"
|
||
|
- exit 1
|
||
|
-fi
|
||
|
-tmpshadow=`mktemp booth-check.XXXXXX`
|
||
|
-if [ $? -ne 0 -o ! -f "$tmpshadow" ]; then
|
||
|
- ha_logger "$0: mktemp failed"
|
||
|
- exit 1
|
||
|
-fi
|
||
|
-
|
||
|
-trap "rm -f $tmpshadow" EXIT
|
||
|
-
|
||
|
-
|
||
|
-# We expect an output like
|
||
|
-# p_dummy (ocf::pacemaker:Dummy): Started geo-rz2-a
|
||
|
-
|
||
|
-status=`crm_simulate -O $tmpshadow --ticket-grant "$BOOTH_TICKET" --simulate --live-check 2>&1`
|
||
|
-if [ $? -ne 0 ]; then
|
||
|
- ha_logger "$0: crm_simulate failed"
|
||
|
- ha_logger "$0: crm_simulate: $status"
|
||
|
- exit 1
|
||
|
-fi
|
||
|
-
|
||
|
-if echo "$status" |
|
||
|
- sed -n '/^Revised cluster status:/,$p' |
|
||
|
- egrep "^[[:space:]]+$service[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
|
||
|
-then
|
||
|
- # can be started - we're done.
|
||
|
- exit 0
|
||
|
-fi
|
||
|
-
|
||
|
-# If target-role is Stopped, it judges with being stopped explicitly.
|
||
|
-output=$(crm_resource --meta --get-parameter="target-role" --resource=$service 2>/dev/null)
|
||
|
-rc=$?
|
||
|
-if [ $rc -eq 0 -a "$output" = "Stopped" ]; then
|
||
|
- exit 0
|
||
|
-fi
|
||
|
-
|
||
|
-# is ticket in standby?
|
||
|
-output=$(crm_ticket --ticket "$BOOTH_TICKET" --get-attr standby)
|
||
|
-rc=$?
|
||
|
-if [ $rc -eq 0 -a "$output" = true ]; then
|
||
|
- exit 0
|
||
|
-fi
|
||
|
-
|
||
|
-# Some error occured.
|
||
|
-# Try to help the admin with a bit of diagnostic.
|
||
|
-#
|
||
|
-# disallow ms-resources, ie. only primitives wanted here
|
||
|
-if ! crm_resource -l | grep -v ":" | grep "$service" ; then
|
||
|
- ha_logger "Defined resource '$service' in $BOOTH_CONF_PATH is not a primitive??"
|
||
|
-fi
|
||
|
-
|
||
|
-exit 1
|
||
|
-
|
||
|
diff --git a/script/service-runnable.in b/script/service-runnable.in
|
||
|
new file mode 100755
|
||
|
index 0000000..9ea33d4
|
||
|
--- /dev/null
|
||
|
+++ b/script/service-runnable.in
|
||
|
@@ -0,0 +1,61 @@
|
||
|
+#!/bin/bash
|
||
|
+# This script is part of Booth.
|
||
|
+# It checks whether the given resource (service) still has a chance
|
||
|
+# to run on the local cluster, so that booth knows whether to
|
||
|
+# acquire the ticket here.
|
||
|
+
|
||
|
+service="${1:?Need a resource name as first argument.}"
|
||
|
+if [ -z "$service" ]; then
|
||
|
+ @LOGGER@ "$0: bad usage: no resource name"
|
||
|
+ exit 1
|
||
|
+fi
|
||
|
+tmpshadow=`mktemp booth-check.XXXXXX`
|
||
|
+if [ $? -ne 0 -o ! -f "$tmpshadow" ]; then
|
||
|
+ @LOGGER@ "$0: mktemp failed"
|
||
|
+ exit 1
|
||
|
+fi
|
||
|
+
|
||
|
+trap "rm -f $tmpshadow" EXIT
|
||
|
+
|
||
|
+
|
||
|
+# We expect an output like
|
||
|
+# p_dummy (ocf::pacemaker:Dummy): Started geo-rz2-a
|
||
|
+
|
||
|
+status=`crm_simulate -O $tmpshadow --ticket-grant "$BOOTH_TICKET" --simulate --live-check 2>&1`
|
||
|
+if [ $? -ne 0 ]; then
|
||
|
+ @LOGGER@ "$0: crm_simulate failed"
|
||
|
+ @LOGGER@ "$0: crm_simulate: $status"
|
||
|
+ exit 1
|
||
|
+fi
|
||
|
+
|
||
|
+if echo "$status" |
|
||
|
+ sed -n '/^Revised cluster status:/,$p' |
|
||
|
+ egrep "^[[:space:]]+$service[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
|
||
|
+then
|
||
|
+ # can be started - we're done.
|
||
|
+ exit 0
|
||
|
+fi
|
||
|
+
|
||
|
+# If target-role is Stopped, it judges with being stopped explicitly.
|
||
|
+output=$(crm_resource --meta --get-parameter="target-role" --resource=$service 2>/dev/null)
|
||
|
+rc=$?
|
||
|
+if [ $rc -eq 0 -a "$output" = "Stopped" ]; then
|
||
|
+ exit 0
|
||
|
+fi
|
||
|
+
|
||
|
+# is ticket in standby?
|
||
|
+output=$(crm_ticket --ticket "$BOOTH_TICKET" --get-attr standby)
|
||
|
+rc=$?
|
||
|
+if [ $rc -eq 0 -a "$output" = true ]; then
|
||
|
+ exit 0
|
||
|
+fi
|
||
|
+
|
||
|
+# Some error occured.
|
||
|
+# Try to help the admin with a bit of diagnostic.
|
||
|
+#
|
||
|
+# disallow ms-resources, ie. only primitives wanted here
|
||
|
+if ! crm_resource -l | grep -v ":" | grep "$service" ; then
|
||
|
+ @LOGGER@ "Defined resource '$service' in $BOOTH_CONF_PATH is not a primitive??"
|
||
|
+fi
|
||
|
+
|
||
|
+exit 1
|
||
|
--
|
||
|
2.4.11
|
||
|
|