Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: sergeyfd/resource-agents
base: 4c63689634
...
head fork: sergeyfd/resource-agents
compare: 4aec4cbe63
  • 4 commits
  • 6 files changed
  • 0 commit comments
  • 2 contributors
Commits on Aug 02, 2011
@dmuhamedagic dmuhamedagic Dev: apache: split off configuration reading and monitor parts
- http-mon.sh contains http client management and http status
  check code
- apache-conf.sh contains apache configuration parser

No code has been changed.
924d070
@dmuhamedagic dmuhamedagic Low: Tools: ocft: make Filesystem test less dangerous 7de8544
Commits on Aug 05, 2011
@dmuhamedagic dmuhamedagic Dev: ocf-shellfuncs: fix wrong logic introduced in commit 8468b5 a572ab8
Commits on Aug 08, 2011
@sergeyfd Merge remote-tracking branch 'upstream/master' 4aec4cb
View
4 heartbeat/Makefile.am
@@ -114,7 +114,9 @@ ocfcommondir = $(OCF_LIB_DIR_PREFIX)/heartbeat
ocfcommon_DATA = ocf-shellfuncs \
ocf-binaries \
ocf-directories \
- ocf-returncodes
+ ocf-returncodes \
+ apache-conf.sh \
+ http-mon.sh
# Legacy locations
hbdir = $(sysconfdir)/ha.d
View
268 heartbeat/apache
@@ -43,6 +43,8 @@
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
+. ${OCF_FUNCTIONS_DIR}/apache-conf.sh
+. ${OCF_FUNCTIONS_DIR}/http-mon.sh
HA_VARRUNDIR=${HA_VARRUN}
#######################################################################
@@ -60,12 +62,6 @@ then
HTTPDLIST="$HTTPDLIST `$MPM 2>/dev/null`"
fi
-# default options for http clients
-# NB: We _always_ test a local resource, so it should be
-# safe to connect from the local interface.
-WGETOPTS="-O- -q -L --no-proxy --bind-address=127.0.0.1"
-CURLOPTS="-o - -Ss -L --interface lo"
-
LOCALHOST="http://localhost"
HTTPDOPTS="-DSTATUS"
DEFAULT_IBMCONFIG=/opt/IBMHTTPServer/conf/httpd.conf
@@ -113,262 +109,6 @@ action:
}
#
-# run the http client
-#
-curl_func() {
- cl_opts="$CURLOPTS $test_httpclient_opts"
- if [ x != "x$test_user" ]; then
- echo "-u $test_user:$test_password" |
- curl -K - $cl_opts "$1"
- else
- curl $cl_opts "$1"
- fi
-}
-wget_func() {
- auth=""
- cl_opts="$WGETOPTS $test_httpclient_opts"
- [ x != "x$test_user" ] &&
- auth="--http-user=$test_user --http-passwd=$test_password"
- wget $auth $cl_opts "$1"
-}
-#
-# rely on whatever the user provided
-userdefined() {
- $test_httpclient $test_httpclient_opts "$1"
-}
-
-#
-# find a good http client
-#
-findhttpclient() {
- # prefer wget (for historical reasons)
- if [ "x$CLIENT" != x ]; then
- echo "$CLIENT"
- elif which wget >/dev/null 2>&1; then
- echo "wget"
- elif which curl >/dev/null 2>&1; then
- echo "curl"
- else
- return 1
- fi
-}
-gethttpclient() {
- [ -z "$test_httpclient" ] &&
- test_httpclient=$ourhttpclient
- case "$test_httpclient" in
- curl|wget) echo ${test_httpclient}_func;; #these are supported
- *) echo userdefined;;
- esac
-}
-
-# test configuration good?
-is_testconf_sane() {
- if [ "x$test_regex" = x -o "x$test_url" = x ]; then
- ocf_log err "test regular expression or test url empty"
- return 1
- fi
- if [ "x$test_user$test_password" != x -a \( "x$test_user" = x -o "x$test_password" = x \) ]; then
- ocf_log err "bad user authentication for extended test"
- return 1
- fi
- return 0
-}
-#
-# read the test definition from the config
-#
-readtestconf() {
- test_name="$1" # we look for this one or the first one if empty
- lcnt=0
- readdef=""
- test_url="" test_regex=""
- test_user="" test_password=""
- test_httpclient="" test_httpclient_opts=""
-
- while read key value; do
- lcnt=$((lcnt+1))
- if [ "$readdef" ]; then
- case "$key" in
- "url") test_url="$value" ;;
- "user") test_user="$value" ;;
- "password") test_password="$value" ;;
- "client") test_httpclient="$value" ;;
- "client_opts") test_httpclient_opts="$value" ;;
- "match") test_regex="$value" ;;
- "end") break ;;
- "#"*|"") ;;
- *) ocf_log err "$lcnt: $key: unknown keyword"; return 1 ;;
- esac
- else
- [ "$key" = "test" ] &&
- [ -z "$test_name" -o "$test_name" = "$value" ] &&
- readdef=1
- fi
- done
-}
-
-source_envfiles() {
- for f; do
- [ -f "$f" -a -r "$f" ] &&
- . "$f"
- done
-}
-
-apachecat() {
- awk '
- function procline() {
- split($0,a);
- if( a[1]~/^[Ii]nclude$/ ) {
- procinclude(a[2]);
- } else {
- if( a[1]=="ServerRoot" ) {
- rootdir=a[2];
- gsub("\"","",rootdir);
- }
- print;
- }
- }
- function printfile(infile, a) {
- while( (getline<infile) > 0 ) {
- procline();
- }
- close(infile);
- }
- function allfiles(dir, cmd,f) {
- cmd="find -L "dir" -type f";
- while( ( cmd | getline f ) > 0 ) {
- printfile(f);
- }
- close(cmd);
- }
- function listfiles(pattern, cmd,f) {
- cmd="ls "pattern" 2>/dev/null";
- while( ( cmd | getline f ) > 0 ) {
- printfile(f);
- }
- close(cmd);
- }
- function procinclude(spec) {
- if( rootdir!="" && spec!~/^\// ) {
- spec=rootdir"/"spec;
- }
- if( isdir(spec) ) {
- allfiles(spec); # read all files in a directory (and subdirs)
- } else {
- listfiles(spec); # there could be jokers
- }
- }
- function isdir(s) {
- return !system("test -d \""s"\"");
- }
- { procline(); }
- ' $1 |
- sed 's/#.*//;s/[[:blank:]]*$//;s/^[[:blank:]]*//' |
- grep -v '^$'
-}
-
-#
-# set parameters (as shell vars) from our apache config file
-#
-get_apache_params() {
- configfile=$1
- shift 1
- vars=`echo $@ | sed 's/ /,/g'`
-
- eval `
- apachecat $configfile | awk -v vars="$vars" '
- BEGIN{
- split(vars,v,",");
- for( i in v )
- vl[i]=tolower(v[i]);
- }
- {
- for( i in v )
- if( tolower($1)==vl[i] ) {
- print v[i]"="$2
- delete vl[i]
- break
- }
- }
- '`
-}
-
-#
-# Return the location(s) that are handled by the given handler
-#
-FindLocationForHandler() {
- PerlScript='while (<>) {
- /<Location "?([^ >"]+)/i && ($loc=$1);
- '"/SetHandler +$2"'/i && print "$loc\n";
- }'
- apachecat $1 | perl -e "$PerlScript"
-}
-
-#
-# Check if the port is valid
-#
-CheckPort() {
- ocf_is_decimal "$1" && [ $1 -gt 0 ]
-}
-
-buildlocalurl() {
- [ "x$Listen" != "x" ] &&
- echo "http://${Listen}" ||
- echo "${LOCALHOST}:${PORT}"
-}
-#
-# Get all the parameters we need from the Apache config file
-#
-GetParams() {
- ConfigFile=$1
- if [ ! -f $ConfigFile ]; then
- return 1
- fi
- get_apache_params $ConfigFile ServerRoot PidFile Port Listen
- case $PidFile in
- /*) ;;
- [[:alnum:]]*) PidFile=$ServerRoot/$PidFile;;
- *) PidFile=$HA_VARRUNDIR/${httpd_basename}.pid;;
- esac
-
- for p in "$PORT" "$Port" 80; do
- if CheckPort "$p"; then
- PORT="$p"
- break
- fi
- done
-
- echo $Listen | grep ':' >/dev/null || # Listen could be just port spec
- Listen="localhost:$Listen"
-
- #
- # It's difficult to figure out whether the server supports
- # the status operation.
- # (we start our server with -DSTATUS - just in case :-))
- #
- # Typically (but not necessarily) the status URL is /server-status
- #
- # For us to think status will work, we have to have the following things:
- #
- # - The server-status handler has to be mapped to some URL somewhere
- #
- # We assume that:
- #
- # - the "main" web server at $PORT will also support it if we can find it
- # somewhere in the file
- # - it will be supported at the same URL as the one we find in the file
- #
- # If this doesn't work for you, then set the statusurl attribute.
- #
- if
- [ "X$STATUSURL" = "X" ]
- then
- StatusURL=`FindLocationForHandler $1 server-status | tail -1`
- STATUSURL="`buildlocalurl`$StatusURL"
- fi
- test "$PidFile"
-}
-
-#
# return TRUE if a process with given PID is running
#
ProcessRunning() {
@@ -481,10 +221,6 @@ status_apache() {
fi
}
-fixtesturl() {
- echo $test_url | grep -qs "^http" && return
- test_url="`buildlocalurl`$test_url"
-}
monitor_apache_extended() {
if [ "$TESTCONFFILE" ]; then
readtestconf < $TESTCONFFILE
View
181 heartbeat/apache-conf.sh
@@ -0,0 +1,181 @@
+#
+# Common apache code
+# (sourced by apache)
+#
+# Author: Alan Robertson
+# Sun Jiang Dong
+#
+# Support: linux-ha@lists.linux-ha.org
+#
+# License: GNU General Public License (GPL)
+#
+# Copyright: (C) 2002-2005 International Business Machines
+#
+
+source_envfiles() {
+ for f; do
+ [ -f "$f" -a -r "$f" ] &&
+ . "$f"
+ done
+}
+
+apachecat() {
+ awk '
+ function procline() {
+ split($0,a);
+ if( a[1]~/^[Ii]nclude$/ ) {
+ procinclude(a[2]);
+ } else {
+ if( a[1]=="ServerRoot" ) {
+ rootdir=a[2];
+ gsub("\"","",rootdir);
+ }
+ print;
+ }
+ }
+ function printfile(infile, a) {
+ while( (getline<infile) > 0 ) {
+ procline();
+ }
+ close(infile);
+ }
+ function allfiles(dir, cmd,f) {
+ cmd="find -L "dir" -type f";
+ while( ( cmd | getline f ) > 0 ) {
+ printfile(f);
+ }
+ close(cmd);
+ }
+ function listfiles(pattern, cmd,f) {
+ cmd="ls "pattern" 2>/dev/null";
+ while( ( cmd | getline f ) > 0 ) {
+ printfile(f);
+ }
+ close(cmd);
+ }
+ function procinclude(spec) {
+ if( rootdir!="" && spec!~/^\// ) {
+ spec=rootdir"/"spec;
+ }
+ if( isdir(spec) ) {
+ allfiles(spec); # read all files in a directory (and subdirs)
+ } else {
+ listfiles(spec); # there could be jokers
+ }
+ }
+ function isdir(s) {
+ return !system("test -d \""s"\"");
+ }
+ { procline(); }
+ ' $1 |
+ sed 's/#.*//;s/[[:blank:]]*$//;s/^[[:blank:]]*//' |
+ grep -v '^$'
+}
+
+#
+# set parameters (as shell vars) from our apache config file
+#
+get_apache_params() {
+ configfile=$1
+ shift 1
+ vars=`echo $@ | sed 's/ /,/g'`
+
+ eval `
+ apachecat $configfile | awk -v vars="$vars" '
+ BEGIN{
+ split(vars,v,",");
+ for( i in v )
+ vl[i]=tolower(v[i]);
+ }
+ {
+ for( i in v )
+ if( tolower($1)==vl[i] ) {
+ print v[i]"="$2
+ delete vl[i]
+ break
+ }
+ }
+ '`
+}
+
+#
+# Return the location(s) that are handled by the given handler
+#
+FindLocationForHandler() {
+ PerlScript='while (<>) {
+ /<Location "?([^ >"]+)/i && ($loc=$1);
+ '"/SetHandler +$2"'/i && print "$loc\n";
+ }'
+ apachecat $1 | perl -e "$PerlScript"
+}
+
+#
+# Check if the port is valid
+#
+CheckPort() {
+ ocf_is_decimal "$1" && [ $1 -gt 0 ]
+}
+
+buildlocalurl() {
+ [ "x$Listen" != "x" ] &&
+ echo "http://${Listen}" ||
+ echo "${LOCALHOST}:${PORT}"
+}
+# the test url may need a local prefix (as specified in the
+# apache Listen directive)
+fixtesturl() {
+ echo $test_url | grep -qs "^http" && return
+ test_url="`buildlocalurl`$test_url"
+}
+#
+# Get all the parameters we need from the Apache config file
+#
+GetParams() {
+ ConfigFile=$1
+ if [ ! -f $ConfigFile ]; then
+ return 1
+ fi
+ get_apache_params $ConfigFile ServerRoot PidFile Port Listen
+ case $PidFile in
+ /*) ;;
+ [[:alnum:]]*) PidFile=$ServerRoot/$PidFile;;
+ *) PidFile=$HA_VARRUNDIR/${httpd_basename}.pid;;
+ esac
+
+ for p in "$PORT" "$Port" 80; do
+ if CheckPort "$p"; then
+ PORT="$p"
+ break
+ fi
+ done
+
+ echo $Listen | grep ':' >/dev/null || # Listen could be just port spec
+ Listen="localhost:$Listen"
+
+ #
+ # It's difficult to figure out whether the server supports
+ # the status operation.
+ # (we start our server with -DSTATUS - just in case :-))
+ #
+ # Typically (but not necessarily) the status URL is /server-status
+ #
+ # For us to think status will work, we have to have the following things:
+ #
+ # - The server-status handler has to be mapped to some URL somewhere
+ #
+ # We assume that:
+ #
+ # - the "main" web server at $PORT will also support it if we can find it
+ # somewhere in the file
+ # - it will be supported at the same URL as the one we find in the file
+ #
+ # If this doesn't work for you, then set the statusurl attribute.
+ #
+ if
+ [ "X$STATUSURL" = "X" ]
+ then
+ StatusURL=`FindLocationForHandler $1 server-status | tail -1`
+ STATUSURL="`buildlocalurl`$StatusURL"
+ fi
+ test "$PidFile"
+}
View
113 heartbeat/http-mon.sh
@@ -0,0 +1,113 @@
+#
+# General http monitor code
+# (sourced by apache and httpmon)
+#
+# Author: Alan Robertson
+# Sun Jiang Dong
+#
+# Support: linux-ha@lists.linux-ha.org
+#
+# License: GNU General Public License (GPL)
+#
+# Copyright: (C) 2002-2005 International Business Machines
+#
+
+# default options for http clients
+# NB: We _always_ test a local resource, so it should be
+# safe to connect from the local interface.
+WGETOPTS="-O- -q -L --no-proxy --bind-address=127.0.0.1"
+CURLOPTS="-o - -Ss -L --interface lo"
+
+#
+# run the http client
+#
+curl_func() {
+ cl_opts="$CURLOPTS $test_httpclient_opts"
+ if [ x != "x$test_user" ]; then
+ echo "-u $test_user:$test_password" |
+ curl -K - $cl_opts "$1"
+ else
+ curl $cl_opts "$1"
+ fi
+}
+wget_func() {
+ auth=""
+ cl_opts="$WGETOPTS $test_httpclient_opts"
+ [ x != "x$test_user" ] &&
+ auth="--http-user=$test_user --http-passwd=$test_password"
+ wget $auth $cl_opts "$1"
+}
+#
+# rely on whatever the user provided
+userdefined() {
+ $test_httpclient $test_httpclient_opts "$1"
+}
+
+#
+# find a good http client
+#
+findhttpclient() {
+ # prefer wget (for historical reasons)
+ if [ "x$CLIENT" != x ]; then
+ echo "$CLIENT"
+ elif which wget >/dev/null 2>&1; then
+ echo "wget"
+ elif which curl >/dev/null 2>&1; then
+ echo "curl"
+ else
+ return 1
+ fi
+}
+gethttpclient() {
+ [ -z "$test_httpclient" ] &&
+ test_httpclient=$ourhttpclient
+ case "$test_httpclient" in
+ curl|wget) echo ${test_httpclient}_func;; #these are supported
+ *) echo userdefined;;
+ esac
+}
+
+# test configuration good?
+is_testconf_sane() {
+ if [ "x$test_regex" = x -o "x$test_url" = x ]; then
+ ocf_log err "test regular expression or test url empty"
+ return 1
+ fi
+ if [ "x$test_user$test_password" != x -a \( "x$test_user" = x -o "x$test_password" = x \) ]; then
+ ocf_log err "bad user authentication for extended test"
+ return 1
+ fi
+ return 0
+}
+#
+# read the test definition from the config
+#
+readtestconf() {
+ test_name="$1" # we look for this one or the first one if empty
+ lcnt=0
+ readdef=""
+ test_url="" test_regex=""
+ test_user="" test_password=""
+ test_httpclient="" test_httpclient_opts=""
+
+ while read key value; do
+ lcnt=$((lcnt+1))
+ if [ "$readdef" ]; then
+ case "$key" in
+ "url") test_url="$value" ;;
+ "user") test_user="$value" ;;
+ "password") test_password="$value" ;;
+ "client") test_httpclient="$value" ;;
+ "client_opts") test_httpclient_opts="$value" ;;
+ "match") test_regex="$value" ;;
+ "end") break ;;
+ "#"*|"") ;;
+ *) ocf_log err "$lcnt: $key: unknown keyword"; return 1 ;;
+ esac
+ else
+ [ "$key" = "test" ] &&
+ [ -z "$test_name" -o "$test_name" = "$value" ] &&
+ readdef=1
+ fi
+ done
+}
View
2  heartbeat/ocf-shellfuncs.in
@@ -171,7 +171,7 @@ hadate() {
}
set_logtag() {
- if [ -n "$HA_LOGTAG" ]; then
+ if [ -z "$HA_LOGTAG" ]; then
if [ -n "$OCF_RESOURCE_INSTANCE" ]; then
HA_LOGTAG="$__SCRIPT_NAME($OCF_RESOURCE_INSTANCE)[$$]"
else
View
4 tools/ocft/Filesystem
@@ -21,12 +21,12 @@ SETUP-AGENT
OCFT_fs=/var/run/resource-agents/ocft-Filesystem-fs
OCFT_loop=/dev/loop0
OCFT_dir=/var/run/resource-agents/ocft-Filesystem-mnt
+ losetup $OCFT_loop 2>/dev/null && exit 1
rmdir $OCFT_dir 2>/dev/null || true
- losetup -d $OCFT_loop 2>/dev/null || true
mkdir $OCFT_dir
dd if=/dev/zero of=$OCFT_fs bs=1024k count=1 2>/dev/null
+ mke2fs -Fq $OCFT_fs
losetup $OCFT_loop $OCFT_fs
- mke2fs -Fq $OCFT_loop
CASE-BLOCK default_status
AgentRun stop

No commit comments for this range

Something went wrong with that request. Please try again.