diff --git a/tools/Makefile.am b/tools/Makefile.am index 974e87c6a0..eae9f60bd2 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,128 +1,128 @@ # # heartbeat: Linux-HA heartbeat code # # Copyright (C) 2001 Michael Moerz # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in ccdv INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ -I$(AISPREFIX)/include/openais EXTRA_DIST = ccdv.c attrd.h halibdir = $(libdir)/@HB_PKG@ -halib_SCRIPTS = haresources2cib.py +halib_SCRIPTS = haresources2cib.py hb2openais.sh halib_PROGRAMS = attrd pingd halib_PYTHON = crm_primitive.py crm_utils.py crm_commands.py sbin_PROGRAMS = crmadmin cibadmin ccm_tool crm_diff crm_mon iso8601 \ crm_master crm_standby crm_failcount crm_attribute \ crm_resource crm_verify crm_uuid crm_shadow attrd_updater sbin_SCRIPTS = crm ## SOURCES ccdv: $(top_srcdir)/tools/ccdv.c gcc $(AM_CFLAGS) $(CFLAGS) -o ccdv $(top_srcdir)/tools/ccdv.c INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir) -I$(top_srcdir) \ -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ -I$(AISPREFIX)/include/openais COMMONLIBS = \ $(top_builddir)/lib/common/libcrmcommon.la \ $(top_builddir)/lib/cib/libcib.la \ -lplumb \ $(GLIBLIB) $(CURSESLIBS) $(LIBRT) \ $(CLUSTERLIBS) ## SOURCES #noinst_HEADERS = config.h control.h crmd.h noinst_HEADERS = crmadmin_SOURCES = crmadmin.c crmadmin_LDADD = $(COMMONLIBS) $(CLUSTERLIBS) \ $(top_builddir)/lib/pengine/libpe_status.la crm_uuid_SOURCES = crm_uuid.c crm_uuid_LDADD = $(GLIBLIB) cibadmin_SOURCES = cibadmin.c cibadmin_LDADD = $(COMMONLIBS) crm_shadow_SOURCES = cib_shadow.c crm_shadow_LDADD = $(COMMONLIBS) ccm_tool_SOURCES = ccm_epoche.c ccm_tool_LDADD = $(COMMONLIBS) $(CLUSTERLIBS) \ $(top_builddir)/lib/common/libcrmcluster.la crm_diff_SOURCES = xml_diff.c crm_diff_LDADD = $(COMMONLIBS) crm_mon_SOURCES = crm_mon.c crm_mon_LDADD = $(COMMONLIBS) -llrm \ $(top_builddir)/lib/pengine/libpe_status.la # Arguments could be made that this should live in crm/pengine crm_verify_SOURCES = crm_verify.c crm_verify_LDADD = $(COMMONLIBS) \ $(top_builddir)/lib/pengine/libpe_status.la \ $(top_builddir)/pengine/libpengine.la crm_master_SOURCES = crm_attribute.c crm_master_LDADD = $(COMMONLIBS) crm_standby_SOURCES = crm_attribute.c crm_standby_LDADD = $(COMMONLIBS) crm_attribute_SOURCES = crm_attribute.c crm_attribute_LDADD = $(COMMONLIBS) crm_failcount_SOURCES = crm_attribute.c crm_failcount_LDADD = $(COMMONLIBS) crm_resource_SOURCES = crm_resource.c crm_resource_LDADD = $(COMMONLIBS) \ $(top_builddir)/lib/pengine/libpe_rules.la \ $(top_builddir)/lib/pengine/libpe_status.la iso8601_SOURCES = test.iso8601.c iso8601_LDADD = $(COMMONLIBS) # A little trick. Now ccdv can be auto-built but not auto-cleaned. attrd_DEPENDENCIES = ccdv attrd_SOURCES = attrd.c attrd_LDADD = $(COMMONLIBS) $(top_builddir)/lib/common/libcrmcluster.la pingd_SOURCES = pingd.c pingd_LDADD = $(COMMONLIBS) attrd_updater_SOURCES = attrd_updater.c attrd_updater_LDADD = $(COMMONLIBS) clean-generic: rm -f *.log *.debug *.xml *~ install-exec-local: uninstall-local: .PHONY: install-exec-hook diff --git a/tools/hb2openais.sh b/tools/hb2openais.sh new file mode 100755 index 0000000000..303518c953 --- /dev/null +++ b/tools/hb2openais.sh @@ -0,0 +1,889 @@ +#!/bin/sh + + # Copyright (C) 2008 Dejan Muhamedagic + # + # This program is free software; you can redistribute it and/or + # modify it under the terms of the GNU General Public + # License as published by the Free Software Foundation; either + # version 2.1 of the License, or (at your option) any later version. + # + # This software is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + # General Public License for more details. + # + # You should have received a copy of the GNU General Public + # License along with this library; if not, write to the Free Software + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + # + +. /etc/ha.d/shellfuncs +. $HA_NOARCHBIN/utillib.sh + +PROG=`basename $0` +# FIXME: once this is part of the package! +PROGDIR=`dirname $0` +echo "$PROGDIR" | grep -qs '^/' || { + test -f /usr/sbin/$PROG && + PROGDIR=/usr/sbin + test -f $HA_NOARCHBIN/$PROG && + PROGDIR=$HA_NOARCHBIN +} + +# the default syslog facility is not (yet) exported by heartbeat +# to shell scripts +# +DEFAULT_HA_LOGFACILITY="daemon" +export DEFAULT_HA_LOGFACILITY +LOGD_CF=`findlogdcf /etc $HA_DIR` +export LOGD_CF +AIS_CONF=/etc/ais/openais.conf +AIS_KEYF=/etc/ais/authkey + +CIB=/var/lib/heartbeat/crm/cib.xml +CIBSIG=/var/lib/heartbeat/crm/cib.xml.sig +HOSTCACHE=/var/lib/heartbeat/hostcache +HB_UUID=/var/lib/heartbeat/hb_uuid +DONE_F=/var/run/heartbeat/.$PROG.conv_done +BACKUPDIR=/var/tmp/`basename $PROG .sh`.backup +BACKUP_FILES=" $CIB $CIBSIG $HOSTCACHE $HB_UUID $AIS_CONF " +RM_FILES=" $CIBSIG $HOSTCACHE $HB_UUID " +REMOTE_RM_FILES=" $CIB $CIBSIG $HOSTCACHE $HB_UUID " +DIST_FILES=" $AIS_CONF $AIS_KEYF $DONE_F " +MAN_TARF=/var/tmp/`basename $PROG .sh`.tar.gz + +[ `id -un` = dejan ] && MYSUDO=sudo + +: ${SSH_OPTS="-T"} + +usage() { + cat</dev/null + else + ssh -T -o Batchmode=yes $1 true 2>/dev/null + fi +} +findsshuser() { + for u in "" $TRY_SSH; do + rc=0 + for n in `getnodes`; do + [ "$node" = "$WE" ] && continue + testsshuser $n $u || { + rc=1 + break + } + done + if [ $rc -eq 0 ]; then + echo $u + return 0 + fi + done + return 1 +} +newportinfo() { + info "the port number for the multicast is set to 5405" + info "please update your firewall rules (if any)" +} +changemediainfo() { + info "openais uses multicast for communication" + info "please make sure that your network infrastructure supports it" +} +multicastinfo() { + info "multicast address for openais set to $1" +} +netaddrinfo() { + info "network address for openais set to $1" +} +backup_files() { + info "backing up $BACKUP_FILES to $BACKUPDIR" + $DRY mkdir $BACKUPDIR || { + echo sorry, could not create $BACKUPDIR directory + echo please cleanup + exit 1 + } + for f in $BACKUP_FILES; do + $DRY cp -p $f $BACKUPDIR || { + echo sorry, could not copy $f to $BACKUPDIR + exit 1 + } + done +} +revert() { + test -d $BACKUPDIR || { + echo sorry, there is no $BACKUPDIR directory + echo cannot revert + exit 1 + } + for f in $BACKUP_FILES; do + cp -p $BACKUPDIR/`basename $f` $f || { + echo sorry, could not copy $BACKUPDIR/`basename $f` to $f + } + done +} +pls_press_enter() { + cat< $AIS_CONF || + fatal "cannot create $AIS_CONF" + grep -wqs interface $AIS_CONF || + fatal "no media found in $HA_CF" +else + openaisconf +fi + +info "Generating a key for OpenAIS authentication ..." +$DRY ais-keygen || + fatal "cannot generate the key using ais-keygen" + +# remove various files which could get in a way + +$DRY rm -f $RM_FILES + +zap_nodes() { + $MYSUDO python - < 0: + opts = ' '.join(s[3:]) + elif s[0] == "ping": + ping_list.append(s[1]) + f.close() + clone = pingd_rsc(opts,' '.join(ping_list)) + resources.appendChild(clone) + +CIB = '/var/lib/heartbeat/crm/cib.xml' +doc = load_cib(CIB) +xml_processnodes(doc,is_whitespace,rmnodes) +resources = doc.getElementsByTagName("resources")[0] +constraints = doc.getElementsByTagName("constraints")[0] +if not resources: + print "ERROR: sorry, no resources section in the CIB, cannot proceed" + sys.exit(1) +if not constraints: + print "ERROR: sorry, no constraints section in the CIB, cannot proceed" + sys.exit(1) +rc = 0 + +for rsc in doc.getElementsByTagName("primitive"): + rsc_id = rsc.getAttribute("id") + rsc_type = rsc.getAttribute("type") + if rsc_type == "Evmsd": + print "INFO: removing the Evmsd resource" + print doc.toprettyxml() + resources.removeChild(rsc) + elif rsc_type == "EvmsSCC": + print "INFO: EvmsSCC resource is going to be replaced by LVM" + vg = get_input("Please supply the name of the volume group corresponding to %s:"%rsc_id) + node = mklvm(rsc_id,vg) + parent = rsc.parentNode + parent.removeChild(rsc) + parent.appendChild(node) + rsc.unlink() + elif rsc_type == "Filesystem": + if get_param(rsc,"fstype") == "ocfs2": + if get_param(rsc,"device").find("evms") > 0: + change_ocfs2_device(rsc) + id = rsc.getAttribute("id") + print "INFO: adding required cloned resources for %s"%id + add_ocfs_clones(id) + print "INFO: adding constraints for %s"%id + add_ocfs_constraints(rsc,id) + print "INFO: adding target_role=Stopped to %s"%id + stop_ocfs2(rsc) + +handle_pingd_respawn() + +s = skip_first(doc.toprettyxml()) +tmp = write_tmp(s) +print tmp + +EOF +} + +part2() { + intro_part2 || return 0 + tmpfile=`convert_cib` + $MYSUDO [ -f "$tmpfile" ] || + fatal "failed to process the CIB" + $DRY mv $tmpfile $CIB + info "Processed the CIB successfully" +} +dcidle() { + try_crmadmin=10 + dc="" + while [ -z "$dc" -a $try_crmadmin -gt 0 ]; do + dc=`$MYSUDO crmadmin -D | awk '{print $NF}'` + try_crmadmin=$((try_crmadmin-1)) + done + + if [ x = x"$dc" ]; then + echo "sorry, no dc found/elected" + exit 1 + fi + maxcnt=60 cnt=0 + while [ $cnt -lt $maxcnt ]; do + stat=`$MYSUDO crmadmin -S $dc` + ec=$? + echo $stat | grep -qs S_IDLE && break + [ "$1" = "-v" ] && echo $stat + sleep 1 + printf "." + cnt=$((cnt+1)) + done + echo status: $stat + echo waited: $cnt + echo $stat | grep -qs S_IDLE +} +wait_cluster() { + printf "waiting for crm to start." + for i in 1 2 3 4 5; do + for j in 1 2; do + sleep 1; printf "." + done + done + dcidle +} +tune_ocfs2() { + cat<