diff --git a/GNUmakefile b/GNUmakefile index 101b2df9d5..0e4b55dc78 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,135 +1,139 @@ # # Copyright (C) 2008 Andrew Beekhof # # 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. # -include Makefile PACKAGE ?= pacemaker # Force 'make dist' to be consistent with 'make export' #distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE) TARFILE = $(distdir).tar.bz2 DIST_ARCHIVES = $(TARFILE) LAST_RELEASE = Pacemaker-1.1.0 STABLE_SERIES = stable-1.0 RPM_ROOT = $(shell pwd) RPM_OPTS = --define "_sourcedir $(RPM_ROOT)" \ --define "_specdir $(RPM_ROOT)" \ --define "_srcrpmdir $(RPM_ROOT)" \ # Default to fedora compliant spec files # SLES: /etc/SuSE-release # openSUSE: /etc/SuSE-release # RHEL: /etc/redhat-release # Fedora: /etc/fedora-release, /etc/redhat-release, /etc/system-release getdistro = $(shell test -e /etc/SuSE-release || echo fedora; test -e /etc/SuSE-release && echo suse) DISTRO ?= $(call getdistro) TAG ?= tip +initialize: + ./autogen.sh + echo "Now run configure with any arguments (eg. --prefix) specific to your system" + export: rm -f $(TARFILE) hg archive -t tbz2 -r $(TAG) $(TARFILE) echo `date`: Rebuilt $(TARFILE) pacemaker-fedora.spec: pacemaker.spec cp $(PACKAGE).spec $(PACKAGE)-$(DISTRO).spec @echo Rebuilt $@ pacemaker-epel.spec: pacemaker.spec cp $(PACKAGE).spec $(PACKAGE)-$(DISTRO).spec @echo Rebuilt $@ pacemaker-suse.spec: pacemaker.spec cp $(PACKAGE).spec $@ sed -i.sed s:%{_docdir}/%{name}:%{_docdir}/%{name}-%{version}:g $@ sed -i.sed s:corosynclib:libcorosync:g $@ sed -i.sed s:pacemaker-libs:libpacemaker3:g $@ sed -i.sed s:heartbeat-libs:heartbeat:g $@ sed -i.sed s:cluster-glue-libs:libglue:g $@ sed -i.sed s:libselinux-devel:automake:g $@ sed -i.sed s:lm_sensors-devel:automake:g $@ sed -i.sed s:bzip2-devel:libbz2-devel:g $@ sed -i.sed s:Development/Libraries:Development/Libraries/C\ and\ C++:g $@ sed -i.sed s:System\ Environment/Daemons:Productivity/Clustering/HA:g $@ sed -i.sed s:bcond_without\ publican:bcond_with\ publican:g $@ sed -i.sed s:\#global\ py_sitedir:\%global\ py_sitedir:g $@ @echo Rebuilt $@ srpm: export $(PACKAGE)-$(DISTRO).spec rm -f *.src.rpm rpmbuild -bs --define "dist .$(DISTRO)" $(RPM_OPTS) $(PACKAGE)-$(DISTRO).spec rpm: srpm @echo To create custom builds, edit the flags and options in $(PACKAGE)-$(DISTRO).spec first rpmbuild --rebuild $(RPM_ROOT)/*.src.rpm mock-nodeps: -rm -rf $(RPM_ROOT)/mock mock --root=fedora-12-x86_64 --resultdir=$(RPM_ROOT)/mock --rebuild $(RPM_ROOT)/*.src.rpm mock: srpm mock-nodeps scratch: hg commit -m "DO-NOT-PUSH" make srpm hg rollback make mock-nodeps deb: echo To make create custom builds, edit the configure flags in debian/rules first dpkg-buildpackage -rfakeroot -us -uc global: clean-generic gtags -q global-html: global htags -sanhIT global-www: global-html rsync -avzxlSD --progress HTML/ root@clusterlabs.org:/var/lib/global/pacemaker changes: @printf "$(PACKAGE) ($(VERSION)-1) stable; urgency=medium\n" @printf " * Update source tarball to revision: `hg id`\n" @printf " * Statistics:\n" @printf " Changesets: `hg log -M --template "{desc|firstline|strip}\n" -r $(LAST_RELEASE):tip | wc -l`\n" @printf " Diff: " @hg diff -r $(LAST_RELEASE):tip | diffstat | tail -n 1 @printf "\n * Testing Notes:\n" @printf "\n + Test hardware:\n" @printf "\n + All testing was performed with STONITH enabled\n" @printf "\n + Pending bugs encountered during testing:\n" @printf "\n * Changes since $(LAST_RELEASE)\n" @hg log -M --template " + {desc|firstline|strip}\n" -r $(LAST_RELEASE):tip | grep -v -e Dev: -e Low: | sort -uf @printf "\n -- Andrew Beekhof `date +"%a, %d %b %Y %T %z"`\n" features: @printf "$(PACKAGE) ($(VERSION)-1) unstable; urgency=medium\n" @printf " * Update source tarball to revision: `hg id`\n" @printf " * Statistics:\n" @printf " Changesets: `hg out -M --template "{desc|firstline|strip}\n" ../$(STABLE_SERIES) | wc -l`\n" @printf " Diff: " @hg out -M -p ../$(STABLE_SERIES) | diffstat | tail -n 1 @printf "\n * Changes added since $(STABLE_SERIES)\n" @hg out -M --template " + {desc|firstline|strip}\n" ../$(STABLE_SERIES) | grep -v -e Dev: -e Low: | sort -uf @printf "\n -- Andrew Beekhof `date +"%a, %d %b %Y %T %z"`\n" rel-tags: tags find . -name TAGS -exec sed -i.sed 's:\(.*\)/\(.*\)/TAGS:\2/TAGS:g' \{\} \; diff --git a/configure.ac b/configure.ac index 774f41c621..d19690d61d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,1540 +1,1538 @@ dnl dnl autoconf for Pacemaker dnl dnl License: GNU General Public License (GPL) dnl =============================================== dnl Bootstrap dnl =============================================== AC_PREREQ(2.53) dnl Suggested structure: dnl information on the package dnl checks for programs dnl checks for libraries dnl checks for header files dnl checks for types dnl checks for structures dnl checks for compiler characteristics dnl checks for library functions dnl checks for system services AC_INIT(pacemaker, 1.1.1, pacemaker@oss.clusterlabs.org) CRM_DTD_VERSION="1.2" PKG_FEATURES="" HB_PKG=heartbeat AC_CONFIG_AUX_DIR(.) AC_CANONICAL_HOST dnl Where #defines go (e.g. `AC_CHECK_HEADERS' below) dnl dnl Internal header: include/config.h dnl - Contains ALL defines dnl - include/config.h.in is generated automatically by autoheader dnl - NOT to be included in any header files except lha_internal.h dnl (which is also not to be included in any other header files) dnl dnl External header: include/crm_config.h dnl - Contains a subset of defines checked here dnl - Manually edit include/crm_config.h.in to have configure include dnl new defines dnl - Should not include HAVE_* defines dnl - Safe to include anywhere AM_CONFIG_HEADER(include/config.h include/crm_config.h) ALL_LINGUAS="en fr" AC_ARG_WITH(version, [ --with-version=version Override package version (if you're a packager needing to pretend) ], [ PACKAGE_VERSION="$withval" ]) AC_ARG_WITH(pkg-name, [ --with-pkg-name=name Override package name (if you're a packager needing to pretend) ], [ PACKAGE_NAME="$withval" ]) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) AC_DEFINE_UNQUOTED(PACEMAKER_VERSION, "$PACKAGE_VERSION", Current pacemaker version) PACKAGE_SERIES=`echo $PACKAGE_VERSION | awk -F. '{ print $1"."$2 }'` AC_SUBST(PACKAGE_SERIES) dnl automake >= 1.11 offers --enable-silent-rules for suppressing the output from dnl normal compilation. When a failure occurs, it will then display the full dnl command line dnl Wrap in m4_ifdef to avoid breaking on older platforms m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) CC_IN_CONFIGURE=yes export CC_IN_CONFIGURE LDD=ldd dnl ======================================================================== dnl Compiler characteristics dnl ======================================================================== AC_PROG_CC dnl Can force other with environment variable "CC". AM_PROG_CC_C_O AC_PROG_CC_STDC AC_LIBTOOL_DLOPEN dnl Enable dlopen support... AC_LIBLTDL_CONVENIENCE dnl make libltdl a convenience lib AC_PROG_LIBTOOL AC_C_STRINGIZE AC_TYPE_SIZE_T AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_STRUCT_TIMEZONE dnl =============================================== dnl Helpers dnl =============================================== cc_supports_flag() { local CFLAGS="$@" AC_MSG_CHECKING(whether $CC supports "$@") AC_COMPILE_IFELSE([int main(){return 0;}] ,[RC=0; AC_MSG_RESULT(yes)],[RC=1; AC_MSG_RESULT(no)]) return $RC } extract_header_define() { AC_MSG_CHECKING(for $2 in $1) Cfile=/tmp/extract_define.$2.${$} printf "#include \n" > ${Cfile}.c printf "#include <%s>\n" $1 >> ${Cfile}.c printf "int main(int argc, char **argv) { printf(\"%%s\", %s); return 0; }\n" $2 >> ${Cfile}.c $CC $CFLAGS ${Cfile}.c -o ${Cfile} value=`${Cfile}` AC_MSG_RESULT($value) printf $value rm -f ${Cfile}.c ${Cfile} } dnl =============================================== dnl Configure Options dnl =============================================== dnl Some systems, like Solaris require a custom package name AC_ARG_WITH(pkgname, [ --with-pkgname=name name for pkg (typically for Solaris) ], [ PKGNAME="$withval" ], [ PKGNAME="LXHAhb" ], ) AC_SUBST(PKGNAME) AC_ARG_ENABLE([ansi], [ --enable-ansi force GCC to compile to ANSI/ANSI standard for older compilers. [default=yes]]) AC_ARG_ENABLE([fatal-warnings], [ --enable-fatal-warnings very pedantic and fatal warnings for gcc [default=yes]]) AC_ARG_ENABLE([pretty], [ --enable-pretty Pretty-print compiler output unless there is an error [default=no]]) AC_ARG_ENABLE([quiet], [ --enable-quiet Supress make output unless there is an error [default=no]]) AC_ARG_ENABLE([thread-safe], [ --enable-thread-safe Enable some client libraries to be thread safe. [default=no]]) AC_ARG_ENABLE([bundled-ltdl], [ --enable-bundled-ltdl Configure, build and install the standalone ltdl library bundled with ${PACKAGE} [default=no]]) LTDL_LIBS="" AC_ARG_WITH(ais, [ --with-ais Support the OpenAIS messaging and membership layer ], [ SUPPORT_AIS=$withval ], [ SUPPORT_AIS=try ], ) AC_ARG_WITH(heartbeat, [ --with-heartbeat Support the Heartbeat messaging and membership layer ], [ SUPPORT_HEARTBEAT=$withval ], [ SUPPORT_HEARTBEAT=try ], ) AC_ARG_WITH(snmp, [ --with-snmp Support the SNMP protocol ], [ SUPPORT_SNMP=$withval ], [ SUPPORT_SNMP=try ], ) AC_ARG_WITH(esmtp, [ --with-esmtp Support the sending mail notifications with the esmtp library ], [ SUPPORT_ESMTP=$withval ], [ SUPPORT_ESMTP=try ], ) AISPREFIX="" AC_ARG_WITH(ais-prefix, [ --with-ais-prefix=DIR Prefix used when OpenAIS was installed [$prefix]], [ AISPREFIX=$withval ], [ AISPREFIX=$prefix ]) LCRSODIR="" AC_ARG_WITH(lcrso-dir, [ --with-lcrso-dir=DIR OpenAIS lcrso files. ], [ LCRSODIR="$withval" ]) INITDIR="" AC_ARG_WITH(initdir, [ --with-initdir=DIR directory for init (rc) scripts [${INITDIR}]], [ INITDIR="$withval" ]) PUBLICAN_BRAND="common" AC_ARG_WITH(brand, [ --with-brand=brand Brand to use for generated documentation [$PUBLICAN_BRAND]], [ PUBLICAN_BRAND="$withval" ]) AC_SUBST(PUBLICAN_BRAND) dnl =============================================== dnl General Processing dnl =============================================== AC_SUBST(HB_PKG) INIT_EXT="" echo Our Host OS: $host_os/$host AC_MSG_NOTICE(Sanitizing prefix: ${prefix}) case $prefix in NONE) prefix=/usr;; esac AC_MSG_NOTICE(Sanitizing exec_prefix: ${exec_prefix}) case $exec_prefix in dnl For consistency with Heartbeat, map NONE->$prefix NONE) exec_prefix=$prefix;; prefix) exec_prefix=$prefix;; esac AC_MSG_NOTICE(Sanitizing ais_prefix: ${AISPREFIX}) case $AISPREFIX in dnl For consistency with Heartbeat, map NONE->$prefix NONE) AISPREFIX=$prefix;; prefix) AISPREFIX=$prefix;; esac AC_MSG_NOTICE(Sanitizing INITDIR: ${INITDIR}) case $INITDIR in prefix) INITDIR=$prefix;; "") AC_MSG_CHECKING(which init (rc) directory to use) for initdir in /etc/init.d /etc/rc.d/init.d /sbin/init.d \ /usr/local/etc/rc.d /etc/rc.d do if test -d $initdir then INITDIR=$initdir break fi done AC_MSG_RESULT($INITDIR);; esac AC_SUBST(INITDIR) AC_MSG_NOTICE(Sanitizing libdir: ${libdir}) case $libdir in dnl For consistency with Heartbeat, map NONE->$prefix *prefix*|NONE) AC_MSG_CHECKING(which lib directory to use) for aDir in lib64 lib do trydir="${exec_prefix}/${aDir}" if test -d ${trydir} then libdir=${trydir} break fi done AC_MSG_RESULT($libdir); ;; esac dnl Expand autoconf variables so that we dont end up with '${prefix}' dnl in #defines and python scripts dnl NOTE: Autoconf deliberately leaves them unexpanded to allow dnl make exec_prefix=/foo install dnl No longer being able to do this seems like no great loss to me... eval prefix="`eval echo ${prefix}`" eval exec_prefix="`eval echo ${exec_prefix}`" eval bindir="`eval echo ${bindir}`" eval sbindir="`eval echo ${sbindir}`" eval libexecdir="`eval echo ${libexecdir}`" eval datadir="`eval echo ${datadir}`" eval sysconfdir="`eval echo ${sysconfdir}`" eval sharedstatedir="`eval echo ${sharedstatedir}`" eval localstatedir="`eval echo ${localstatedir}`" eval libdir="`eval echo ${libdir}`" eval includedir="`eval echo ${includedir}`" eval oldincludedir="`eval echo ${oldincludedir}`" eval infodir="`eval echo ${infodir}`" eval mandir="`eval echo ${mandir}`" dnl Home-grown variables eval INITDIR="${INITDIR}" eval docdir="`eval echo ${docdir}`" if test x"${docdir}" = x""; then docdir=${datadir}/doc/${PACKAGE}-${VERSION} #docdir=${datadir}/doc/packages/${PACKAGE} fi AC_SUBST(docdir) for j in prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir \ sharedstatedir localstatedir libdir includedir oldincludedir infodir \ mandir INITDIR docdir do dirname=`eval echo '${'${j}'}'` if test ! -d "$dirname" then AC_MSG_WARN([$j directory ($dirname) does not exist!]) fi done dnl This OS-based decision-making is poor autotools practice; dnl feature-based mechanisms are strongly preferred. dnl dnl So keep this section to a bare minimum; regard as a "necessary evil". case "$host_os" in *bsd*) LIBS="-L/usr/local/lib" CPPFLAGS="$CPPFLAGS -I/usr/local/include" INIT_EXT=".sh" ;; *solaris*) ;; *linux*) AC_DEFINE_UNQUOTED(ON_LINUX, 1, Compiling for Linux platform) CFLAGS="$CFLAGS -I${prefix}/include" ;; darwin*) AC_DEFINE_UNQUOTED(ON_DARWIN, 1, Compiling for Darwin platform) LIBS="$LIBS -L${prefix}/lib" CFLAGS="$CFLAGS -I${prefix}/include" ;; esac dnl Eventually remove this CFLAGS="$CFLAGS -I${prefix}/include/heartbeat" AC_SUBST(INIT_EXT) AC_DEFINE_UNQUOTED(HA_LOG_FACILITY, LOG_DAEMON, Default logging facility) AC_MSG_NOTICE(Host CPU: $host_cpu) case "$host_cpu" in ppc64|powerpc64) case $CFLAGS in *powerpc64*) ;; *) if test "$GCC" = yes; then CFLAGS="$CFLAGS -m64" fi ;; esac esac AC_MSG_CHECKING(which format is needed to print uint64_t) ac_save_CFLAGS=$CFLAGS CFLAGS="-Wall -Werror" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [ #include #include #include ], [ int max = 512; uint64_t bignum = 42; char *buffer = malloc(max); const char *random = "random"; snprintf(buffer, max-1, "", bignum, random); fprintf(stderr, "Result: %s\n", buffer); ] )], [U64T="%lu"], [U64T="%llu"] ) CFLAGS=$ac_save_CFLAGS AC_MSG_RESULT($U64T) AC_DEFINE_UNQUOTED(U64T, "$U64T", Correct printf format for logging uint64_t) AC_CHECK_HEADERS(hb_config.h) AC_CHECK_HEADERS(glue_config.h) GLUE_HEADER=none if test "$ac_cv_header_glue_config_h" = "yes"; then GLUE_HEADER=glue_config.h elif test "$ac_cv_header_hb_config_h" = "yes"; then GLUE_HEADER=hb_config.h else AC_MSG_FAILURE(Core development headers were not found) fi dnl Variables needed for substitution CRM_DTD_DIRECTORY="${datadir}/pacemaker" AC_DEFINE_UNQUOTED(CRM_DTD_DIRECTORY,"$CRM_DTD_DIRECTORY", Location for the Pacemaker Relax-NG Schema) AC_SUBST(CRM_DTD_DIRECTORY) AC_DEFINE_UNQUOTED(CRM_DTD_VERSION,"$CRM_DTD_VERSION", Current version of the Pacemaker Relax-NG Schema) AC_SUBST(CRM_DTD_VERSION) CRM_DAEMON_USER=`extract_header_define $GLUE_HEADER HA_CCMUSER` AC_DEFINE_UNQUOTED(CRM_DAEMON_USER,"$CRM_DAEMON_USER", User to run Pacemaker daemons as) AC_SUBST(CRM_DAEMON_USER) CRM_DAEMON_GROUP=`extract_header_define $GLUE_HEADER HA_APIGROUP` AC_DEFINE_UNQUOTED(CRM_DAEMON_GROUP,"$CRM_DAEMON_GROUP", Group to run Pacemaker daemons as) AC_SUBST(CRM_DAEMON_GROUP) CRM_STATE_DIR=${localstatedir}/run/crm AC_DEFINE_UNQUOTED(CRM_STATE_DIR,"$CRM_STATE_DIR", Where to keep state files and sockets) AC_SUBST(CRM_STATE_DIR) PE_STATE_DIR="${localstatedir}/lib/pengine" AC_DEFINE_UNQUOTED(PE_STATE_DIR,"$PE_STATE_DIR", Where to keep PEngine outputs) AC_SUBST(PE_STATE_DIR) dnl Eventually move out of the heartbeat dir tree and create compatability code CRM_CONFIG_DIR="${localstatedir}/lib/heartbeat/crm" AC_DEFINE_UNQUOTED(CRM_CONFIG_DIR,"$CRM_CONFIG_DIR", Where to keep CIB configuration files) AC_SUBST(CRM_CONFIG_DIR) dnl Eventually move out of the heartbeat dir tree and create compatability code dnl CRM_DAEMON_DIR=$libdir/pacemaker CRM_DAEMON_DIR=`extract_header_define $GLUE_HEADER HA_LIBHBDIR` AC_DEFINE_UNQUOTED(CRM_DAEMON_DIR,"$CRM_DAEMON_DIR", Location for Pacemaker daemons) AC_SUBST(CRM_DAEMON_DIR) dnl Create symlinks to here from CRM_DAEMON_DIR when needed HB_DAEMON_DIR=`extract_header_define $GLUE_HEADER HA_LIBHBDIR` AC_DEFINE_UNQUOTED(HB_DAEMON_DIR,"$HB_DAEMON_DIR", Location for Heartbeat expects Pacemaker daemons to be in) AC_SUBST(HB_DAEMON_DIR) dnl Needed so that the AIS plugin can clear out the directory as Heartbeat does HA_STATE_DIR=`extract_header_define $GLUE_HEADER HA_VARRUNDIR` AC_DEFINE_UNQUOTED(HA_STATE_DIR,"$HA_STATE_DIR", Where Heartbeat keeps state files and sockets) AC_SUBST(HA_STATE_DIR) dnl Needed for the location of hostcache in CTS.py HA_VARLIBHBDIR=`extract_header_define $GLUE_HEADER HA_VARLIBHBDIR` AC_SUBST(HA_VARLIBHBDIR) AC_DEFINE_UNQUOTED(UUID_FILE,"$localstatedir/lib/heartbeat/hb_uuid", Location of Heartbeat's UUID file) OCF_ROOT_DIR=`extract_header_define $GLUE_HEADER OCF_ROOT_DIR` if test "X$OCF_ROOT_DIR" = X; then AC_MSG_ERROR(Could not locate OCF directory) fi AC_SUBST(OCF_ROOT_DIR) OCF_RA_DIR=`extract_header_define $GLUE_HEADER OCF_RA_DIR` AC_DEFINE_UNQUOTED(OCF_RA_DIR,"$OCF_RA_DIR", Location for OCF RAs) AC_SUBST(OCF_RA_DIR) dnl Extract this value from glue_config.h once we no longer support anything else STONITH_PLUGIN_DIR="$libdir/stonith/plugins/stonith/" AC_DEFINE_UNQUOTED(STONITH_PLUGIN_DIR,"$STONITH_PLUGIN_DIR", Location for Stonith plugins) AC_SUBST(STONITH_PLUGIN_DIR) RH_STONITH_DIR="$sbindir" AC_DEFINE_UNQUOTED(RH_STONITH_DIR,"$RH_STONITH_DIR", Location for Red Hat Stonith agents) RH_STONITH_PREFIX="fence_" AC_DEFINE_UNQUOTED(RH_STONITH_PREFIX,"$RH_STONITH_PREFIX", Prefix for Red Hat Stonith agents) AC_PATH_PROGS(HG, hg false) AC_MSG_CHECKING(build version) BUILD_VERSION=unknown if test -f $srcdir/.hg_archival.txt; then BUILD_VERSION=`cat $srcdir/.hg_archival.txt | awk '/node:/ { print $2 }'` elif test -x $HG -a -d .hg; then BUILD_VERSION=`$HG id -itb` if test $? != 0; then BUILD_VERSION=unknown fi fi AC_DEFINE_UNQUOTED(BUILD_VERSION, "$BUILD_VERSION", Build version) AC_MSG_RESULT($BUILD_VERSION) AC_SUBST(BUILD_VERSION) dnl =============================================== dnl Program Paths dnl =============================================== PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin" export PATH dnl Replacing AC_PROG_LIBTOOL with AC_CHECK_PROG because LIBTOOL dnl was NOT being expanded all the time thus causing things to fail. AC_CHECK_PROGS(LIBTOOL, glibtool libtool libtool15 libtool13) AM_PATH_PYTHON AC_CHECK_PROGS(MAKE, gmake make) AC_PATH_PROGS(HTML2TXT, lynx w3m) AC_PATH_PROGS(HELP2MAN, help2man) AC_PATH_PROGS(POD2MAN, pod2man, pod2man) AC_PATH_PROGS(ASCIIDOC, asciidoc) AC_PATH_PROGS(PUBLICAN, publican) AC_PATH_PROGS(XSLTPROC, xsltproc) AC_PATH_PROGS(FOP, fop) AC_PATH_PROGS(SSH, ssh, /usr/bin/ssh) AC_PATH_PROGS(SCP, scp, /usr/bin/scp) AC_PATH_PROGS(HG, hg, /bin/false) AC_PATH_PROGS(TAR, tar) AC_PATH_PROGS(MD5, md5) AC_PATH_PROGS(TEST, test) AC_PATH_PROGS(PKGCONFIG, pkg-config) AC_PATH_PROGS(XML2CONFIG, xml2-config) AC_PATH_PROGS(VALGRIND_BIN, valgrind, /usr/bin/valgrind) AC_DEFINE_UNQUOTED(VALGRIND_BIN, "$VALGRIND_BIN", Valgrind command) if test x"${LIBTOOL}" = x""; then AC_MSG_ERROR(You need (g)libtool installed in order to build ${PACKAGE}) fi if test x"${MAKE}" = x""; then AC_MSG_ERROR(You need (g)make installed in order to build ${PACKAGE}) fi AM_CONDITIONAL(BUILD_HELP, test x"${HELP2MAN}" != x"") if test x"${HELP2MAN}" != x""; then PKG_FEATURES="$PKG_FEATURES manpages" fi MANPAGE_XSLT="" if test x"${XSLTPROC}" != x""; then AC_MSG_CHECKING(docbook to manpage transform) XSLT=`find ${datadir} -name docbook.xsl` for xsl in $XSLT; do dname=`dirname $xsl` bname=`basename $dname` if test "$bname" = "manpages"; then MANPAGE_XSLT="$xsl" break fi done fi AC_MSG_RESULT($MANPAGE_XSLT) AC_SUBST(MANPAGE_XSLT) AM_CONDITIONAL(BUILD_XML_HELP, test x"${MANPAGE_XSLT}" != x"") if test x"${MANPAGE_XSLT}" != x""; then PKG_FEATURES="$PKG_FEATURES docbook-manpages" fi AM_CONDITIONAL(BUILD_ASCIIDOC, test x"${ASCIIDOC}" != x"") if test x"${ASCIIDOC}" != x""; then PKG_FEATURES="$PKG_FEATURES asciidoc" fi AM_CONDITIONAL(BUILD_DOCBOOK, test ${PUBLICAN} != x"") if test ${PUBLICAN} != x""; then PKG_FEATURES="$PKG_FEATURES publican" fi dnl =============================================== dnl Libraries dnl =============================================== AC_CHECK_LIB(socket, socket) dnl -lsocket AC_CHECK_LIB(c, dlopen) dnl if dlopen is in libc... AC_CHECK_LIB(dl, dlopen) dnl -ldl (for Linux) AC_CHECK_LIB(rt, sched_getscheduler) dnl -lrt (for Tru64) AC_CHECK_LIB(gnugetopt, getopt_long) dnl -lgnugetopt ( if available ) AC_CHECK_LIB(pam, pam_start) dnl -lpam (if available) AC_CHECK_LIB(uuid, uuid_parse) dnl e2fsprogs AC_CHECK_LIB(uuid, uuid_create) dnl ossp if test x"${PKGCONFIG}" = x""; then AC_MSG_ERROR(You need pkgconfig installed in order to build ${PACKAGE}) fi dnl dnl On many systems libcrypto is needed when linking against libsnmp. dnl Check to see if it exists, and if so use it. dnl AC_CHECK_LIB(crypto, CRYPTO_free, CRYPTOLIB="-lcrypto",) AC_SUBST(CRYPTOLIB) if test "x${enable_thread_safe}" = "xyes"; then GPKGNAME="gthread-2.0" else GPKGNAME="glib-2.0" fi if $PKGCONFIG --exists $GPKGNAME then GLIBCONFIG="$PKGCONFIG $GPKGNAME" else set -x echo PKG_CONFIG_PATH=$PKG_CONFIG_PATH $PKGCONFIG --exists $GPKGNAME; echo $? $PKGCONFIG --cflags $GPKGNAME; echo $? $PKGCONFIG $GPKGNAME; echo $? set +x AC_MSG_ERROR(You need glib2-devel installed in order to build ${PACKAGE}) fi AC_MSG_RESULT(using $GLIBCONFIG) # # Where is dlopen? # if test "$ac_cv_lib_c_dlopen" = yes; then LIBADD_DL="" elif test "$ac_cv_lib_dl_dlopen" = yes; then LIBADD_DL=-ldl else LIBADD_DL=${lt_cv_dlopen_libs} fi dnl dnl Check for location of gettext dnl dnl On at least Solaris 2.x, where it is in libc, specifying lintl causes dnl grief. Ensure minimal result, not the sum of all possibilities. dnl And do libc first. dnl Known examples: dnl c: Linux, Solaris 2.6+ dnl intl: BSD, AIX AC_CHECK_LIB(c, gettext) if test x$ac_cv_lib_c_gettext != xyes; then AC_CHECK_LIB(intl, gettext) fi if test x$ac_cv_lib_c_gettext != xyes -a x$ac_cv_lib_intl_gettext != xyes; then AC_MSG_ERROR(You need gettext installed in order to build ${PACKAGE}) fi if test "X$GLIBCONFIG" != X; then AC_MSG_CHECKING(for special glib includes: ) GLIBHEAD=`$GLIBCONFIG --cflags` AC_MSG_RESULT($GLIBHEAD) CPPFLAGS="$CPPFLAGS $GLIBHEAD" AC_MSG_CHECKING(for glib library flags) GLIBLIB=`$GLIBCONFIG --libs` AC_MSG_RESULT($GLIBLIB) LIBS="$LIBS $GLIBLIB" fi dnl ======================================================================== dnl Headers dnl ======================================================================== AC_HEADER_STDC AC_CHECK_HEADERS(arpa/inet.h) AC_CHECK_HEADERS(asm/types.h) AC_CHECK_HEADERS(assert.h) AC_CHECK_HEADERS(auth-client.h) AC_CHECK_HEADERS(ctype.h) AC_CHECK_HEADERS(dirent.h) AC_CHECK_HEADERS(errno.h) AC_CHECK_HEADERS(fcntl.h) AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(glib.h) AC_CHECK_HEADERS(grp.h) AC_CHECK_HEADERS(limits.h) AC_CHECK_HEADERS(linux/errqueue.h) AC_CHECK_HEADERS(malloc.h) AC_CHECK_HEADERS(netdb.h) AC_CHECK_HEADERS(netinet/in.h) AC_CHECK_HEADERS(netinet/ip.h) AC_CHECK_HEADERS(pam/pam_appl.h) AC_CHECK_HEADERS(pthread.h) AC_CHECK_HEADERS(pwd.h) AC_CHECK_HEADERS(security/pam_appl.h) AC_CHECK_HEADERS(sgtty.h) AC_CHECK_HEADERS(signal.h) AC_CHECK_HEADERS(stdarg.h) AC_CHECK_HEADERS(stddef.h) AC_CHECK_HEADERS(stdio.h) AC_CHECK_HEADERS(stdlib.h) AC_CHECK_HEADERS(string.h) AC_CHECK_HEADERS(strings.h) AC_CHECK_HEADERS(sys/dir.h) AC_CHECK_HEADERS(sys/ioctl.h) AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(sys/poll.h) AC_CHECK_HEADERS(sys/resource.h) AC_CHECK_HEADERS(sys/select.h) AC_CHECK_HEADERS(sys/socket.h) AC_CHECK_HEADERS(sys/sockio.h) AC_CHECK_HEADERS(sys/stat.h) AC_CHECK_HEADERS(sys/time.h) AC_CHECK_HEADERS(sys/timeb.h) AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/uio.h) AC_CHECK_HEADERS(sys/un.h) AC_CHECK_HEADERS(sys/utsname.h) AC_CHECK_HEADERS(sys/wait.h) AC_CHECK_HEADERS(time.h) AC_CHECK_HEADERS(unistd.h) AC_CHECK_HEADERS(winsock.h) dnl These headers need prerequisits before the tests will pass dnl AC_CHECK_HEADERS(net/if.h) dnl AC_CHECK_HEADERS(netinet/icmp6.h) dnl AC_CHECK_HEADERS(netinet/ip6.h) dnl AC_CHECK_HEADERS(netinet/ip_icmp.h) AC_MSG_CHECKING(for special libxml2 includes) if test "x$XML2CONFIG" = "x"; then AC_MSG_ERROR(libxml2 config not found) else XML2HEAD="`$XML2CONFIG --cflags`" AC_MSG_RESULT($XML2HEAD) AC_CHECK_LIB(xml2, xmlReadMemory) AC_CHECK_LIB(xslt, xsltApplyStylesheet) fi CPPFLAGS="$CPPFLAGS $XML2HEAD" AC_CHECK_HEADERS(libxml/xpath.h) AC_CHECK_HEADERS(libxslt/xslt.h) if test "$ac_cv_header_libxml_xpath_h" != "yes"; then AC_MSG_ERROR(The libxml developement headers were not found) fi if test "$ac_cv_header_libxslt_xslt_h" != "yes"; then AC_MSG_ERROR(The libxslt developement headers were not found) fi dnl ======================================================================== dnl Structures dnl ======================================================================== AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[[#include ]]) dnl ======================================================================== dnl Functions dnl ======================================================================== AC_CHECK_FUNCS(g_log_set_default_handler) AC_CHECK_FUNCS(getopt, AC_DEFINE(HAVE_DECL_GETOPT, 1, [Have getopt function])) dnl ======================================================================== dnl ltdl dnl ======================================================================== AC_CHECK_LIB(ltdl, lt_dlopen, [LTDL_foo=1]) if test "x${enable_bundled_ltdl}" = "xyes"; then if test $ac_cv_lib_ltdl_lt_dlopen = yes; then AC_MSG_NOTICE([Disabling usage of installed ltdl]) fi ac_cv_lib_ltdl_lt_dlopen=no fi LIBLTDL_DIR="" if test $ac_cv_lib_ltdl_lt_dlopen != yes ; then AC_MSG_NOTICE([Installing local ltdl]) LIBLTDL_DIR=libltdl ( cd $srcdir ; $TAR -xvf libltdl.tar ) if test "$?" -ne 0; then AC_MSG_ERROR([$TAR of libltdl.tar in $srcdir failed]) fi AC_CONFIG_SUBDIRS(libltdl) else LIBS="$LIBS -lltdl" AC_MSG_NOTICE([Using installed ltdl]) INCLTDL="" LIBLTDL="" fi AC_SUBST(INCLTDL) AC_SUBST(LIBLTDL) AC_SUBST(LIBLTDL_DIR) dnl ======================================================================== dnl bzip2 dnl ======================================================================== AC_CHECK_HEADERS(bzlib.h) AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffCompress) if test x$ac_cv_lib_bz2_BZ2_bzBuffToBuffCompress != xyes ; then AC_MSG_ERROR(BZ2 libraries not found) fi if test x$ac_cv_header_bzlib_h != xyes; then AC_MSG_ERROR(BZ2 Development headers not found) fi dnl ======================================================================== dnl ncurses dnl ======================================================================== dnl dnl A few OSes (e.g. Linux) deliver a default "ncurses" alongside "curses". dnl Many non-Linux deliver "curses"; sites may add "ncurses". dnl dnl However, the source-code recommendation for both is to #include "curses.h" dnl (i.e. "ncurses" still wants the include to be simple, no-'n', "curses.h"). dnl dnl ncurse takes precedence. dnl AC_CHECK_HEADERS(curses.h) AC_CHECK_HEADERS(curses/curses.h) AC_CHECK_HEADERS(ncurses.h) AC_CHECK_HEADERS(ncurses/ncurses.h) dnl Although n-library is preferred, only look for it if the n-header was found. CURSESLIBS='' if test "$ac_cv_header_ncurses_h" = "yes"; then AC_CHECK_LIB(ncurses, printw, [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)] ) fi if test "$ac_cv_header_ncurses_ncurses_h" = "yes"; then AC_CHECK_LIB(ncurses, printw, [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)] ) fi dnl Only look for non-n-library if there was no n-library. if test X"$CURSESLIBS" = X"" -a "$ac_cv_header_curses_h" = "yes"; then AC_CHECK_LIB(curses, printw, [CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)] ) fi dnl Only look for non-n-library if there was no n-library. if test X"$CURSESLIBS" = X"" -a "$ac_cv_header_curses_curses_h" = "yes"; then AC_CHECK_LIB(curses, printw, [CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)] ) fi if test "x$CURSESLIBS" != "x"; then PKG_FEATURES="$PKG_FEATURES ncurses" fi dnl Check for printw() prototype compatibility if test X"$CURSESLIBS" != X"" && cc_supports_flag -Wcast-qual && cc_supports_flag -Werror; then AC_MSG_CHECKING(whether printw() requires argument of "const char *") ac_save_LIBS=$LIBS LIBS="$CURSESLIBS $LIBS" ac_save_CFLAGS=$CFLAGS CFLAGS="-Wcast-qual -Werror" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [ #if defined(HAVE_CURSES_H) # include #elif defined(HAVE_NCURSES_H) # include #endif ], [printw((const char *)"Test");] )], [ac_cv_compatible_printw=yes], [ac_cv_compatible_printw=no] ) LIBS=$ac_save_LIBS CFLAGS=$ac_save_CFLAGS AC_MSG_RESULT([$ac_cv_compatible_printw]) if test "$ac_cv_compatible_printw" = no; then AC_MSG_WARN([The printw() function of your ncurses or curses library is old, we will disable usage of the library. If you want to use this library anyway, please update to newer version of the library, ncurses 5.4 or later is recommended. You can get the library from http://www.gnu.org/software/ncurses/.]) AC_MSG_NOTICE([Disabling curses]) AC_DEFINE(HAVE_INCOMPATIBLE_PRINTW, 1, [Do we have incompatible printw() in curses library?]) fi fi AC_SUBST(CURSESLIBS) dnl ======================================================================== dnl Cluster infrastructure - Heartbeat dnl ======================================================================== dnl On Debian, AC_CHECK_LIBS fail if a library has any unresolved symbols dnl So check for all the depenancies (so they're added to LIBS) before checking for -lplumb AC_CHECK_LIB(pils, PILLoadPlugin) AC_CHECK_LIB(plumb, G_main_add_IPC_Channel) if test x"$ac_cv_lib_plumb_G_main_add_IPC_Channel" != x"yes"; then AC_MSG_FAILURE(Core Heartbeat utility libraries not found: $ac_cv_lib_plumb_G_main_add_IPC_Channel) fi dnl Compatability checks AC_CHECK_FUNCS(msgfromIPC_timeout) AC_CHECK_MEMBERS([struct lrm_ops.fail_rsc],,,[[#include ]]) dnl ======================================================================== dnl Cluster stack - Heartbeat dnl ======================================================================== case $SUPPORT_HEARTBEAT in 1|yes|true) AC_CHECK_LIB(hbclient, ll_cluster_new, [SUPPORT_HEARTBEAT=1], [AC_MSG_FAILURE(Unable to support Heartbeat: client libraries not found)]);; try) AC_CHECK_LIB(hbclient, ll_cluster_new, [SUPPORT_HEARTBEAT=1], [SUPPORT_HEARTBEAT=0]);; *) SUPPORT_HEARTBEAT=0;; esac AM_CONDITIONAL(BUILD_HEARTBEAT_SUPPORT, test $SUPPORT_HEARTBEAT = 1) AC_DEFINE_UNQUOTED(SUPPORT_HEARTBEAT, $SUPPORT_HEARTBEAT, Support the Heartbeat messaging and membership layer) dnl ======================================================================== dnl Cluster stack - OpenAIS dnl ======================================================================== AISLIB="" dnl Normalize the values case $SUPPORT_AIS in 1|yes|true) missingisfatal=1;; try) missingisfatal=0;; *) SUPPORT_AIS=no;; esac AC_MSG_CHECKING(for native AIS) AISMSGLIB="" AIS_VERSION="none" COROSYNC_PKG="$PKGCONFIG libcoroipcc" if test $SUPPORT_AIS = no; then AC_MSG_RESULT(no... not requested.) else AC_MSG_RESULT($SUPPORT_AIS, with '$AISPREFIX') AC_CHECK_HEADERS(openais/saAis.h) AC_CHECK_HEADERS(corosync/coroipcc.h) $COROSYNC_PKG --exists if test $? = 0; then AIS_VERSION="corosync" elif test "$ac_cv_header_openais_saAis_h" = "yes"; then AIS_VERSION="whitetank" else aisreason="Whitetank headers not found" fi fi if test $AIS_VERSION != "none"; then AC_MSG_CHECKING(for OpenAIS branch) AC_MSG_RESULT($AIS_VERSION) fi if test $AIS_VERSION = "corosync"; then if test "$ac_cv_header_corosync_coroipcc_h" != "yes"; then AIS_VERSION="none" aisreason="Corosync headers not found" fi saveLIBS="$LIBS" LIBS="$LIBS `$COROSYNC_PKG --libs-only-L`" AC_CHECK_LIB(coroipcc, coroipcc_msg_send_reply_receive, []) LIBS="$saveLIBS" if test $ac_cv_lib_coroipcc_coroipcc_msg_send_reply_receive != yes; then AC_MSG_RESULT(Cannot locate AIS messaging library) aisreason="requred Corosync libraries not found" AIS_VERSION="none" fi fi dnl continue? if test $AIS_VERSION = "whitetank"; then dnl Find it in lib, lib64, or wherever it wants to live... AC_MSG_CHECKING(location of OpenAIS libraries) dnl CoroSync location alib=`ls ${AISPREFIX}/*/libcpg.so | head -n 1` if test -z "$alib"; then dnl Whitetank location alib=`ls ${AISPREFIX}/*/*/libcpg.so | head -n 1` fi AISLIB=`dirname $alib` AC_MSG_RESULT($AISLIB) if test "x$AISLIB" = "x"; then AC_MSG_WARN(Use --with-ais-prefix to specify the prefix OpenAIS was installed with) aisreason="library directory not found" AIS_VERSION="none" elif test ! -d "$AISLIB"; then AC_MSG_WARN(Use --with-ais-prefix to specify the prefix OpenAIS was installed with) aisreason="specified library directory does not exist" AIS_VERSION="none" fi fi dnl continue? if test $AIS_VERSION = "whitetank"; then AC_MSG_CHECKING(location of OpenAIS plugins) if test -z "$LCRSODIR"; then LCRSODIR="$libexecdir/lcrso" alib=`ls ${AISPREFIX}/*/lcrso/objdb.lcrso | head -n 1` LCRSODIR=`dirname $alib` fi AC_MSG_RESULT($LCRSODIR) if test "x$LCRSODIR" = "x"; then AC_MSG_RESULT(Invalid. Please specify the correct location with --with-lcrso-dir) aisreason="plugin directory not found" AIS_VERSION="none" elif test ! -d "$LCRSODIR"; then AC_MSG_RESULT(Invalid. Please specify the correct location with --with-lcrso-dir) aisreason="specified plugin directory does not exist" AIS_VERSION="none" fi fi dnl continue? if test $AIS_VERSION = "whitetank"; then dnl Don't add the messaging library to LIBS since most daemons don't need/use it saveLIBS="$LIBS" LIBS="$LIBS -L${AISLIB} -R${AISLIB}" AC_CHECK_LIB(SaMsg, saSendReceiveReply, []) AC_CHECK_LIB(SaMsg, openais_msg_send_reply_receive, []) if test $ac_cv_lib_SaMsg_openais_msg_send_reply_receive = yes; then : OpenAIS elif test $ac_cv_lib_SaMsg_saSendReceiveReply = yes; then : OpenAIS AC_DEFINE_UNQUOTED(TRADITIONAL_AIS_IPC, 1, "Use the 'old' AIS IPC interface") else AC_MSG_RESULT(Cannot locate AIS messaging library) aisreason="requred libraries not found" AIS_VERSION="none" fi LIBS="$saveLIBS" fi SUPPORT_AIS=1 case $AIS_VERSION in corosync) AC_DEFINE_UNQUOTED(AIS_COROSYNC, 1, "AIS target is the corosync series") LCRSODIR=`$PKGCONFIG corosync --variable=lcrsodir` CFLAGS="$CFLAGS `$COROSYNC_PKG --cflags`" AISMSGLIB=`$COROSYNC_PKG --libs` ;; whitetank) AC_DEFINE_UNQUOTED(AIS_WHITETANK, 1, "AIS target is the whitetank series") CFLAGS="$CFLAGS -I$AISPREFIX/include/openais" AISMSGLIB="-L${AISLIB} -R${AISLIB} -lSaMsg" ;; none) SUPPORT_AIS=0 if test "x$aisreason" != x; then if test $missingisfatal = 0; then AC_MSG_WARN(Unable to support OpenAIS: $aisreason) else AC_MSG_FAILURE(Unable to support OpenAIS: $aisreason) fi fi ;; *) AC_MSG_FAILURE(Unknown OpenAIS branch: $AIS_VERSION);; esac AC_DEFINE_UNQUOTED(SUPPORT_AIS, $SUPPORT_AIS, Support the OpenAIS messaging and membership layer) AM_CONDITIONAL(BUILD_AIS_SUPPORT, test $SUPPORT_AIS = 1) dnl dnl Cluster stack - Sanity dnl STACKS="" CLUSTERLIBS="" if test $SUPPORT_HEARTBEAT = 1; then STACKS="$STACKS heartbeat" CLUSTERLIBS="$CLUSTERLIBS -lhbclient -lccmclient" fi if test $SUPPORT_AIS = 1; then STACKS="$STACKS $AIS_VERSION" CLUSTERLIBS="$CLUSTERLIBS ${AISMSGLIB}" else AISPREFIX="" LCRSODIR="$libdir" fi PKG_FEATURES="$PKG_FEATURES$STACKS" AC_MSG_CHECKING(for supported stacks) if test x"$STACKS" = x; then AC_MSG_FAILURE(You must choose at least one cluster stack to support) fi AC_MSG_RESULT($STACKS) AC_SUBST(CLUSTERLIBS) AC_SUBST(LCRSODIR) dnl ======================================================================== dnl SNMP dnl ======================================================================== case $SUPPORT_SNMP in 1|yes|true) missingisfatal=1;; try) missingisfatal=0;; *) SUPPORT_SNMP=no;; esac SNMPLIBS="" AC_MSG_CHECKING(for snmp support) if test $SUPPORT_SNMP = no; then AC_MSG_RESULT(no... not requested.) SUPPORT_SNMP=0 else SNMPCONFIG="" AC_MSG_RESULT($SUPPORT_SNMP) AC_CHECK_HEADERS(net-snmp/net-snmp-config.h) if test "x${ac_cv_header_net_snmp_net_snmp_config_h}" != "xyes"; then SUPPORT_SNMP="no" fi if test $SUPPORT_SNMP != no; then AC_PATH_PROGS(SNMPCONFIG, net-snmp-config) if test "X${SNMPCONFIG}" = "X"; then AC_MSG_RESULT(You need the net_snmp development package to continue.) SUPPORT_SNMP=no fi fi if test $SUPPORT_SNMP != no; then AC_MSG_CHECKING(for special snmp libraries) SNMPLIBS=`$SNMPCONFIG --agent-libs` AC_MSG_RESULT($SNMPLIBS) fi if test $SUPPORT_SNMP != no; then savedLibs=$LIBS LIBS="$LIBS $SNMPLIBS" AC_CHECK_FUNCS(netsnmp_transport_open_client) if test $ac_cv_func_netsnmp_transport_open_client != yes; then AC_CHECK_FUNCS(netsnmp_tdomain_transport) if test $ac_cv_func_netsnmp_tdomain_transport != yes; then SUPPORT_SNMP=no else AC_DEFINE_UNQUOTED(NETSNMPV53, 1, [Use the older 5.3 version of the net-snmp API]) fi fi LIBS=$savedLibs fi if test $SUPPORT_SNMP = no; then SNMPLIBS="" SUPPORT_SNMP=0 if test $missingisfatal = 0; then AC_MSG_WARN(Unable to support SNMP) else AC_MSG_FAILURE(Unable to support SNMP) fi else SUPPORT_SNMP=1 fi fi if test $SUPPORT_SNMP = 1; then PKG_FEATURES="$PKG_FEATURES snmp" fi AC_SUBST(SNMPLIBS) AM_CONDITIONAL(ENABLE_SNMP, test "$SUPPORT_SNMP" = "1") AC_DEFINE_UNQUOTED(ENABLE_SNMP, $SUPPORT_SNMP, Build in support for sending SNMP traps) dnl ======================================================================== dnl ESMTP dnl ======================================================================== case $SUPPORT_ESMTP in 1|yes|true) missingisfatal=1;; try) missingisfatal=0;; *) SUPPORT_ESMTP=no;; esac ESMTPLIB="" AC_MSG_CHECKING(for esmtp support) if test $SUPPORT_ESMTP = no; then AC_MSG_RESULT(no... not requested.) SUPPORT_ESMTP=0 else ESMTPCONFIG="" AC_MSG_RESULT($SUPPORT_ESMTP) AC_CHECK_HEADERS(libesmtp.h) if test "x${ac_cv_header_libesmtp_h}" != "xyes"; then ENABLE_ESMTP="no" fi if test $SUPPORT_ESMTP != no; then AC_PATH_PROGS(ESMTPCONFIG, libesmtp-config) if test "X${ESMTPCONFIG}" = "X"; then AC_MSG_RESULT(You need the libesmtp development package to continue.) SUPPORT_ESMTP=no fi fi if test $SUPPORT_ESMTP != no; then AC_MSG_CHECKING(for special esmtp libraries) ESMTPLIBS=`$ESMTPCONFIG --libs | tr '\n' ' '` AC_MSG_RESULT($ESMTPLIBS) fi if test $SUPPORT_ESMTP = no; then SUPPORT_ESMTP=0 if test $missingisfatal = 0; then AC_MSG_WARN(Unable to support ESMTP) else AC_MSG_FAILURE(Unable to support ESMTP) fi else SUPPORT_ESMTP=1 fi fi if test $SUPPORT_ESMTP = 1; then PKG_FEATURES="$PKG_FEATURES libesmtp" fi AC_SUBST(ESMTPLIBS) AM_CONDITIONAL(ENABLE_ESMTP, test "$SUPPORT_ESMTP" = "1") AC_DEFINE_UNQUOTED(ENABLE_ESMTP, $SUPPORT_ESMTP, Build in support for sending mail notifications with ESMTP) dnl ======================================================================== dnl GnuTLS dnl ======================================================================== AC_CHECK_HEADERS(gnutls/gnutls.h) AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h) dnl GNUTLS library: Attempt to determine by 'libgnutls-config' program. dnl If no 'libgnutls-config', try traditional autoconf means. AC_PATH_PROGS(LIBGNUTLS_CONFIG, libgnutls-config) if test -n "$LIBGNUTLS_CONFIG"; then AC_MSG_CHECKING(for gnutls header flags) GNUTLSHEAD="`$LIBGNUTLS_CONFIG --cflags`"; AC_MSG_RESULT($GNUTLSHEAD) AC_MSG_CHECKING(for gnutls library flags) GNUTLSLIBS="`$LIBGNUTLS_CONFIG --libs`"; AC_MSG_RESULT($GNUTLSLIBS) else AC_CHECK_LIB(gnutls, gnutls_init) fi AC_SUBST(GNUTLSHEAD) AC_SUBST(GNUTLSLIBS) dnl ======================================================================== dnl System Health dnl ======================================================================== dnl Check if servicelog development package is installed SERVICELOG=servicelog-1 SERVICELOG_EXISTS="no" AC_MSG_CHECKING(for $SERVICELOG packages) if $PKGCONFIG --exists $SERVICELOG then SERVICELOG_EXISTS="yes" fi AC_MSG_RESULT($SERVICELOG_EXISTS) AM_CONDITIONAL(BUILD_SERVICELOG, test "$SERVICELOG_EXISTS" = "yes") dnl Check if OpenIMPI packages and servicelog are installed OPENIPMI="OpenIPMI OpenIPMIposix" OPENIPMI_SERVICELOG_EXISTS="no" AC_MSG_CHECKING(for $SERVICELOG $OPENIPMI packages) if $PKGCONFIG --exists $OPENIPMI $SERVICELOG then OPENIPMI_SERVICELOG_EXISTS="yes" fi AC_MSG_RESULT($OPENIPMI_SERVICELOG_EXISTS) AM_CONDITIONAL(BUILD_OPENIPMI_SERVICELOG, test "$OPENIPMI_SERVICELOG_EXISTS" = "yes") dnl ======================================================================== dnl checks for library functions to replace them dnl dnl NoSuchFunctionName: dnl is a dummy function which no system supplies. It is here to make dnl the system compile semi-correctly on OpenBSD which doesn't know dnl how to create an empty archive dnl dnl scandir: Only on BSD. dnl System-V systems may have it, but hidden and/or deprecated. dnl A replacement function is supplied for it. dnl dnl setenv: is some bsdish function that should also be avoided (use dnl putenv instead) dnl On the other hand, putenv doesn't provide the right API for the dnl code and has memory leaks designed in (sigh...) Fortunately this dnl A replacement function is supplied for it. dnl dnl strerror: returns a string that corresponds to an errno. dnl A replacement function is supplied for it. dnl dnl unsetenv: is some bsdish function that should also be avoided (No dnl replacement) dnl A replacement function is supplied for it. dnl dnl strnlen: is a gnu function similar to strlen, but safer. dnl We wrote a tolearably-fast replacement function for it. dnl dnl strndup: is a gnu function similar to strdup, but safer. dnl We wrote a tolearably-fast replacement function for it. dnl dnl daemon: is a GNU function. The daemon() function is for programs wishing to dnl detach themselves from the controlling terminal and run in the dnl background as system daemon dnl A replacement function is supplied for it. AC_REPLACE_FUNCS(alphasort inet_pton NoSuchFunctionName scandir setenv strerror unsetenv strnlen strndup daemon strlcpy strlcat) dnl ======================================================================== dnl Compiler flags dnl ======================================================================== dnl Make sure that CFLAGS is not exported. If the user did dnl not have CFLAGS in their environment then this should have dnl no effect. However if CFLAGS was exported from the user's dnl environment, then the new CFLAGS will also be exported dnl to sub processes. CC_ERRORS="" CC_EXTRAS="" if export | fgrep " CFLAGS=" > /dev/null; then export -n CFLAGS || true # We don't want to bomb out if this fails fi if test "$GCC" != yes; then CFLAGS="$CFLAGS -g" enable_fatal_warnings=no else CFLAGS="$CFLAGS -ggdb3 -O0" # We had to eliminate -Wnested-externs because of libtool changes EXTRA_FLAGS="-fgnu89-inline -fstack-protector-all -Wall -Waggregate-return -Wbad-function-cast -Wcast-qual -Wcast-align -Wdeclaration-after-statement -Wendif-labels -Wfloat-equal -Wformat=2 -Wformat-security -Wformat-nonliteral -Winline -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-long-long -Wno-strict-aliasing -Wpointer-arith -Wstrict-prototypes -Wunsigned-char -Wwrite-strings" # Additional warnings it might be nice to enable one day # -Wshadow # -Wunreachable-code for j in $EXTRA_FLAGS do if cc_supports_flag $j then CC_EXTRAS="$CC_EXTRAS $j" fi done dnl In lib/ais/Makefile.am there's a gcc option available as of v4.x GCC_MAJOR=`gcc -v 2>&1 | awk 'END{print $3}' | sed 's/[.].*//'` AM_CONDITIONAL(GCC_4, test "${GCC_MAJOR}" = 4) dnl System specific options case "$host_os" in *linux*|*bsd*) if test "${enable_fatal_warnings}" = "unknown"; then enable_fatal_warnings=yes fi ;; esac if test "x${enable_fatal_warnings}" != xno && cc_supports_flag -Werror ; then enable_fatal_warnings=yes else enable_fatal_warnings=no fi if test "x${enable_ansi}" != xno && cc_supports_flag -std=iso9899:199409 ; then AC_MSG_NOTICE(Enabling ANSI Compatibility) CC_EXTRAS="$CC_EXTRAS -ansi -D_GNU_SOURCE -DANSI_ONLY" fi AC_MSG_NOTICE(Activated additional gcc flags: ${CC_EXTRAS}) fi CFLAGS="$CFLAGS $CC_EXTRAS" NON_FATAL_CFLAGS="$CFLAGS" AC_SUBST(NON_FATAL_CFLAGS) dnl dnl We reset CFLAGS to include our warnings *after* all function dnl checking goes on, so that our warning flags don't keep the dnl AC_*FUNCS() calls above from working. In particular, -Werror will dnl *always* cause us troubles if we set it before here. dnl dnl if test "x${enable_fatal_warnings}" = xyes ; then AC_MSG_NOTICE(Enabling Fatal Warnings) CFLAGS="$CFLAGS -Werror" fi AC_SUBST(CFLAGS) dnl This is useful for use in Makefiles that need to remove one specific flag CFLAGS_COPY="$CFLAGS" AC_SUBST(CFLAGS_COPY) AC_SUBST(LIBADD_DL) dnl extra flags for dynamic linking libraries AC_SUBST(LIBADD_INTL) dnl extra flags for GNU gettext stuff... AC_SUBST(LOCALE) dnl Options for cleaning up the compiler output QUIET_LIBTOOL_OPTS="" QUIET_MAKE_OPTS="" if test "x${enable_quiet}" = "xyes"; then QUIET_LIBTOOL_OPTS="--quiet" QUIET_MAKE_OPTS="--quiet" fi AC_MSG_RESULT(Supress make details: ${enable_quiet}) dnl Put the above variables to use LIBTOOL="${LIBTOOL} --tag=CC \$(QUIET_LIBTOOL_OPTS)" MAKE="${MAKE} \$(QUIET_MAKE_OPTS)" AC_SUBST(CC) AC_SUBST(MAKE) AC_SUBST(LIBTOOL) AC_SUBST(QUIET_MAKE_OPTS) AC_SUBST(QUIET_LIBTOOL_OPTS) AC_DEFINE_UNQUOTED(CRM_FEATURES, "$PKG_FEATURES", Set of enabled features) dnl The Makefiles and shell scripts we output AC_CONFIG_FILES(Makefile \ cts/Makefile \ cts/CTSvars.py \ cts/LSBDummy \ cib/Makefile \ crmd/Makefile \ pengine/Makefile \ pengine/regression.core.sh \ doc/Makefile \ doc/cibadmin.8 \ doc/crm_resource.8 \ doc/Pacemaker_Explained/publican.cfg \ include/Makefile \ include/crm/Makefile \ include/crm/common/Makefile \ include/crm/pengine/Makefile \ replace/Makefile \ lib/Makefile \ lib/ais/Makefile \ lib/common/Makefile \ lib/cib/Makefile \ lib/pengine/Makefile \ lib/transition/Makefile \ lib/fencing/Makefile \ lib/plugins/Makefile \ lib/plugins/lrm/Makefile \ fencing/Makefile \ extra/Makefile \ extra/resources/Makefile \ tools/Makefile \ tools/crm_report \ tools/hb2openais.sh \ tools/crm_primitive.py \ shell/Makefile \ shell/templates/Makefile \ shell/regression/Makefile \ - shell/regression/regression.sh \ - shell/regression/lrmregtest-lsb \ shell/regression/testcases/Makefile \ shell/modules/Makefile \ shell/modules/ui.py \ shell/modules/ra.py \ shell/modules/vars.py \ shell/modules/help.py \ xml/Makefile \ ) dnl Now process the entire list of files added by previous dnl calls to AC_CONFIG_FILES() AC_OUTPUT() dnl ***************** dnl Configure summary dnl ***************** AC_MSG_RESULT([]) AC_MSG_RESULT([$PACKAGE configuration:]) AC_MSG_RESULT([ Version = ${VERSION} (Build: $BUILD_VERSION)]) AC_MSG_RESULT([ Features =${PKG_FEATURES}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ Prefix = ${prefix}]) AC_MSG_RESULT([ Executables = ${sbindir}]) AC_MSG_RESULT([ Man pages = ${mandir}]) AC_MSG_RESULT([ Libraries = ${libdir}]) AC_MSG_RESULT([ Header files = ${includedir}]) AC_MSG_RESULT([ Arch-independent files = ${datadir}]) AC_MSG_RESULT([ State information = ${localstatedir}]) AC_MSG_RESULT([ System configuration = ${sysconfdir}]) AC_MSG_RESULT([ AIS Plugins = ${LCRSODIR}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ Use system LTDL = ${ac_cv_lib_ltdl_lt_dlopen}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ HA group name = ${CRM_DAEMON_GROUP}]) AC_MSG_RESULT([ HA user name = ${CRM_DAEMON_USER}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ CFLAGS = ${CFLAGS}]) AC_MSG_RESULT([ Libraries = ${LIBS}]) AC_MSG_RESULT([ Stack Libraries = ${CLUSTERLIBS}]) diff --git a/fencing/main.c b/fencing/main.c index 6ac9fbcee7..56b6e708b6 100644 --- a/fencing/main.c +++ b/fencing/main.c @@ -1,639 +1,641 @@ /* * Copyright (C) 2009 Andrew Beekhof * * 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 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include char *channel1 = NULL; char *channel2 = NULL; char *stonith_our_uname = NULL; GMainLoop *mainloop = NULL; GHashTable *client_list = NULL; gboolean stonith_shutdown_flag = FALSE; #if SUPPORT_HEARTBEAT ll_cluster_t *hb_conn = NULL; #endif static gboolean stonith_client_disconnect( IPC_Channel *channel, stonith_client_t *stonith_client) { if (channel == NULL) { CRM_DEV_ASSERT(stonith_client == NULL); } else if (stonith_client == NULL) { crm_err("No client"); } else { CRM_DEV_ASSERT(channel->ch_status != IPC_CONNECT); crm_debug_2("Cleaning up after client disconnect: %s/%s/%s", crm_str(stonith_client->name), stonith_client->channel_name, stonith_client->id); if(stonith_client->id != NULL) { if(!g_hash_table_remove(client_list, stonith_client->id)) { crm_err("Client %s not found in the hashtable", stonith_client->name); } } } return FALSE; } static gboolean stonith_client_callback(IPC_Channel *channel, gpointer user_data) { int lpc = 0; const char *value = NULL; xmlNode *request = NULL; gboolean keep_channel = TRUE; stonith_client_t *stonith_client = user_data; CRM_CHECK(stonith_client != NULL, crm_err("Invalid client"); return FALSE); CRM_CHECK(stonith_client->id != NULL, crm_err("Invalid client: %p", stonith_client); return FALSE); if(IPC_ISRCONN(channel) && channel->ops->is_message_pending(channel)) { lpc++; request = xmlfromIPC(channel, MAX_IPC_DELAY); if (request == NULL) { goto bail; } if(stonith_client->name == NULL) { value = crm_element_value(request, F_STONITH_CLIENTNAME); if(value == NULL) { stonith_client->name = crm_itoa(channel->farside_pid); } else { stonith_client->name = crm_strdup(value); } } crm_xml_add(request, F_STONITH_CLIENTID, stonith_client->id); crm_xml_add(request, F_STONITH_CLIENTNAME, stonith_client->name); if(stonith_client->callback_id == NULL) { value = crm_element_value(request, F_STONITH_CALLBACK_TOKEN); if(value != NULL) { stonith_client->callback_id = crm_strdup(value); } else { stonith_client->callback_id = crm_strdup(stonith_client->id); } } crm_log_xml(LOG_MSG, "Client[inbound]", request); stonith_command(stonith_client, request, NULL); free_xml(request); } bail: if(channel->ch_status != IPC_CONNECT) { crm_debug_2("Client disconnected"); keep_channel = stonith_client_disconnect(channel, stonith_client); } return keep_channel; } static void stonith_client_destroy(gpointer user_data) { stonith_client_t *stonith_client = user_data; if(stonith_client == NULL) { crm_debug_4("Destroying %p", user_data); return; } if(stonith_client->source != NULL) { crm_debug_4("Deleting %s (%p) from mainloop", stonith_client->name, stonith_client->source); G_main_del_IPC_Channel(stonith_client->source); stonith_client->source = NULL; } crm_debug_3("Destroying %s (%p)", stonith_client->name, user_data); crm_free(stonith_client->name); crm_free(stonith_client->callback_id); crm_free(stonith_client->id); crm_free(stonith_client); crm_debug_4("Freed the cib client"); return; } static gboolean stonith_client_connect(IPC_Channel *channel, gpointer user_data) { cl_uuid_t client_id; xmlNode *reg_msg = NULL; stonith_client_t *new_client = NULL; char uuid_str[UU_UNPARSE_SIZEOF]; const char *channel_name = user_data; crm_debug_3("Connecting channel"); CRM_CHECK(channel_name != NULL, return FALSE); if (channel == NULL) { crm_err("Channel was NULL"); return FALSE; } else if (channel->ch_status != IPC_CONNECT) { crm_err("Channel was disconnected"); return FALSE; } else if(stonith_shutdown_flag) { crm_info("Ignoring new client [%d] during shutdown", channel->farside_pid); return FALSE; } crm_malloc0(new_client, sizeof(stonith_client_t)); new_client->channel = channel; new_client->channel_name = channel_name; crm_debug_3("Created channel %p for channel %s", new_client, new_client->channel_name); channel->ops->set_recv_qlen(channel, 1024); channel->ops->set_send_qlen(channel, 1024); new_client->source = G_main_add_IPC_Channel( G_PRIORITY_DEFAULT, channel, FALSE, stonith_client_callback, new_client, stonith_client_destroy); crm_debug_3("Channel %s connected for client %s", new_client->channel_name, new_client->id); cl_uuid_generate(&client_id); cl_uuid_unparse(&client_id, uuid_str); CRM_CHECK(new_client->id == NULL, crm_free(new_client->id)); new_client->id = crm_strdup(uuid_str); /* make sure we can find ourselves later for sync calls * redirected to the master instance */ g_hash_table_insert(client_list, new_client->id, new_client); reg_msg = create_xml_node(NULL, "callback"); crm_xml_add(reg_msg, F_STONITH_OPERATION, CRM_OP_REGISTER); crm_xml_add(reg_msg, F_STONITH_CLIENTID, new_client->id); send_ipc_message(channel, reg_msg); free_xml(reg_msg); return TRUE; } static void stonith_peer_callback(xmlNode * msg, void* private_data) { const char *remote = crm_element_value(msg, F_ORIG); crm_log_xml(LOG_MSG, "Peer[inbound]", msg); stonith_command(NULL, msg, remote); } static void stonith_peer_hb_callback(HA_Message * msg, void* private_data) { xmlNode *xml = convert_ha_message(NULL, msg, __FUNCTION__); stonith_peer_callback(xml, private_data); free_xml(xml); } #if SUPPORT_AIS static gboolean stonith_peer_ais_callback( AIS_Message *wrapper, char *data, int sender) { xmlNode *xml = NULL; if(wrapper->header.id == crm_class_cluster) { xml = string2xml(data); if(xml == NULL) { goto bail; } crm_xml_add(xml, F_ORIG, wrapper->sender.uname); crm_xml_add_int(xml, F_SEQ, wrapper->id); stonith_peer_callback(xml, NULL); } free_xml(xml); return TRUE; bail: crm_err("Invalid XML: '%.120s'", data); return TRUE; } static void stonith_peer_ais_destroy(gpointer user_data) { crm_err("AIS connection terminated"); ais_fd_sync = -1; exit(1); } #endif static void stonith_peer_hb_destroy(gpointer user_data) { if(stonith_shutdown_flag) { crm_info("Heartbeat disconnection complete... exiting"); } else { crm_err("Heartbeat connection lost! Exiting."); } crm_info("Exiting..."); if (mainloop != NULL && g_main_is_running(mainloop)) { g_main_quit(mainloop); } else { exit(LSB_EXIT_OK); } } static int send_via_callback_channel(xmlNode *msg, const char *token) { stonith_client_t *hash_client = NULL; enum stonith_errors rc = stonith_ok; crm_debug_3("Delivering msg %p to client %s", msg, token); if(token == NULL) { crm_err("No client id token, cant send message"); if(rc == stonith_ok) { rc = -1; } } else if(msg == NULL) { crm_err("No message to send"); rc = -1; } else { /* A client that left before we could reply is not really * _our_ error. Warn instead. */ hash_client = g_hash_table_lookup(client_list, token); if(hash_client == NULL) { crm_warn("Cannot find client for token %s", token); rc = -1; } else if (crm_str_eq(hash_client->channel_name, "remote", FALSE)) { /* just hope it's alive */ } else if(hash_client->channel == NULL) { crm_err("Cannot find channel for client %s", token); rc = -1; } } if(rc == stonith_ok) { crm_debug_3("Delivering reply to client %s (%s)", token, hash_client->channel_name); if(send_ipc_message(hash_client->channel, msg) == FALSE) { crm_warn("Delivery of reply to client %s/%s failed", hash_client->name, token); rc = -1; } } return rc; } void do_local_reply(xmlNode *notify_src, const char *client_id, gboolean sync_reply, gboolean from_peer) { /* send callback to originating child */ stonith_client_t *client_obj = NULL; enum stonith_errors local_rc = stonith_ok; crm_debug_2("Sending response"); if(client_id != NULL) { client_obj = g_hash_table_lookup(client_list, client_id); } else { crm_debug_2("No client to sent the response to." " F_STONITH_CLIENTID not set."); } crm_debug_3("Sending callback to request originator"); if(client_obj == NULL) { local_rc = -1; } else { const char *client_id = client_obj->callback_id; crm_debug_2("Sending %ssync response to %s %s", sync_reply?"":"an a-", client_obj->name, from_peer?"(originator of delegated request)":""); if(sync_reply) { client_id = client_obj->id; } local_rc = send_via_callback_channel(notify_src, client_id); } if(local_rc != stonith_ok && client_obj != NULL) { crm_warn("%sSync reply to %s failed: %s", sync_reply?"":"A-", client_obj?client_obj->name:"", stonith_error2string(local_rc)); } } long long get_stonith_flag(const char *name) { if(safe_str_eq(name, STONITH_OP_FENCE)) { return 0x01; } else if(safe_str_eq(name, STONITH_OP_DEVICE_ADD)) { return 0x04; } else if(safe_str_eq(name, STONITH_OP_DEVICE_DEL)) { return 0x10; } return 0; } static void stonith_notify_client(gpointer key, gpointer value, gpointer user_data) { IPC_Channel *ipc_client = NULL; xmlNode *update_msg = user_data; stonith_client_t *client = value; const char *type = NULL; CRM_CHECK(client != NULL, return); CRM_CHECK(update_msg != NULL, return); type = crm_element_value(update_msg, F_SUBTYPE); CRM_CHECK(type != NULL, crm_log_xml_err(update_msg, "notify"); return); if(client == NULL) { crm_warn("Skipping NULL client"); return; } else if(client->channel == NULL) { crm_warn("Skipping client with NULL channel"); return; } else if(client->name == NULL) { crm_debug_2("Skipping unnammed client / comamnd channel"); return; } ipc_client = client->channel; if(client->flags & get_stonith_flag(type)) { crm_info("Sending %s-notification to client %s/%s", type, client->name, client->id); if(ipc_client->send_queue->current_qlen >= ipc_client->send_queue->max_qlen) { /* We never want the STONITH to exit because our client is slow */ crm_crit("%s-notification of client %s/%s failed - queue saturated", type, client->name, client->id); } else if(send_ipc_message(ipc_client, update_msg) == FALSE) { crm_warn("%s-Notification of client %s/%s failed", type, client->name, client->id); } } } void do_stonith_notify( int options, const char *type, enum stonith_errors result, xmlNode *data, const char *remote) { /* TODO: Standardize the contents of data */ xmlNode *update_msg = create_xml_node(NULL, "notify"); CRM_CHECK_AND_STORE(type != NULL, ;); crm_xml_add(update_msg, F_TYPE, T_STONITH_NOTIFY); crm_xml_add(update_msg, F_SUBTYPE, type); crm_xml_add(update_msg, F_STONITH_OPERATION, type); crm_xml_add_int(update_msg, F_STONITH_RC, result); if(data != NULL) { add_message_xml(update_msg, F_STONITH_CALLDATA, data); } crm_debug_3("Notifying clients"); g_hash_table_foreach(client_list, stonith_notify_client, update_msg); free_xml(update_msg); crm_debug_3("Notify complete"); } static void stonith_shutdown(int nsig) { stonith_shutdown_flag = TRUE; crm_info("Terminating with %d clients", g_hash_table_size(client_list)); stonith_client_disconnect(NULL, NULL); exit(0); } static void stonith_cleanup(void) { crm_peer_destroy(); g_hash_table_destroy(client_list); crm_free(stonith_our_uname); #if HAVE_LIBXML2 xmlCleanupParser(); #endif crm_free(channel1); } static struct crm_option long_options[] = { {"stand-alone", 0, 0, 's'}, {"verbose", 0, 0, 'V'}, {"version", 0, 0, '$'}, {"help", 0, 0, '?'}, {0, 0, 0, 0} }; int main(int argc, char ** argv) { int flag; int rc = 0; int argerr = 0; int option_index = 0; gboolean stand_alone = FALSE; - crm_log_init("stonith-ng", LOG_INFO, TRUE, TRUE, argc, argv); + set_crm_log_level(LOG_INFO); + crm_system_name = "stonith-ng"; crm_set_options("V?s$", "mode [options]", long_options, "Provides a summary of cluster's current state." "\n\nOutputs varying levels of detail in a number of different formats.\n"); while (1) { flag = crm_get_option(argc, argv, &option_index); if (flag == -1) break; switch(flag) { case 'V': alter_debug(DEBUG_INC); cl_log_enable_stderr(1); break; case 's': stand_alone = TRUE; cl_log_enable_stderr(1); break; case '$': case '?': crm_help(flag, LSB_EXIT_OK); break; default: ++argerr; break; } } if(argc - optind == 1 && safe_str_eq("metadata", argv[optind])) { /* TODO: Cleanup */; printf("\n"); printf("\n"); printf("1.0\n"); printf("This is a fake resource that details the instance attributes handled by stonithd.\n"); printf("stonithd Options\n"); printf("\n"); printf("\n"); printf("How long to wait for the STONITH action to complete. Overrides the stonith-timeout cluster property\n"); printf("\n"); printf("How long to wait for the STONITH action to complete. Overrides the stonith-timeout cluster property\n"); printf("\n"); printf("\n"); printf("The priority of the stonith resource. The lower the number, the higher the priority.\n"); printf("\n"); printf("The priority of the stonith resource. The lower the number, the higher the priority.\n"); printf("\n"); printf("\n"); printf("\n"); return 0; } - if (optind > argc) { + if (optind != argc) { ++argerr; } if (argerr) { crm_help('?', LSB_EXIT_GENERIC); } + crm_log_init("stonith-ng", crm_log_level, TRUE, TRUE, argc, argv); mainloop_add_signal(SIGTERM, stonith_shutdown); /* EnableProcLogging(); */ set_sigchld_proctrack(G_PRIORITY_HIGH,DEFAULT_MAXDISPATCHTIME); crm_peer_init(); client_list = g_hash_table_new(g_str_hash, g_str_equal); if(stand_alone == FALSE) { void *dispatch = stonith_peer_hb_callback; void *destroy = stonith_peer_hb_destroy; if(is_openais_cluster()) { #if SUPPORT_AIS destroy = stonith_peer_ais_destroy; dispatch = stonith_peer_ais_callback; #endif } if(crm_cluster_connect(&stonith_our_uname, NULL, dispatch, destroy, #if SUPPORT_HEARTBEAT &hb_conn #else NULL #endif ) == FALSE){ crm_crit("Cannot sign in to the cluster... terminating"); exit(100); } } else { stonith_our_uname = crm_strdup("localhost"); } channel1 = crm_strdup(stonith_channel); rc = init_server_ipc_comms( channel1, stonith_client_connect, default_ipc_connection_destroy); channel2 = crm_strdup(stonith_channel_callback); rc = init_server_ipc_comms( channel2, stonith_client_connect, default_ipc_connection_destroy); if(rc == 0) { /* Create the mainloop and run it... */ mainloop = g_main_new(FALSE); crm_info("Starting %s mainloop", crm_system_name); g_main_run(mainloop); } else { crm_err("Couldnt start all communication channels, exiting."); } stonith_cleanup(); #if SUPPORT_HEARTBEAT if(hb_conn) { hb_conn->llc_ops->delete(hb_conn); } #endif crm_info("Done"); return rc; } diff --git a/lib/cib/cib_client.c b/lib/cib/cib_client.c index 1fe3fdc2a7..6c14328cd3 100644 --- a/lib/cib/cib_client.c +++ b/lib/cib/cib_client.c @@ -1,598 +1,616 @@ /* * Copyright (c) 2004 Andrew Beekhof * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser 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 library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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 * */ #include #include #include #include #include #include #include #include #include #include #include #include GHashTable *cib_op_callback_table = NULL; int cib_client_set_op_callback( cib_t *cib, void (*callback)(const xmlNode *msg, int call_id, int rc, xmlNode *output)); int cib_client_add_notify_callback( cib_t *cib, const char *event, void (*callback)( const char *event, xmlNode *msg)); int cib_client_del_notify_callback( cib_t *cib, const char *event, void (*callback)( const char *event, xmlNode *msg)); gint ciblib_GCompareFunc(gconstpointer a, gconstpointer b); #define op_common(cib) \ if(cib == NULL) { \ return cib_missing; \ } else if(cib->cmds->variant_op == NULL) { \ return cib_variant; \ } static int cib_client_noop(cib_t *cib, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CRM_OP_NOOP, NULL, NULL, NULL, NULL, call_options); } static int cib_client_ping(cib_t *cib, xmlNode **output_data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CRM_OP_PING, NULL,NULL,NULL, output_data, call_options); } static int cib_client_query(cib_t *cib, const char *section, xmlNode **output_data, int call_options) { return cib->cmds->query_from( cib, NULL, section, output_data, call_options); } static int cib_client_query_from(cib_t *cib, const char *host, const char *section, xmlNode **output_data, int call_options) { op_common(cib) return cib->cmds->variant_op(cib, CIB_OP_QUERY, host, section, NULL, output_data, call_options); } static int cib_client_is_master(cib_t *cib) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_ISMASTER, NULL, NULL,NULL,NULL, cib_scope_local|cib_sync_call); } static int cib_client_set_slave(cib_t *cib, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_SLAVE, NULL,NULL,NULL,NULL, call_options); } static int cib_client_set_slave_all(cib_t *cib, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_SLAVEALL, NULL,NULL,NULL,NULL, call_options); } static int cib_client_set_master(cib_t *cib, int call_options) { op_common(cib) crm_debug_3("Adding cib_scope_local to options"); return cib->cmds->variant_op( cib, CIB_OP_MASTER, NULL,NULL,NULL,NULL, call_options|cib_scope_local); } static int cib_client_bump_epoch(cib_t *cib, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_BUMP, NULL, NULL, NULL, NULL, call_options); } static int cib_client_upgrade(cib_t *cib, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_UPGRADE, NULL, NULL, NULL, NULL, call_options); } static int cib_client_sync(cib_t *cib, const char *section, int call_options) { return cib->cmds->sync_from(cib, NULL, section, call_options); } static int cib_client_sync_from( cib_t *cib, const char *host, const char *section, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_SYNC, host, section, NULL, NULL, call_options); } static int cib_client_create( cib_t *cib, const char *section, xmlNode *data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_CREATE, NULL, section, data, NULL, call_options); } static int cib_client_modify( cib_t *cib, const char *section, xmlNode *data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_MODIFY, NULL, section, data, NULL, call_options); } static int cib_client_update( cib_t *cib, const char *section, xmlNode *data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_MODIFY, NULL, section, data, NULL, call_options); } static int cib_client_replace( cib_t *cib, const char *section, xmlNode *data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_REPLACE, NULL, section, data, NULL, call_options); } static int cib_client_delete( cib_t *cib, const char *section, xmlNode *data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_DELETE, NULL, section, data, NULL, call_options); } static int cib_client_delete_absolute( cib_t *cib, const char *section, xmlNode *data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_DELETE_ALT, NULL, section, data, NULL, call_options); } static int cib_client_erase( cib_t *cib, xmlNode **output_data, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CIB_OP_ERASE, NULL, NULL, NULL, output_data, call_options); } static int cib_client_quit(cib_t *cib, int call_options) { op_common(cib) return cib->cmds->variant_op( cib, CRM_OP_QUIT, NULL, NULL, NULL, NULL, call_options); } static void cib_destroy_op_callback(gpointer data) { cib_callback_client_t *blob = data; if(blob->timer && blob->timer->ref > 0) { g_source_remove(blob->timer->ref); } crm_free(blob->timer); crm_free(blob); } char *get_shadow_file(const char *suffix) { + char *cib_home = NULL; char *fullname = NULL; char *name = crm_concat("shadow", suffix, '.'); const char *dir = getenv("CIB_shadow_dir"); if(dir == NULL) { const char *user = getenv("USER"); if(safe_str_eq(user, "root") || safe_str_eq(user, CRM_DAEMON_USER)) { dir = CRM_CONFIG_DIR; + } else { + const char *home = getenv("HOME"); + dir = "/tmp"; + if(home && home[0] == '/') { + int rc = 0; + cib_home = crm_concat(home, ".cib", '/'); + + rc = mkdir(cib_home, 0700); + if(rc < 0 && errno != EEXIST) { + crm_perror(LOG_ERR, "Couldn't create user-specific shadow directory: %s", cib_home); + errno = 0; + + } else { + dir = cib_home; + } + } } } fullname = crm_concat(dir, name, '/'); + crm_free(cib_home); crm_free(name); return fullname; } cib_t* cib_shadow_new(const char *shadow) { cib_t *new_cib = NULL; char *shadow_file = NULL; CRM_CHECK(shadow != NULL, return NULL); shadow_file = get_shadow_file(shadow); new_cib = cib_file_new(shadow_file); crm_free(shadow_file); return new_cib; } cib_t *cib_new_no_shadow(void) { unsetenv("CIB_shadow"); return cib_new(); } cib_t* cib_new(void) { const char *value = getenv("CIB_shadow"); if(value) { return cib_shadow_new(value); } value = getenv("CIB_file"); if(value) { return cib_file_new(value); } value = getenv("CIB_port"); if(value) { gboolean encrypted = TRUE; int port = crm_parse_int(value, NULL); const char *server = getenv("CIB_server"); const char *user = getenv("CIB_user"); const char *pass = getenv("CIB_passwd"); value = getenv("CIB_encrypted"); if(value && crm_is_true(value) == FALSE) { crm_info("Disabling TLS"); encrypted = FALSE; } if(user == NULL) { user = CRM_DAEMON_USER; crm_info("Defaulting to user: %s", user); } if(server == NULL) { server = "localhost"; crm_info("Defaulting to localhost"); } return cib_remote_new(server, user, pass, port, encrypted); } return cib_native_new(); } /* this is backwards... cib_*_new should call this not the other way around */ cib_t* cib_new_variant(void) { cib_t* new_cib = NULL; crm_malloc0(new_cib, sizeof(cib_t)); if(cib_op_callback_table != NULL) { g_hash_table_destroy(cib_op_callback_table); cib_op_callback_table = NULL; } if(cib_op_callback_table == NULL) { cib_op_callback_table = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, cib_destroy_op_callback); } new_cib->call_id = 1; new_cib->variant = cib_undefined; new_cib->type = cib_none; new_cib->state = cib_disconnected; new_cib->op_callback = NULL; new_cib->variant_opaque = NULL; new_cib->notify_list = NULL; /* the rest will get filled in by the variant constructor */ crm_malloc0(new_cib->cmds, sizeof(cib_api_operations_t)); new_cib->cmds->set_op_callback = cib_client_set_op_callback; new_cib->cmds->add_notify_callback = cib_client_add_notify_callback; new_cib->cmds->del_notify_callback = cib_client_del_notify_callback; new_cib->cmds->register_callback = cib_client_register_callback; new_cib->cmds->noop = cib_client_noop; new_cib->cmds->ping = cib_client_ping; new_cib->cmds->query = cib_client_query; new_cib->cmds->sync = cib_client_sync; new_cib->cmds->query_from = cib_client_query_from; new_cib->cmds->sync_from = cib_client_sync_from; new_cib->cmds->is_master = cib_client_is_master; new_cib->cmds->set_master = cib_client_set_master; new_cib->cmds->set_slave = cib_client_set_slave; new_cib->cmds->set_slave_all = cib_client_set_slave_all; new_cib->cmds->upgrade = cib_client_upgrade; new_cib->cmds->bump_epoch = cib_client_bump_epoch; new_cib->cmds->create = cib_client_create; new_cib->cmds->modify = cib_client_modify; new_cib->cmds->update = cib_client_update; new_cib->cmds->replace = cib_client_replace; new_cib->cmds->delete = cib_client_delete; new_cib->cmds->erase = cib_client_erase; new_cib->cmds->quit = cib_client_quit; new_cib->cmds->delete_absolute = cib_client_delete_absolute; return new_cib; } void cib_delete(cib_t *cib) { GList *list = cib->notify_list; while(list != NULL) { cib_notify_client_t *client = g_list_nth_data(list, 0); list = g_list_remove(list, client); crm_free(client); } g_hash_table_destroy(cib_op_callback_table); cib->cmds->free(cib); cib = NULL; } int cib_client_set_op_callback( cib_t *cib, void (*callback)(const xmlNode *msg, int call_id, int rc, xmlNode *output)) { if(callback == NULL) { crm_info("Un-Setting operation callback"); } else { crm_debug_3("Setting operation callback"); } cib->op_callback = callback; return cib_ok; } int cib_client_add_notify_callback( cib_t *cib, const char *event, void (*callback)( const char *event, xmlNode *msg)) { GList *list_item = NULL; cib_notify_client_t *new_client = NULL; if(cib->variant != cib_native && cib->variant != cib_remote) { return cib_NOTSUPPORTED; } crm_debug_2("Adding callback for %s events (%d)", event, g_list_length(cib->notify_list)); crm_malloc0(new_client, sizeof(cib_notify_client_t)); new_client->event = event; new_client->callback = callback; list_item = g_list_find_custom( cib->notify_list, new_client, ciblib_GCompareFunc); if(list_item != NULL) { crm_warn("Callback already present"); crm_free(new_client); return cib_EXISTS; } else { cib->notify_list = g_list_append( cib->notify_list, new_client); cib->cmds->register_notification(cib, event, 1); crm_debug_3("Callback added (%d)", g_list_length(cib->notify_list)); } return cib_ok; } int cib_client_del_notify_callback( cib_t *cib, const char *event, void (*callback)( const char *event, xmlNode *msg)) { GList *list_item = NULL; cib_notify_client_t *new_client = NULL; if(cib->variant != cib_native && cib->variant != cib_remote) { return cib_NOTSUPPORTED; } crm_debug("Removing callback for %s events", event); crm_malloc0(new_client, sizeof(cib_notify_client_t)); new_client->event = event; new_client->callback = callback; list_item = g_list_find_custom( cib->notify_list, new_client, ciblib_GCompareFunc); cib->cmds->register_notification(cib, event, 0); if(list_item != NULL) { cib_notify_client_t *list_client = list_item->data; cib->notify_list = g_list_remove(cib->notify_list, list_client); crm_free(list_client); crm_debug_3("Removed callback"); } else { crm_debug_3("Callback not present"); } crm_free(new_client); return cib_ok; } gint ciblib_GCompareFunc(gconstpointer a, gconstpointer b) { int rc = 0; const cib_notify_client_t *a_client = a; const cib_notify_client_t *b_client = b; CRM_CHECK(a_client->event != NULL && b_client->event != NULL, return 0); rc = strcmp(a_client->event, b_client->event); if(rc == 0) { if(a_client->callback == b_client->callback) { return 0; } else if(((long)a_client->callback) < ((long)b_client->callback)) { crm_err("callbacks for %s are not equal: %p vs. %p", a_client->event, a_client->callback, b_client->callback); return -1; } crm_err("callbacks for %s are not equal: %p vs. %p", a_client->event, a_client->callback, b_client->callback); return 1; } return rc; } static gboolean cib_async_timeout_handler(gpointer data) { struct timer_rec_s *timer = data; crm_debug("Async call %d timed out after %ds", timer->call_id, timer->timeout); cib_native_callback(timer->cib, NULL, timer->call_id, cib_remote_timeout); /* Always return TRUE, never remove the handler * We do that in remove_cib_op_callback() */ return TRUE; } gboolean cib_client_register_callback( cib_t *cib, int call_id, int timeout, gboolean only_success, void *user_data, const char *callback_name, void (*callback)(xmlNode*, int, int, xmlNode*,void*)) { cib_callback_client_t *blob = NULL; if(call_id < 0) { if(only_success == FALSE) { callback(NULL, call_id, call_id, NULL, user_data); } else { crm_warn("CIB call failed: %s", cib_error2string(call_id)); } return FALSE; } crm_malloc0(blob, sizeof(cib_callback_client_t)); blob->id = callback_name; blob->only_success = only_success; blob->user_data = user_data; blob->callback = callback; if(timeout > 0) { struct timer_rec_s *async_timer = NULL; crm_malloc0(async_timer, sizeof(struct timer_rec_s)); blob->timer = async_timer; async_timer->cib = cib; async_timer->call_id = call_id; async_timer->timeout = timeout*1000; async_timer->ref = g_timeout_add( async_timer->timeout, cib_async_timeout_handler, async_timer); } g_hash_table_insert(cib_op_callback_table, GINT_TO_POINTER(call_id), blob); return TRUE; } void remove_cib_op_callback(int call_id, gboolean all_callbacks) { if(all_callbacks) { if(cib_op_callback_table != NULL) { g_hash_table_destroy(cib_op_callback_table); } cib_op_callback_table = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, cib_destroy_op_callback); } else { g_hash_table_remove(cib_op_callback_table, GINT_TO_POINTER(call_id)); } } int num_cib_op_callbacks(void) { if(cib_op_callback_table == NULL) { return 0; } return g_hash_table_size(cib_op_callback_table); } static void cib_dump_pending_op(gpointer key, gpointer value, gpointer user_data) { int call = GPOINTER_TO_INT(key); cib_callback_client_t *blob = value; crm_debug("Call %d (%s): pending", call, crm_str(blob->id)); } void cib_dump_pending_callbacks(void) { if(cib_op_callback_table == NULL) { return; } return g_hash_table_foreach(cib_op_callback_table, cib_dump_pending_op, NULL); } diff --git a/pacemaker.spec b/pacemaker.spec index fcbfea024d..6010df56d7 100644 --- a/pacemaker.spec +++ b/pacemaker.spec @@ -1,1364 +1,1364 @@ %global gname haclient %global uname hacluster %global pcmk_docdir %{_docdir}/%{name} %global specversion 3 #global upstream_version tip %global upstream_prefix pacemaker # Keep around for when/if required #global alphatag %{upstream_version}.hg %global pcmk_release %{?alphatag:0.}%{specversion}%{?alphatag:.%{alphatag}}%{?dist} # Compatibility macros for distros (fedora) that don't provide Python macros by default # Do this instead of trying to conditionally %include %{_rpmconfigdir}/macros.python %{!?py_ver: %{expand: %%global py_ver %%(echo `python -c "import sys; print sys.version[:3]"`)}} %{!?py_prefix: %{expand: %%global py_prefix %%(echo `python -c "import sys; print sys.prefix"`)}} %{!?py_libdir: %{expand: %%global py_libdir %%{expand:%%%%{py_prefix}/lib/python%%%%{py_ver}}}} %{!?py_sitedir: %{expand: %%global py_sitedir %%{expand:%%%%{py_libdir}/site-packages}}} # Uncomment for openSUSE11.2 which advertises lib64 but uses lib #global py_sitedir %{py_prefix}/lib/python%{py_ver}/site-packages # Compatibility macro wrappers for legacy RPM versions that do not # support conditional builds %{!?bcond_without: %{expand: %%global bcond_without() %%{expand:%%%%{!?_without_%%{1}:%%%%global with_%%{1} 1}}}} %{!?bcond_with: %{expand: %%global bcond_with() %%{expand:%%%%{?_with_%%{1}:%%%%global with_%%{1} 1}}}} %{!?with: %{expand: %%global with() %%{expand:%%%%{?with_%%{1}:1}%%%%{!?with_%%{1}:0}}}} %{!?without: %{expand: %%global without() %%{expand:%%%%{?with_%%{1}:0}%%%%{!?with_%%{1}:1}}}} # Conditionals # Invoke "rpmbuild --without " or "rpmbuild --with " # to disable or enable specific features # Supported cluster stacks, must support at least one %bcond_without ais %bcond_without heartbeat # ESMTP is not available in RHEL, only in EPEL. Allow people to build # the RPM without ESMTP in case they choose not to use EPEL packages %bcond_without esmtp %bcond_without snmp # We generate some docs using Publican, but its not available everywhere %bcond_without publican Name: pacemaker Summary: Scalable High-Availability cluster resource manager Version: 1.1.1 Release: %{pcmk_release} License: GPLv2+ and LGPLv2+ Url: http://www.clusterlabs.org Group: System Environment/Daemons Source0: pacemaker.tar.bz2 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) AutoReqProv: on Requires(pre): cluster-glue Requires: resource-agents Requires: python >= 2.4 Conflicts: heartbeat < 2.99 %if 0%{?fedora} || 0%{?centos} > 4 || 0%{?rhel} > 4 Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) BuildRequires: help2man libtool-ltdl-devel %endif %if 0%{?suse_version} # net-snmp-devel on SLES10 does not suck in tcpd-devel automatically BuildRequires: help2man tcpd-devel %endif # Required for core functionality BuildRequires: automake autoconf libtool pkgconfig python BuildRequires: glib2-devel cluster-glue-libs-devel libxml2-devel libxslt-devel BuildRequires: pkgconfig python-devel gcc-c++ bzip2-devel gnutls-devel pam-devel # Enables optional functionality BuildRequires: ncurses-devel openssl-devel libselinux-devel %ifarch alpha %{ix86} x86_64 BuildRequires: lm_sensors-devel %endif %if %{with esmtp} BuildRequires: libesmtp-devel -Requires: libesmtp %endif %if %{with snmp} BuildRequires: net-snmp-devel -Requires: net-snmp %endif %if %{with ais} # Do not require corosync, the admin should select which stack to use and install it BuildRequires: corosynclib-devel %endif %if %{with heartbeat} # Do not require heartbeat, the admin should select which stack to use and install it BuildRequires: heartbeat-devel heartbeat-libs >= 3.0.0 %endif %if %{with publican} BuildRequires: publican %endif %description Pacemaker is an advanced, scalable High-Availability cluster resource manager for Linux-HA (Heartbeat) and/or OpenAIS. It supports "n-node" clusters with significant capabilities for managing resources and dependencies. It will run scripts at initialization, when machines go up or down, when related resources fail and can be configured to periodically check resource health. Available rpmbuild rebuild options: --without : heartbeat ais snmp esmtp publican %package -n pacemaker-libs License: GPLv2+ and LGPLv2+ Summary: Libraries used by the Pacemaker cluster resource manager and its clients Group: System Environment/Daemons Requires: %{name} = %{version}-%{release} %description -n pacemaker-libs Pacemaker is an advanced, scalable High-Availability cluster resource manager for Linux-HA (Heartbeat) and/or OpenAIS. It supports "n-node" clusters with significant capabilities for managing resources and dependencies. It will run scripts at initialization, when machines go up or down, when related resources fail and can be configured to periodically check resource health. %package -n pacemaker-libs-devel License: GPLv2+ and LGPLv2+ Summary: Pacemaker development package Group: Development/Libraries Requires: pacemaker-libs = %{version}-%{release} Requires: cluster-glue-libs-devel %if %{with ais} Requires: corosynclib-devel %endif %if %{with heartbeat} Requires: heartbeat-devel %endif %description -n pacemaker-libs-devel Headers and shared libraries for developing tools for Pacemaker. Pacemaker is an advanced, scalable High-Availability cluster resource manager for Linux-HA (Heartbeat) and/or OpenAIS. It supports "n-node" clusters with significant capabilities for managing resources and dependencies. It will run scripts at initialization, when machines go up or down, when related resources fail and can be configured to periodically check resource health. %package cts License: GPLv2+ and LGPLv2+ Summary: Test framework for cluster-related technologies like Pacemaker Group: System Environment/Daemons Requires: python %description cts Test framework for cluster-related technologies like Pacemaker %package doc License: GPLv2+ and LGPLv2+ Summary: Documentation for Pacemaker Group: Documentation %description doc Documentation for Pacemaker. Pacemaker is an advanced, scalable High-Availability cluster resource manager for Linux-HA (Heartbeat) and/or OpenAIS. It supports "n-node" clusters with significant capabilities for managing resources and dependencies. It will run scripts at initialization, when machines go up or down, when related resources fail and can be configured to periodically check resource health. %prep %setup -q -n %{upstream_prefix}%{?upstream_version} %build ./autogen.sh # RHEL <= 5 does not support --docdir docdir=%{pcmk_docdir} %{configure} \ %{?_without_heartbeat} \ %{?_without_ais} \ %{?_without_esmtp} \ %{?_without_snmp} \ --localstatedir=%{_var} \ --enable-fatal-warnings=no make %{_smp_mflags} docdir=%{pcmk_docdir} %install rm -rf %{buildroot} make DESTDIR=%{buildroot} docdir=%{pcmk_docdir} install # Scripts that need should be executable chmod a+x %{buildroot}/%{_libdir}/heartbeat/hb2openais-helper.py chmod a+x %{buildroot}/%{_datadir}/pacemaker/tests/cts/CTSlab.py chmod a+x %{buildroot}/%{_datadir}/pacemaker/tests/cts/extracttests.py # These are not actually scripts find %{buildroot} -name '*.xml' -type f -print0 | xargs -0 chmod a-x find %{buildroot} -name '*.xsl' -type f -print0 | xargs -0 chmod a-x find %{buildroot} -name '*.rng' -type f -print0 | xargs -0 chmod a-x find %{buildroot} -name '*.dtd' -type f -print0 | xargs -0 chmod a-x # Dont package static libs find %{buildroot} -name '*.a' -type f -print0 | xargs -0 rm -f find %{buildroot} -name '*.la' -type f -print0 | xargs -0 rm -f # Do not package these either rm -f %{buildroot}/%{_libdir}/heartbeat/crm_primitive.* rm -f %{buildroot}/%{_libdir}/heartbeat/atest rm -f %{buildroot}/%{_libdir}/service_crm.so %clean rm -rf %{buildroot} %post -n pacemaker-libs -p /sbin/ldconfig %postun -n pacemaker-libs -p /sbin/ldconfig %files ########################################################### %defattr(-,root,root) %exclude %{_datadir}/pacemaker/tests %{_datadir}/pacemaker %{_datadir}/snmp/mibs/PCMK-MIB.txt %{_libdir}/heartbeat/* %{_sbindir}/cibadmin %{_sbindir}/crm_attribute %{_sbindir}/crm_diff %{_sbindir}/crm_failcount %{_sbindir}/crm_master %{_sbindir}/crm_mon %{_sbindir}/crm %{_sbindir}/crm_resource %{_sbindir}/crm_standby %{_sbindir}/crm_verify %{_sbindir}/crmadmin %{_sbindir}/iso8601 %{_sbindir}/attrd_updater %{_sbindir}/ptest %{_sbindir}/crm_shadow %{_sbindir}/cibpipe %{_sbindir}/crm_node %{_sbindir}/crm_simulate %{_sbindir}/fence_legacy %{_sbindir}/stonith_admin %{_sbindir}/crm_report %{py_sitedir}/crm %doc %{_mandir}/man8/*.8* %doc %{_mandir}/man7/*.7* %if %{with heartbeat} %{_sbindir}/crm_uuid %else %exclude %{_sbindir}/crm_uuid %endif %doc COPYING %doc AUTHORS %dir %attr (750, %{uname}, %{gname}) %{_var}/lib/heartbeat/crm %dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pengine %dir %attr (750, %{uname}, %{gname}) %{_var}/run/crm %dir /usr/lib/ocf %dir /usr/lib/ocf/resource.d /usr/lib/ocf/resource.d/pacemaker %if %{with ais} %{_libexecdir}/lcrso/pacemaker.lcrso %endif %files -n pacemaker-libs %defattr(-,root,root) %{_libdir}/libcib.so.* %{_libdir}/libcrmcommon.so.* %{_libdir}/libcrmcluster.so.* %{_libdir}/libpe_status.so.* %{_libdir}/libpe_rules.so.* %{_libdir}/libpengine.so.* %{_libdir}/libtransitioner.so.* %{_libdir}/libstonithd.so.* %doc COPYING.LIB %doc AUTHORS %files doc +%defattr(-,root,root) %doc %{pcmk_docdir} %files cts +%defattr(-,root,root) %{py_sitedir}/cts %{_datadir}/pacemaker/tests/cts %doc COPYING.LIB %doc AUTHORS %files -n pacemaker-libs-devel %defattr(-,root,root) %exclude %{_datadir}/pacemaker/tests/cts %{_datadir}/pacemaker/tests %{_includedir}/pacemaker %{_libdir}/*.so %doc COPYING.LIB %doc AUTHORS %changelog * Tue Feb 16 2010 Andrew Beekhof - 1.1.1-1 - First public release of Pacemaker 1.1 - Package reference documentation in a doc subpackage - Move cts into a subpackage so that it can be easily consumed by others - Update source tarball to revision: 17d9cd4ee29f + New stonith daemon that supports global notifications + Service placement influenced by the physical resources + A new tool for simulating failures and the cluster’s reaction to them + Ability to serialize an otherwise unrelated a set of resource actions (eg. Xen migrations) * Wed Feb 10 2010 Andrew Beekhof - 1.0.7-4 - Rebuild for heartbeat 3.0.2-2 * Wed Feb 10 2010 Andrew Beekhof - 1.0.7-3 - Rebuild for cluster-glue 1.0.3 * Tue Jan 19 2010 Andrew Beekhof - 1.0.7-2 - Rebuild for corosync 1.2.0 * Mon Jan 18 2010 Andrew Beekhof - 1.0.7-1 - Update source tarball to revision: 2eed906f43e9 (stable-1.0) tip - Statistics: Changesets: 193 Diff: 220 files changed, 15933 insertions(+), 8782 deletions(-) - Changes since 1.0.5-4 + High: PE: Bug 2213 - Ensure groups process location constraints so that clone-node-max works for cloned groups + High: PE: Bug lf#2153 - non-clones should not restart when clones stop/start on other nodes + High: PE: Bug lf#2209 - Clone ordering should be able to prevent startup of dependant clones + High: PE: Bug lf#2216 - Correctly identify the state of anonymous clones when deciding when to probe + High: PE: Bug lf#2225 - Operations that require fencing should wait for 'stonith_complete' not 'all_stopped'. + High: PE: Bug lf#2225 - Prevent clone peers from stopping while another is instance is (potentially) being fenced + High: PE: Correctly anti-colocate with a group + High: PE: Correctly unpack ordering constraints for resource sets to avoid graph loops + High: Tools: crm: load help from crm_cli.txt + High: Tools: crm: resource sets (bnc#550923) + High: Tools: crm: support for comments (LF 2221) + High: Tools: crm: support for description attribute in resources/operations (bnc#548690) + High: Tools: hb2openais: add EVMS2 CSM processing (and other changes) (bnc#548093) + High: Tools: hb2openais: do not allow empty rules, clones, or groups (LF 2215) + High: Tools: hb2openais: refuse to convert pure EVMS volumes + High: cib: Ensure the loop for login message terminates + High: cib: Finally fix reliability of receiving large messages over remote plaintext connections + High: cib: Fix remote notifications + High: cib: For remote connections, default to CRM_DAEMON_USER since thats the only one that the cib can validate the password for using PAM + High: cib: Remote plaintext - Retry sending parts of the message that did not fit the first time + High: crmd: Ensure batch-limit is correctly enforced + High: crmd: Ensure we have the latest status after a transition abort + High (bnc#547579,547582): Tools: crm: status section editing support + High: shell: Add allow-migrate as allowed meta-attribute (bnc#539968) + Medium: Build: Do not automatically add -L/lib, it could cause 64-bit arches to break + Medium: PE: Bug lf#2206 - rsc_order constraints always use score at the top level + Medium: PE: Only complain about target-role=master for non m/s resources + Medium: PE: Prevent non-multistate resources from being promoted through target-role + Medium: PE: Provide a default action for resource-set ordering + Medium: PE: Silently fix requires=fencing for stonith resources so that it can be set in op_defaults + Medium: Tools: Bug lf#2286 - Allow the shell to accept template parameters on the command line + Medium: Tools: Bug lf#2307 - Provide a way to determin the nodeid of past cluster members + Medium: Tools: crm: add update method to template apply (LF 2289) + Medium: Tools: crm: direct RA interface for ocf class resource agents (LF 2270) + Medium: Tools: crm: direct RA interface for stonith class resource agents (LF 2270) + Medium: Tools: crm: do not add score which does not exist + Medium: Tools: crm: do not consider warnings as errors (LF 2274) + Medium: Tools: crm: do not remove sets which contain id-ref attribute (LF 2304) + Medium: Tools: crm: drop empty attributes elements + Medium: Tools: crm: exclude locations when testing for pathological constraints (LF 2300) + Medium: Tools: crm: fix exit code on single shot commands + Medium: Tools: crm: fix node delete (LF 2305) + Medium: Tools: crm: implement -F (--force) option + Medium: Tools: crm: rename status to cibstatus (LF 2236) + Medium: Tools: crm: revisit configure commit + Medium: Tools: crm: stay in crm if user specified level only (LF 2286) + Medium: Tools: crm: verify changes on exit from the configure level + Medium: ais: Some clients such as gfs_controld want a cluster name, allow one to be specified in corosync.conf + Medium: cib: Clean up logic for receiving remote messages + Medium: cib: Create valid notification control messages + Medium: cib: Indicate where the remote connection came from + Medium: cib: Send password prompt to stderr so that stdout can be redirected + Medium: cts: Fix rsh handling when stdout is not required + Medium: doc: Fill in the section on removing a node from an AIS-based cluster + Medium: doc: Update the docs to reflect the 0.6/1.0 rolling upgrade problem + Medium: doc: Use Publican for docbook based documentation + Medium: fencing: stonithd: add metadata for stonithd instance attributes (and support in the shell) + Medium: fencing: stonithd: ignore case when comparing host names (LF 2292) + Medium: tools: Make crm_mon functional with remote connections + Medium: xml: Add stopped as a supported role for operations + Medium: xml: Bug bnc#552713 - Treat node unames as text fields not IDs + Medium: xml: Bug lf#2215 - Create an always-true expression for empty rules when upgrading from 0.6 * Thu Oct 29 2009 Andrew Beekhof - 1.0.5-4 - Include the fixes from CoroSync integration testing - Move the resource templates - they are not documentation - Ensure documentation is placed in a standard location - Exclude documentation that is included elsewhere in the package - Update the tarball from upstream to version ee19d8e83c2a + High: cib: Correctly clean up when both plaintext and tls remote ports are requested + High: PE: Bug bnc#515172 - Provide better defaults for lt(e) and gt(e) comparisions + High: PE: Bug lf#2197 - Allow master instances placemaker to be influenced by colocation constraints + High: PE: Make sure promote/demote pseudo actions are created correctly + High: PE: Prevent target-role from promoting more than master-max instances + High: ais: Bug lf#2199 - Prevent expected-quorum-votes from being populated with garbage + High: ais: Prevent deadlock - dont try to release IPC message if the connection failed + High: cib: For validation errors, send back the full CIB so the client can display the errors + High: cib: Prevent use-after-free for remote plaintext connections + High: crmd: Bug lf#2201 - Prevent use-of-NULL when running heartbeat * Wed Oct 13 2009 Andrew Beekhof - 1.0.5-3 - Update the tarball from upstream to version 38cd629e5c3c + High: Core: Bug lf#2169 - Allow dtd/schema validation to be disabled + High: PE: Bug lf#2106 - Not all anonymous clone children are restarted after configuration change + High: PE: Bug lf#2170 - stop-all-resources option had no effect + High: PE: Bug lf#2171 - Prevent groups from starting if they depend on a complex resource which can not + High: PE: Disable resource management if stonith-enabled=true and no stonith resources are defined + High: PE: do not include master score if it would prevent allocation + High: ais: Avoid excessive load by checking for dead children every 1s (instead of 100ms) + High: ais: Bug rh#525589 - Prevent shutdown deadlocks when running on CoroSync + High: ais: Gracefully handle changes to the AIS nodeid + High: crmd: Bug bnc#527530 - Wait for the transition to complete before leaving S_TRANSITION_ENGINE + High: crmd: Prevent use-after-free with LOG_DEBUG_3 + Medium: xml: Mask the "symmetrical" attribute on rsc_colocation constraints (bnc#540672) + Medium (bnc#520707): Tools: crm: new templates ocfs2 and clvm + Medium: Build: Invert the disable ais/heartbeat logic so that --without (ais|heartbeat) is available to rpmbuild + Medium: PE: Bug lf#2178 - Indicate unmanaged clones + Medium: PE: Bug lf#2180 - Include node information for all failed ops + Medium: PE: Bug lf#2189 - Incorrect error message when unpacking simple ordering constraint + Medium: PE: Correctly log resources that would like to start but can not + Medium: PE: Stop ptest from logging to syslog + Medium: ais: Include version details in plugin name + Medium: crmd: Requery the resource metadata after every start operation * Fri Aug 21 2009 Tomas Mraz - 1.0.5-2.1 - rebuilt with new openssl * Wed Aug 19 2009 Andrew Beekhof - 1.0.5-2 - Add versioned perl dependency as specified by https://fedoraproject.org/wiki/Packaging/Perl#Packages_that_link_to_libperl - No longer remove RPATH data, it prevents us finding libperl.so and no other libraries were being hardcoded - Compile in support for heartbeat - Conditionally add heartbeat-devel and corosynclib-devel to the -devel requirements depending on which stacks are supported * Mon Aug 17 2009 Andrew Beekhof - 1.0.5-1 - Add dependency on resource-agents - Use the version of the configure macro that supplies --prefix, --libdir, etc - Update the tarball from upstream to version 462f1569a437 (Pacemaker 1.0.5 final) + High: Tools: crm_resource - Advertise --move instead of --migrate + Medium: Extra: New node connectivity RA that uses system ping and attrd_updater + Medium: crmd: Note that dc-deadtime can be used to mask the brokeness of some switches * Tue Aug 11 2009 Ville Skyttä - 1.0.5-0.7.c9120a53a6ae.hg - Use bzipped upstream tarball. * Wed Jul 29 2009 Andrew Beekhof - 1.0.5-0.6.c9120a53a6ae.hg - Add back missing build auto* dependancies - Minor cleanups to the install directive * Tue Jul 28 2009 Andrew Beekhof - 1.0.5-0.5.c9120a53a6ae.hg - Add a leading zero to the revision when alphatag is used * Tue Jul 28 2009 Andrew Beekhof - 1.0.5-0.4.c9120a53a6ae.hg - Incorporate the feedback from the cluster-glue review - Realistically, the version is a 1.0.5 pre-release - Use the global directive instead of define for variables - Use the haclient/hacluster group/user instead of daemon - Use the _configure macro - Fix install dependancies * Fri Jul 24 2009 Andrew Beekhof - 1.0.4-3 - Initial Fedora checkin - Include an AUTHORS and license file in each package - Change the library package name to pacemaker-libs to be more Fedora compliant - Remove execute permissions from xml related files - Reference the new cluster-glue devel package name - Update the tarball from upstream to version c9120a53a6ae + High: PE: Only prevent migration if the clone dependency is stopping/starting on the target node + High: PE: Bug 2160 - Dont shuffle clones due to colocation + High: PE: New implementation of the resource migration (not stop/start) logic + Medium: Tools: crm_resource - Prevent use-of-NULL by requiring a resource name for the -A and -a options + Medium: PE: Prevent use-of-NULL in find_first_action() * Tue Jul 14 2009 Andrew Beekhof - 1.0.4-2 - Reference authors from the project AUTHORS file instead of listing in description - Change Source0 to reference the Mercurial repo - Cleaned up the summaries and descriptions - Incorporate the results of Fedora package self-review * Thu Jun 04 2009 Andrew Beekhof - 1.0.4-1 - Update source tarball to revision: 1d87d3e0fc7f (stable-1.0) - Statistics: Changesets: 209 Diff: 266 files changed, 12010 insertions(+), 8276 deletions(-) - Changes since Pacemaker-1.0.3 + High (bnc#488291): ais: do not rely on byte endianness on ptr cast + High (bnc#507255): Tools: crm: delete rsc/op_defaults (these meta_attributes are killing me) + High (bnc#507255): Tools: crm: import properly rsc/op_defaults + High (LF 2114): Tools: crm: add support for operation instance attributes + High: ais: Bug lf#2126 - Messages replies cannot be routed to transient clients + High: ais: Fix compilation for the latest Corosync API (v1719) + High: attrd: Do not perform all updates as complete refreshes + High: cib: Fix huge memory leak affecting heartbeat-based clusters + High: Core: Allow xpath queries to match attributes + High: Core: Generate the help text directly from a tool options struct + High: Core: Handle differences in 0.6 messaging format + High: crmd: Bug lf#2120 - All transient node attribute updates need to go via attrd + High: crmd: Correctly calculate how long an FSA action took to avoid spamming the logs with errors + High: crmd: Fix another large memory leak affecting Heartbeat based clusters + High: lha: Restore compatability with older versions + High: PE: Bug bnc#495687 - Filesystem is not notified of successful STONITH under some conditions + High: PE: Make running a cluster with STONITH enabled but no STONITH resources an error and provide details on resolutions + High: PE: Prevent use-ofNULL when using resource ordering sets + High: PE: Provide inter-notification ordering guarantees + High: PE: Rewrite the notification code to be understanable and extendable + High: Tools: attrd - Prevent race condition resulting in the cluster forgetting the node wishes to shut down + High: Tools: crm: regression tests + High: Tools: crm_mon - Fix smtp notifications + High: Tools: crm_resource - Repair the ability to query meta attributes + Low Build: Bug lf#2105 - Debian package should contain pacemaker doc and crm templates + Medium (bnc#507255): Tools: crm: handle empty rsc/op_defaults properly + Medium (bnc#507255): Tools: crm: use the right obj_type when creating objects from xml nodes + Medium (LF 2107): Tools: crm: revisit exit codes in configure + Medium: cib: Do not bother validating updates that only affect the status section + Medium: Core: Include supported stacks in version information + Medium: crmd: Record in the CIB, the cluster infrastructure being used + Medium: cts: Do not combine crm_standby arguments - the wrapper ca not process them + Medium: cts: Fix the CIBAusdit class + Medium: Extra: Refresh showscores script from Dominik + Medium: PE: Build a statically linked version of ptest + Medium: PE: Correctly log the actions for resources that are being recovered + Medium: PE: Correctly log the occurance of promotion events + Medium: PE: Implememt node health based on a patch from Mark Hamzy + Medium: Tools: Add examples to help text outputs + Medium: Tools: crm: catch syntax errors for configure load + Medium: Tools: crm: implement erasing nodes in configure erase + Medium: Tools: crm: work with parents only when managing xml objects + Medium: Tools: crm_mon - Add option to run custom notification program on resource operations (Patch by Dominik Klein) + Medium: Tools: crm_resource - Allow --cleanup to function on complex resources and cluster-wide + Medium: Tools: haresource2cib.py - Patch from horms to fix conversion error + Medium: Tools: Include stack information in crm_mon output + Medium: Tools: Two new options (--stack,--constraints) to crm_resource for querying how a resource is configured * Wed Apr 08 2009 Andrew Beekhof - 1.0.3-1 - Update source tarball to revision: b133b3f19797 (stable-1.0) tip - Statistics: Changesets: 383 Diff: 329 files changed, 15471 insertions(+), 15119 deletions(-) - Changes since Pacemaker-1.0.2 + Added tag SLE11-HAE-GMC for changeset 9196be9830c2 + High: ais plugin: Fix quorum calculation (bnc#487003) + High: ais: Another memory fix leak in error path + High: ais: Bug bnc#482847, bnc#482905 - Force a clean exit of OpenAIS once Pacemaker has finished unloading + High: ais: Bug bnc#486858 - Fix update_member() to prevent spamming clients with membership events containing no changes + High: ais: Centralize all quorum calculations in the ais plugin and allow expected votes to be configured int he cib + High: ais: Correctly handle a return value of zero from openais_dispatch_recv() + High: ais: Disable logging to a file + High: ais: Fix memory leak in error path + High: ais: IPC messages are only in scope until a response is sent + High: All signal handlers used with CL_SIGNAL() need to be as minimal as possible + High: cib: Bug bnc#482885 - Simplify CIB disk-writes to prevent data loss. Required a change to the backup filename format + High: cib: crmd: Revert part of 9782ab035003. Complex shutdown routines need G_main_add_SignalHandler to avoid race coditions + High: crm: Avoid infinite loop during crm configure edit (bnc#480327) + High: crmd: Avoid a race condition by waiting for the attrd update to trigger a transition automatically + High: crmd: Bug bnc#480977 - Prevent extra, partial, shutdown when a node restarts too quickly + High: crmd: Bug bnc#480977 - Prevent extra, partial, shutdown when a node restarts too quickly (verified) + High: crmd: Bug bnc#489063 - Ensure the DC is always unset after we 'loose' an election + High: crmd: Bug BSC#479543 - Correctly find the migration source for timed out migrate_from actions + High: crmd: Call crm_peer_init() before we start the FSA - prevents a race condition when used with Heartbeat + High: crmd: Erasing the status section should not be forced to the local node + High: crmd: Fix memory leak in cib notication processing code + High: crmd: Fix memory leak in transition graph processing + High: crmd: Fix memory leaks found by valgrind + High: crmd: More memory leaks fixes found by valgrind + High: fencing: stonithd: is_heartbeat_cluster is a no-no if there is no heartbeat support + High: PE: Bug bnc#466788 - Exclude nodes that can not run resources + High: PE: Bug bnc#466788 - Make colocation based on node attributes work + High: PE: Bug BNC#478687 - Do not crash when clone-max is 0 + High: PE: Bug bnc#488721 - Fix id-ref expansion for clones, the doc-root for clone children is not the cib root + High: PE: Bug bnc#490418 - Correctly determine node state for nodes wishing to be terminated + High: PE: Bug LF#2087 - Correctly parse the state of anonymous clones that have multiple instances on a given node + High: PE: Bug lf#2089 - Meta attributes are not inherited by clone children + High: PE: Bug lf#2091 - Correctly restart modified resources that were found active by a probe + High: PE: Bug lf#2094 - Fix probe ordering for cloned groups + High: PE: Bug LF:2075 - Fix large pingd memory leaks + High: PE: Correctly attach orphaned clone children to their parent + High: PE: Correctly handle terminate node attributes that are set to the output from time() + High: PE: Ensure orphaned clone members are hooked up to the parent when clone-max=0 + High: PE: Fix memory leak in LogActions + High: PE: Fix the determination of whether a group is active + High: PE: Look up the correct promotion preference for anonymous masters + High: PE: Simplify handling of start failures by changing the default migration-threshold to INFINITY + High: PE: The ordered option for clones no longer causes extra start/stop operations + High: RA: Bug bnc#490641 - Shut down dlm_controld with -TERM instead of -KILL + High: RA: pingd: Set default ping interval to 1 instead of 0 seconds + High: Resources: pingd - Correctly tell the ping daemon to shut down + High: Tools: Bug bnc#483365 - Ensure the command from cluster_test includes a value for --log-facility + High: Tools: cli: fix and improve delete command + High: Tools: crm: add and implement templates + High: Tools: crm: add support for command aliases and some common commands (i.e. cd,exit) + High: Tools: crm: create top configuration nodes if they are missing + High: Tools: crm: fix parsing attributes for rules (broken by the previous changeset) + High: Tools: crm: new ra set of commands + High: Tools: crm: resource agents information management + High: Tools: crm: rsc/op_defaults + High: Tools: crm: support for no value attribute in nvpairs + High: Tools: crm: the new configure monitor command + High: Tools: crm: the new configure node command + High: Tools: crm_mon - Prevent use-of-NULL when summarizing an orphan + High: Tools: hb2openais: create clvmd clone for respawn evmsd in ha.cf + High: Tools: hb2openais: fix a serious recursion bug in xml node processing + High: Tools: hb2openais: fix ocfs2 processing + High: Tools: pingd - prevent double free of getaddrinfo() output in error path + High: Tools: The default re-ping interval for pingd should be 1s not 1ms + Medium (bnc#479049): Tools: crm: add validation of resource type for the configure primitive command + Medium (bnc#479050): Tools: crm: add help for RA parameters in tab completion + Medium (bnc#479050): Tools: crm: add tab completion for primitive params/meta/op + Medium (bnc#479050): Tools: crm: reimplement cluster properties completion + Medium (bnc#486968): Tools: crm: listnodes function requires no parameters (do not mix completion with other stuff) + Medium: ais: Remove the ugly hack for dampening AIS membership changes + Medium: cib: Fix memory leaks by using mainloop_add_signal + Medium: cib: Move more logging to the debug level (was info) + Medium: cib: Overhaul the processing of synchronous replies + Medium: Core: Add library functions for instructing the cluster to terminate nodes + Medium: crmd: Add new expected-quorum-votes option + Medium: crmd: Allow up to 5 retires when an attrd update fails + Medium: crmd: Automatically detect and use new values for crm_config options + Medium: crmd: Bug bnc#490426 - Escalated shutdowns stall when there are pending resource operations + Medium: crmd: Clean up and optimize the DC election algorithm + Medium: crmd: Fix memory leak in shutdown + Medium: crmd: Fix memory leaks spotted by Valgrind + Medium: crmd: Ingore join messages from hosts other than our DC + Medium: crmd: Limit the scope of resource updates to the status section + Medium: crmd: Prevent the crmd from being respawned if its told to shut down when it did not ask to be + Medium: crmd: Re-check the election status after membership events + Medium: crmd: Send resource updates via the local CIB during elections + Medium: PE: Bug bnc#491441 - crm_mon does not display operations returning 'uninstalled' correctly + Medium: PE: Bug lf#2101 - For location constraints, role=Slave is equivalent to role=Started + Medium: PE: Clean up the API - removed ->children() and renamed ->find_child() to fine_rsc() + Medium: PE: Compress the display of healthy anonymous clones + Medium: PE: Correctly log the actions for resources that are being recovered + Medium: PE: Determin a promotion score for complex resources + Medium: PE: Ensure clones always have a value for globally-unique + Medium: PE: Prevent orphan clones from being allocated + Medium: RA: controld: Return proper exit code for stop op. + Medium: Tools: Bug bnc#482558 - Fix logging test in cluster_test + Medium: Tools: Bug bnc#482828 - Fix quoting in cluster_test logging setup + Medium: Tools: Bug bnc#482840 - Include directory path to CTSlab.py + Medium: Tools: crm: add more user input checks + Medium: Tools: crm: do not check resource status of we are working with a shadow + Medium: Tools: crm: fix id-refs and allow reference to top objects (i.e. primitive) + Medium: Tools: crm: ignore comments in the CIB + Medium: Tools: crm: multiple column output would not work with small lists + Medium: Tools: crm: refuse to delete running resources + Medium: Tools: crm: rudimentary if-else for templates + Medium: Tools: crm: Start/stop clones via target-role. + Medium: Tools: crm_mon - Compress the node status for healthy and offline nodes + Medium: Tools: crm_shadow - Return 0/cib_ok when --create-empty succeeds + Medium: Tools: crm_shadow - Support -e, the short form of --create-empty + Medium: Tools: Make attrd quieter + Medium: Tools: pingd - Avoid using various clplumbing functions as they seem to leak + Medium: Tools: Reduce pingd logging * Mon Feb 16 2009 Andrew Beekhof - 1.0.2-1 - Update source tarball to revision: d232d19daeb9 (stable-1.0) tip - Statistics: Changesets: 441 Diff: 639 files changed, 20871 insertions(+), 21594 deletions(-) - Changes since Pacemaker-1.0.1 + High (bnc#450815): Tools: crm cli: do not generate id for the operations tag + High: ais: Add support for the new AIS IPC layer + High: ais: Always set header.error to the correct default: SA_AIS_OK + High: ais: Bug BNC#456243 - Ensure the membership cache always contains an entry for the local node + High: ais: Bug BNC:456208 - Prevent deadlocks by not logging in the child process before exec() + High: ais: By default, disable supprt for the WIP openais IPC patch + High: ais: Detect and handle situations where ais and the crm disagree on the node name + High: ais: Ensure crm_peer_seq is updated after a membership update + High: ais: Make sure all IPC header fields are set to sane defaults + High: ais: Repair and streamline service load now that whitetank startup functions correctly + High: build: create and install doc files + High: cib: Allow clients without mainloop to connect to the cib + High: cib: CID:18 - Fix use-of-NULL in cib_perform_op + High: cib: CID:18 - Repair errors introduced in b5a18704477b - Fix use-of-NULL in cib_perform_op + High: cib: Ensure diffs contain the correct values of admin_epoch + High: cib: Fix four moderately sized memory leaks detected by Valgrind + High: Core: CID:10 - Prevent indexing into an array of schemas with a negative value + High: Core: CID:13 - Fix memory leak in log_data_element + High: Core: CID:15 - Fix memory leak in crm_get_peer + High: Core: CID:6 - Fix use-of-NULL in copy_ha_msg_input + High: Core: Fix crash in the membership code preventing node shutdown + High: Core: Fix more memory leaks foudn by valgrind + High: Core: Prevent unterminated strings after decompression + High: crmd: Bug BNC:467995 - Delay marking STONITH operations complete until STONITH tells us so + High: crmd: Bug LF:1962 - Do not NACK peers because they are not (yet) in our membership. Just ignore them. + High: crmd: Bug LF:2010 - Ensure fencing cib updates create the node_state entry if needed to preent re-fencing during cluster startup + High: crmd: Correctly handle reconnections to attrd + High: crmd: Ensure updates for lost migrate operations indicate which node it tried to migrating to + High: crmd: If there are no nodes to finalize, start an election. + High: crmd: If there are no nodes to welcome, start an election. + High: crmd: Prevent node attribute loss by detecting attrd disconnections immediately + High: crmd: Prevent node re-probe loops by ensuring manditory actions always complete + High: PE: Bug 2005 - Fix startup ordering of cloned stonith groups + High: PE: Bug 2006 - Correctly reprobe cloned groups + High: PE: Bug BNC:465484 - Fix the no-quorum-policy=suicide option + High: PE: Bug LF:1996 - Correctly process disabled monitor operations + High: PE: CID:19 - Fix use-of-NULL in determine_online_status + High: PE: Clones now default to globally-unique=false + High: PE: Correctly calculate the number of available nodes for the clone to use + High: PE: Only shoot online nodes with no-quorum-policy=suicide + High: PE: Prevent on-fail settings being ignored after a resource is successfully stopped + High: PE: Prevent use-of-NULL for failed migrate actions in process_rsc_state() + High: PE: Remove an optimization for the terminate node attribute that caused the cluster to block indefinitly + High: PE: Repar the ability to colocate based on node attributes other than uname + High: PE: Start the correct monitor operation for unmanaged masters + High: stonith: CID:3 - Fix another case of exceptionally poor error handling by the original stonith developers + High: stonith: CID:5 - Checking for NULL and then dereferencing it anyway is an interesting approach to error handling + High: stonithd: Sending IPC to the cluster is a privileged operation + High: stonithd: wrong checks for shmid (0 is a valid id) + High: Tools: attrd - Correctly determine when an attribute has stopped changing and should be committed to the CIB + High: Tools: Bug 2003 - pingd does not correctly detect failures when the interface is down + High: Tools: Bug 2003 - pingd does not correctly handle node-down events on multi-NIC systems + High: Tools: Bug 2021 - pingd does not detect sequence wrapping correctly, incorrectly reports nodes offline + High: Tools: Bug BNC:468066 - Do not use the result of uname() when its no longer in scope + High: Tools: Bug BNC:473265 - crm_resource -L dumps core + High: Tools: Bug LF:2001 - Transient node attributes should be set via attrd + High: Tools: Bug LF:2036 - crm_resource cannot set/get parameters for cloned resources + High: Tools: Bug LF:2046 - Node attribute updates are lost because attrd can take too long to start + High: Tools: Cause the correct clone instance to be failed with crm_resource -F + High: Tools: cluster_test - Allow the user to select a stack and fix CTS invocation + High: Tools: crm cli: allow rename only if the resource is stopped + High: Tools: crm cli: catch system errors on file operations + High: Tools: crm cli: completion for ids in configure + High: Tools: crm cli: drop '-rsc' from attributes for order constraint + High: Tools: crm cli: exit with an appropriate exit code + High: Tools: crm cli: fix wrong order of action and resource in order constraint + High: Tools: crm cli: fox wrong exit code + High: Tools: crm cli: improve handling of cib attributes + High: Tools: crm cli: new command: configure rename + High: Tools: crm cli: new command: configure upgrade + High: Tools: crm cli: new command: node delete + High: Tools: crm cli: prevent key errors on missing cib attributes + High: Tools: crm cli: print long help for help topics + High: Tools: crm cli: return on syntax error when parsing score + High: Tools: crm cli: rsc_location can be without nvpairs + High: Tools: crm cli: short node preference location constraint + High: Tools: crm cli: sometimes, on errors, level would change on single shot use + High: Tools: crm cli: syntax: drop a bunch of commas (remains of help tables conversion) + High: Tools: crm cli: verify user input for sanity + High: Tools: crm: find expressions within rules (do not always skip xml nodes due to used id) + High: Tools: crm_master should not define a set id now that attrd is used. Defining one can break lookups + High: Tools: crm_mon Use the OID assigned to the project by IANA for SNMP traps + Medium (bnc#445622): Tools: crm cli: improve the node show command and drop node status + Medium (LF 2009): stonithd: improve timeouts for remote fencing + Medium: ais: Allow dead peers to be removed from membership calculations + Medium: ais: Pass node deletion events on to clients + Medium: ais: Sanitize ipc usage + Medium: ais: Supply the node uname in addtion to the id + Medium: Build: Clean up configure to ensure NON_FATAL_CFLAGS is consistent with CFLAGS (ie. includes -g) + Medium: Build: Install cluster_test + Medium: Build: Use more restrictive CFLAGS and fix the resulting errors + Medium: cib: CID:20 - Fix potential use-after-free in cib_native_signon + Medium: Core: Bug BNC:474727 - Set a maximum time to wait for IPC messages + Medium: Core: CID:12 - Fix memory leak in decode_transition_magic error path + Medium: Core: CID:14 - Fix memory leak in calculate_xml_digest error path + Medium: Core: CID:16 - Fix memory leak in date_to_string error path + Medium: Core: Try to track down the cause of XML parsing errors + Medium: crmd: Bug BNC:472473 - Do not wait excessive amounts of time for lost actions + Medium: crmd: Bug BNC:472473 - Reduce the transition timeout to action_timeout+network_delay + Medium: crmd: Do not fast-track the processing of LRM refreshes when there are pending actions. + Medium: crmd: do_dc_join_filter_offer - Check the 'join' message is for the current instance before deciding to NACK peers + Medium: crmd: Find option values without having to do a config upgrade + Medium: crmd: Implement shutdown using a transient node attribute + Medium: crmd: Update the crmd options to use dashes instead of underscores + Medium: cts: Add 'cluster reattach' to the suite of automated regression tests + Medium: cts: cluster_test - Make some usability enhancements + Medium: CTS: cluster_test - suggest a valid port number + Medium: CTS: Fix python import order + Medium: cts: Implement an automated SplitBrain test + Medium: CTS: Remove references to deleted classes + Medium: Extra: Resources - Use HA_VARRUN instead of HA_RSCTMP for state files as Heartbeat removes HA_RSCTMP at startup + Medium: HB: Bug 1933 - Fake crmd_client_status_callback() calls because HB does not provide them for already running processes + Medium: PE: CID:17 - Fix memory leak in find_actions_by_task error path + Medium: PE: CID:7,8 - Prevent hypothetical use-of-NULL in LogActions + Medium: PE: Defer logging the actions performed on a resource until we have processed ordering constraints + Medium: PE: Remove the symmetrical attribute of colocation constraints + Medium: Resources: pingd - fix the meta defaults + Medium: Resources: Stateful - Add missing meta defaults + Medium: stonithd: exit if we the pid file cannot be locked + Medium: Tools: Allow attrd clients to specify the ID the attribute should be created with + Medium: Tools: attrd - Allow attribute updates to be performed from a hosts peer + Medium: Tools: Bug LF:1994 - Clean up crm_verify return codes + Medium: Tools: Change the pingd defaults to ping hosts once every second (instead of 5 times every 10 seconds) + Medium: Tools: cibmin - Detect resource operations with a view to providing email/snmp/cim notification + Medium: Tools: crm cli: add back symmetrical for order constraints + Medium: Tools: crm cli: generate role in location when converting from xml + Medium: Tools: crm cli: handle shlex exceptions + Medium: Tools: crm cli: keep order of help topics + Medium: Tools: crm cli: refine completion for ids in configure + Medium: Tools: crm cli: replace inf with INFINITY + Medium: Tools: crm cli: streamline cib load and parsing + Medium: Tools: crm cli: supply provider only for ocf class primitives + Medium: Tools: crm_mon - Add support for sending mail notifications of resource events + Medium: Tools: crm_mon - Include the DC version in status summary + Medium: Tools: crm_mon - Sanitize startup and option processing + Medium: Tools: crm_mon - switch to event-driven updates and add support for sending snmp traps + Medium: Tools: crm_shadow - Replace the --locate option with the saner --edit + Medium: Tools: hb2openais: do not remove Evmsd resources, but replace them with clvmd + Medium: Tools: hb2openais: replace crmadmin with crm_mon + Medium: Tools: hb2openais: replace the lsb class with ocf for o2cb + Medium: Tools: hb2openais: reuse code + Medium: Tools: LF:2029 - Display an error if crm_resource is used to reset the operation history of non-primitive resources + Medium: Tools: Make pingd resilient to attrd failures + Medium: Tools: pingd - fix the command line switches + Medium: Tools: Rename ccm_tool to crm_node * Tue Nov 18 2008 Andrew Beekhof - 1.0.1-1 - Update source tarball to revision: 6fc5ce8302ab (stable-1.0) tip - Statistics: Changesets: 170 Diff: 816 files changed, 7633 insertions(+), 6286 deletions(-) - Changes since Pacemaker-1.0.1 + High: ais: Allow the crmd to get callbacks whenever a node state changes + High: ais: Create an option for starting the mgmtd daemon automatically + High: ais: Ensure HA_RSCTMP exists for use by resource agents + High: ais: Hook up the openais.conf config logging options + High: ais: Zero out the PID of disconnecting clients + High: cib: Ensure global updates cause a disk write when appropriate + High: Core: Add an extra snaity check to getXpathResults() to prevent segfaults + High: Core: Do not redefine __FUNCTION__ unnecessarily + High: Core: Repair the ability to have comments in the configuration + High: crmd: Bug:1975 - crmd should wait indefinitely for stonith operations to complete + High: crmd: Ensure PE processing does not occur for all error cases in do_pe_invoke_callback + High: crmd: Requests to the CIB should cause any prior PE calculations to be ignored + High: heartbeat: Wait for membership 'up' events before removing stale node status data + High: PE: Bug LF:1988 - Ensure recurring operations always have the correct target-rc set + High: PE: Bug LF:1988 - For unmanaged resources we need to skip the usual can_run_resources() checks + High: PE: Ensure the terminate node attribute is handled correctly + High: PE: Fix optional colocation + High: PE: Improve up the detection of 'new' nodes joining the cluster + High: PE: Prevent assert failures in master_color() by ensuring unmanaged masters are always reallocated to their current location + High: Tools: crm cli: parser: return False on syntax error and None for comments + High: Tools: crm cli: unify template and edit commands + High: Tools: crm_shadow - Show more line number information after validation failures + High: Tools: hb2openais: add option to upgrade the CIB to v3.0 + High: Tools: hb2openais: add U option to getopts and update usage + High: Tools: hb2openais: backup improved and multiple fixes + High: Tools: hb2openais: fix class/provider reversal + High: Tools: hb2openais: fix testing + High: Tools: hb2openais: move the CIB update to the end + High: Tools: hb2openais: update logging and set logfile appropriately + High: Tools: LF:1969 - Attrd never sets any properties in the cib + High: Tools: Make attrd functional on OpenAIS + Medium: ais: Hook up the options for specifying the expected number of nodes and total quorum votes + Medium: ais: Look for pacemaker options inside the service block with 'name: pacemaker' instead of creating an addtional configuration block + Medium: ais: Provide better feedback when nodes change nodeids (in openais.conf) + Medium: cib: Always store cib contents on disk with num_updates=0 + Medium: cib: Ensure remote access ports are cleaned up on shutdown + Medium: crmd: Detect deleted resource operations automatically + Medium: crmd: Erase a nodes resource operations and transient attributes after a successful STONITH + Medium: crmd: Find a more appropriate place to update quorum and refresh attrd attributes + Medium: crmd: Fix the handling of unexpected PE exits to ensure the current CIB is stored + Medium: crmd: Fix the recording of pending operations in the CIB + Medium: crmd: Initiate an attrd refresh _after_ the status section has been fully repopulated + Medium: crmd: Only the DC should update quorum in an openais cluster + Medium: Ensure meta attributes are used consistantly + Medium: PE: Allow group and clone level resource attributes + Medium: PE: Bug N:437719 - Ensure scores from colocated resources count when allocating groups + Medium: PE: Prevent lsb scripts from being used in globally unique clones + Medium: PE: Make a best-effort guess at a migration threshold for people with 0.6 configs + Medium: Resources: controld - ensure we are part of a clone with globally_unique=false + Medium: Tools: attrd - Automatically refresh all attributes after a CIB replace operation + Medium: Tools: Bug LF:1985 - crm_mon - Correctly process failed cib queries to allow reconnection after cluster restarts + Medium: Tools: Bug LF:1987 - crm_verify incorrectly warns of configuration upgrades for the most recent version + Medium: Tools: crm (bnc#441028): check for key error in attributes management + Medium: Tools: crm_mon - display the meaning of the operation rc code instead of the status + Medium: Tools: crm_mon - Fix the display of timing data + Medium: Tools: crm_verify - check that we are being asked to validate a complete config + Medium: xml: Relax the restriction on the contents of rsc_locaiton.node * Thu Oct 16 2008 Andrew Beekhof - 1.0.0-1 - Update source tarball to revision: 388654dfef8f tip - Statistics: Changesets: 261 Diff: 3021 files changed, 244985 insertions(+), 111596 deletions(-) - Changes since f805e1b30103 + High: add the crm cli program + High: ais: Move the service id definition to a common location and make sure it is always used + High: build: rename hb2openais.sh to .in and replace paths with vars + High: cib: Implement --create for crm_shadow + High: cib: Remove dead files + High: Core: Allow the expected number of quorum votes to be configrable + High: Core: cl_malloc and friends were removed from Heartbeat + High: Core: Only call xmlCleanupParser() if we parsed anything. Doing so unconditionally seems to cause a segfault + High: hb2openais.sh: improve pingd handling; several bugs fixed + High: hb2openais: fix clone creation; replace EVMS strings + High: new hb2openais.sh conversion script + High: PE: Bug LF:1950 - Ensure the current values for all notification variables are always set (even if empty) + High: PE: Bug LF:1955 - Ensure unmanaged masters are unconditionally repromoted to ensure they are monitored correctly. + High: PE: Bug LF:1955 - Fix another case of filtering causing unmanaged master failures + High: PE: Bug LF:1955 - Umanaged mode prevents master resources from being allocated correctly + High: PE: Bug N:420538 - Anit-colocation caused a positive node preference + High: PE: Correctly handle unmanaged resources to prevent them from being started elsewhere + High: PE: crm_resource - Fix the --migrate command + High: PE: MAke stonith-enabled default to true and warn if no STONITH resources are found + High: PE: Make sure orphaned clone children are created correctly + High: PE: Monitors for unmanaged resources do not need to wait for start/promote/demote actions to complete + High: stonithd (LF 1951): fix remote stonith operations + High: stonithd: fix handling of timeouts + High: stonithd: fix logic for stonith resource priorities + High: stonithd: implement the fence-timeout instance attribute + High: stonithd: initialize value before reading fence-timeout + High: stonithd: set timeouts for fencing ops to the timeout of the start op + High: stonithd: stonith rsc priorities (new feature) + High: Tools: Add hb2openais - a tool for upgrading a Heartbeat cluster to use OpenAIS instead + High: Tools: crm_verify - clean up the upgrade logic to prevent crash on invalid configurations + High: Tools: Make pingd functional on Linux + High: Update version numbers for 1.0 candidates + Medium: ais: Add support for a synchronous call to retrieve the nodes nodeid + Medium: ais: Use the agreed service number + Medium: Build: Reliably detect heartbeat libraries during configure + Medium: Build: Supply prototypes for libreplace functions when needed + Medium: Build: Teach configure how to find corosync + Medium: Core: Provide better feedback if Pacemaker is started by a stack it does not support + Medium: crmd: Avoid calling GHashTable functions with NULL + Medium: crmd: Delay raising I_ERROR when the PE exits until we have had a chance to save the current CIB + Medium: crmd: Hook up the stonith-timeout option to stonithd + Medium: crmd: Prevent potential use-of-NULL in global_timer_callback + Medium: crmd: Rationalize the logging of graph aborts + Medium: PE: Add a stonith_timeout option and remove new options that are better set in rsc_defaults + Medium: PE: Allow external entities to ask for a node to be shot by creating a terminate=true transient node attribute + Medium: PE: Bug LF:1950 - Notifications do not contain all documented resource state fields + Medium: PE: Bug N:417585 - Do not restart group children whos individual score drops below zero + Medium: PE: Detect clients that disconnect before receiving their reply + Medium: PE: Implement a true maintenance mode + Medium: PE: Implement on-fail=standby for NTT. Derived from a patch by Satomi TANIGUCHI + Medium: PE: Print the correct message when stonith is disabled + Medium: PE: ptest - check the input is valid before proceeding + Medium: PE: Revert group stickiness to the 'old way' + Medium: PE: Use the correct attribute for action 'requires' (was prereq) + Medium: stonithd: Fix compilation without full heartbeat install + Medium: stonithd: exit with better code on empty host list + Medium: tools: Add a new regression test for CLI tools + Medium: tools: crm_resource - return with non-zero when a resource migration command is invalid + Medium: tools: crm_shadow - Allow the admin to start with an empty CIB (and no cluster connection) + Medium: xml: pacemaker-0.7 is now an alias for the 1.0 schema * Mon Sep 22 2008 Andrew Beekhof - 0.7.3-1 - Update source tarball to revision: 33e677ab7764+ tip - Statistics: Changesets: 133 Diff: 89 files changed, 7492 insertions(+), 1125 deletions(-) - Changes since f805e1b30103 + High: Tools: add the crm cli program + High: Core: cl_malloc and friends were removed from Heartbeat + High: Core: Only call xmlCleanupParser() if we parsed anything. Doing so unconditionally seems to cause a segfault + High: new hb2openais.sh conversion script + High: PE: Bug LF:1950 - Ensure the current values for all notification variables are always set (even if empty) + High: PE: Bug LF:1955 - Ensure unmanaged masters are unconditionally repromoted to ensure they are monitored correctly. + High: PE: Bug LF:1955 - Fix another case of filtering causing unmanaged master failures + High: PE: Bug LF:1955 - Umanaged mode prevents master resources from being allocated correctly + High: PE: Bug N:420538 - Anit-colocation caused a positive node preference + High: PE: Correctly handle unmanaged resources to prevent them from being started elsewhere + High: PE: crm_resource - Fix the --migrate command + High: PE: MAke stonith-enabled default to true and warn if no STONITH resources are found + High: PE: Make sure orphaned clone children are created correctly + High: PE: Monitors for unmanaged resources do not need to wait for start/promote/demote actions to complete + High: stonithd (LF 1951): fix remote stonith operations + High: Tools: crm_verify - clean up the upgrade logic to prevent crash on invalid configurations + Medium: ais: Add support for a synchronous call to retrieve the nodes nodeid + Medium: ais: Use the agreed service number + Medium: PE: Allow external entities to ask for a node to be shot by creating a terminate=true transient node attribute + Medium: PE: Bug LF:1950 - Notifications do not contain all documented resource state fields + Medium: PE: Bug N:417585 - Do not restart group children whos individual score drops below zero + Medium: PE: Implement a true maintenance mode + Medium: PE: Print the correct message when stonith is disabled + Medium: stonithd: exit with better code on empty host list + Medium: xml: pacemaker-0.7 is now an alias for the 1.0 schema * Wed Aug 20 2008 Andrew Beekhof - 0.7.1-1 - Update source tarball to revision: f805e1b30103+ tip - Statistics: Changesets: 184 Diff: 513 files changed, 43408 insertions(+), 43783 deletions(-) - Changes since 0.7.0-19 + Fix compilation when GNUTLS isnt found + High: admin: Fix use-after-free in crm_mon + High: Build: Remove testing code that prevented heartbeat-only builds + High: cib: Use single quotes so that the xpath queries for nvpairs will succeed + High: crmd: Always connect to stonithd when the TE starts and ensure we notice if it dies + High: crmd: Correctly handle a dead PE process + High: crmd: Make sure async-failures cause the failcount to be incrimented + High: PE: Bug LF:1941 - Handle failed clone instance probes when clone-max < #nodes + High: PE: Parse resource ordering sets correctly + High: PE: Prevent use-of-NULL - order->rsc_rh will not always be non-NULL + High: PE: Unpack colocation sets correctly + High: Tools: crm_mon - Prevent use-of-NULL for orphaned resources + Medium: ais: Add support for a synchronous call to retrieve the nodes nodeid + Medium: ais: Allow transient clients to receive membership updates + Medium: ais: Avoid double-free in error path + Medium: ais: Include in the mebership nodes for which we have not determined their hostname + Medium: ais: Spawn the PE from the ais plugin instead of the crmd + Medium: cib: By default, new configurations use the latest schema + Medium: cib: Clean up the CIB if it was already disconnected + Medium: cib: Only incriment num_updates if something actually changed + Medium: cib: Prevent use-after-free in client after abnormal termination of the CIB + Medium: Core: Fix memory leak in xpath searches + Medium: Core: Get more details regarding parser errors + Medium: Core: Repair expand_plus_plus - do not call char2score on unexpanded values + Medium: Core: Switch to the libxml2 parser - its significantly faster + Medium: Core: Use a libxml2 library function for xml -> text conversion + Medium: crmd: Asynchronous failure actions have no parameters + Medium: crmd: Avoid calling glib functions with NULL + Medium: crmd: Do not allow an election to promote a node from S_STARTING + Medium: crmd: Do not vote if we have not completed the local startup + Medium: crmd: Fix te_update_diff() now that get_object_root() functions differently + Medium: crmd: Fix the lrmd xpath expressions to not contain quotes + Medium: crmd: If we get a join offer during an election, better restart the election + Medium: crmd: No further processing is needed when using the LRMs API call for failing resources + Medium: crmd: Only update have-quorum if the value changed + Medium: crmd: Repair the input validation logic in do_te_invoke + Medium: cts: CIBs can no longer contain comments + Medium: cts: Enable a bunch of tests that were incorrectly disabled + Medium: cts: The libxml2 parser wont allow v1 resources to use integers as parameter names + Medium: Do not use the cluster UID and GID directly. Look them up based on the configured value of HA_CCMUSER + Medium: Fix compilation when heartbeat is not supported + Medium: PE: Allow groups to be involved in optional ordering constraints + Medium: PE: Allow sets of operations to be reused by multiple resources + Medium: PE: Bug LF:1941 - Mark extra clone instances as orphans and do not show inactive ones + Medium: PE: Determin the correct migration-threshold during resource expansion + Medium: PE: Implement no-quorum-policy=suicide (FATE #303619) + Medium: pengine: Clean up resources after stopping old copies of the PE + Medium: pengine: Teach the PE how to stop old copies of itself + Medium: Tools: Backport hb_report updates + Medium: Tools: cib_shadow - On create, spawn a new shell with CIB_shadow and PS1 set accordingly + Medium: Tools: Rename cib_shadow to crm_shadow * Fri Jul 18 2008 Andrew Beekhof - 0.7.0-19 - Update source tarball to revision: 007c3a1c50f5 (unstable) tip - Statistics: Changesets: 108 Diff: 216 files changed, 4632 insertions(+), 4173 deletions(-) - Changes added since unstable-0.7 + High: admin: Fix use-after-free in crm_mon + High: ais: Change the tag for the ais plugin to "pacemaker" (used in openais.conf) + High: ais: Log terminated processes as an error + High: cib: Performance - Reorganize things to avoid calculating the XML diff twice + High: PE: Bug LF:1941 - Handle failed clone instance probes when clone-max < #nodes + High: PE: Fix memory leak in action2xml + High: PE: Make OCF_ERR_ARGS a node-level error rather than a cluster-level one + High: PE: Properly handle clones that are not installed on all nodes + Medium: admin: cibadmin - Show any validation errors if the upgrade failed + Medium: admin: cib_shadow - Implement --locate to display the underlying filename + Medium: admin: cib_shadow - Implement a --diff option + Medium: admin: cib_shadow - Implement a --switch option + Medium: admin: crm_resource - create more compact constraints that do not use lifetime (which is deprecated) + Medium: ais: Approximate born_on for OpenAIS based clusters + Medium: cib: Remove do_id_check, it is a poor substitute for ID validation by a schema + Medium: cib: Skip construction of pre-notify messages if no-one wants one + Medium: Core: Attempt to streamline some key functions to increase performance + Medium: Core: Clean up XML parser after validation + Medium: crmd: Detect and optimize the CRMs behavior when processing diffs of an LRM refresh + Medium: Fix memory leaks when resetting the name of an XML object + Medium: PE: Prefer the current location if it is one of a group of nodes with the same (highest) score * Wed Jun 25 2008 Andrew Beekhof - 0.7.0-1 - Update source tarball to revision: bde0c7db74fb tip - Statistics: Changesets: 439 Diff: 676 files changed, 41310 insertions(+), 52071 deletions(-) - Changes added since stable-0.6 + High: A new tool for setting up and invoking CTS + High: Admin: All tools now use --node (-N) for specifying node unames + High: Admin: All tools now use --xml-file (-x) and --xml-text (-X) for specifying where to find XML blobs + High: cib: Cleanup the API - remove redundant input fields + High: cib: Implement CIB_shadow - a facility for making and testing changes before uploading them to the cluster + High: cib: Make registering per-op callbacks an API call and renamed (for clarity) the API call for requesting notifications + High: Core: Add a facility for automatically upgrading old configurations + High: Core: Adopt libxml2 as the XML processing library - all external clients need to be recompiled + High: Core: Allow sending TLS messages larger than the MTU + High: Core: Fix parsing of time-only ISO dates + High: Core: Smarter handling of XML values containing quotes + High: Core: XML memory corruption - catch, and handle, cases where we are overwriting an attribute value with itself + High: Core: The xml ID type does not allow UUIDs that start with a number + High: Core: Implement XPath based versions of query/delete/replace/modify + High: Core: Remove some HA2.0.(3,4) compatability code + High: crmd: Overhaul the detection of nodes that are starting vs. failed + High: PE: Bug LF:1459 - Allow failures to expire + High: PE: Have the PE do non-persistent configuration upgrades before performing calculations + High: PE: Replace failure-stickiness with a simple 'migration-threshold' + High: TE: Simplify the design by folding the tengine process into the crmd + Medium: Admin: Bug LF:1438 - Allow the list of all/active resource operations to be queried by crm_resource + Medium: Admin: Bug LF:1708 - crm_resource should print a warning if an attribute is already set as a meta attribute + Medium: Admin: Bug LF:1883 - crm_mon should display fail-count and operation history + Medium: Admin: Bug LF:1883 - crm_mon should display operation timing data + Medium: Admin: Bug N:371785 - crm_resource -C does not also clean up fail-count attributes + Medium: Admin: crm_mon - include timing data for failed actions + Medium: ais: Read options from the environment since objdb is not completely usable yet + Medium: cib: Add sections for op_defaults and rsc_defaults + Medium: cib: Better matching notification callbacks (for detecting duplicates and removal) + Medium: cib: Bug LF:1348 - Allow rules and attribute sets to be referenced for use in other objects + Medium: cib: BUG LF:1918 - By default, all cib calls now timeout after 30s + Medium: cib: Detect updates that decrease the version tuple + Medium: cib: Implement a client-side operation timeout - Requires LHA update + Medium: cib: Implement callbacks and async notifications for remote connections + Medium: cib: Make cib->cmds->update() an alias for modify at the API level (also implemented in cibadmin) + Medium: cib: Mark the CIB as disconnected if the IPC connection is terminated + Medium: cib: New call option 'cib_can_create' which can be passed to modify actions - allows the object to be created if it does not exist yet + Medium: cib: Reimplement get|set|delete attributes using XPath + Medium: cib: Remove some useless parts of the API + Medium: cib: Remove the 'attributes' scaffolding from the new format + Medium: cib: Implement the ability for clients to connect to remote servers + Medium: Core: Add support for validating xml against RelaxNG schemas + Medium: Core: Allow more than one item to be modified/deleted in XPath based operations + Medium: Core: Fix the sort_pairs function for creating sorted xml objects + Medium: Core: iso8601 - Implement subtract_duration and fix subtract_time + Medium: Core: Reduce the amount of xml copying occuring + Medium: Core: Support value='value+=N' XML updates (in addtion to value='value++') + Medium: crmd: Add support for lrm_ops->fail_rsc if its available + Medium: crmd: HB - watch link status for node leaving events + Medium: crmd: Bug LF:1924 - Improved handling of lrmd disconnects and shutdowns + Medium: crmd: Do not wait for actions with a start_delay over 5 minutes. Confirm them immediately + Medium: PE: Bug LF:1328 - Do not fencing nodes in clusters without managed resources + Medium: PE: Bug LF:1461 - Give transient node attributes (in ) preference over persistent ones (in ) + Medium: PE: Bug LF:1884, Bug LF:1885 - Implement N:M ordering and colocation constraints + Medium: PE: Bug LF:1886 - Create a resource and operation 'defaults' config section + Medium: PE: Bug LF:1892 - Allow recurring actions to be triggered at known times + Medium: PE: Bug LF:1926 - Probes should complete before stop actions are invoked + Medium: PE: Fix the standby when its set as a transient attribute + Medium: PE: Implement a global 'stop-all-resources' option + Medium: PE: Implement cibpipe, a tool for performing/simulating config changes "offline" + Medium: PE: We do not allow colocation with specific clone instances + Medium: Tools: pingd - Implement a stack-independant version of pingd + Medium: xml: Ship an xslt for upgrading from 0.6 to 0.7 * Thu Jun 19 2008 Andrew Beekhof - 0.6.5-1 - Update source tarball to revision: b9fe723d1ac5 tip - Statistics: Changesets: 48 Diff: 37 files changed, 1204 insertions(+), 234 deletions(-) - Changes since Pacemaker-0.6.4 + High: Admin: Repair the ability to delete failcounts + High: ais: Audit IPC handling between the AIS plugin and CRM processes + High: ais: Have the plugin create needed /var/lib directories + High: ais: Make sure the sync and async connections are assigned correctly (not swapped) + High: cib: Correctly detect configuration changes - num_updates does not count + High: PE: Apply stickiness values to the whole group, not the individual resources + High: PE: Bug N:385265 - Ensure groups are migrated instead of remaining partially active on the current node + High: PE: Bug N:396293 - Enforce manditory group restarts due to ordering constraints + High: PE: Correctly recover master instances found active on more than one node + High: PE: Fix memory leaks reported by Valgrind + Medium: Admin: crm_mon - Misc improvements from Satomi Taniguchi + Medium: Bug LF:1900 - Resource stickiness should not allow placement in asynchronous clusters + Medium: crmd: Ensure joins are completed promptly when a node taking part dies + Medium: PE: Avoid clone instance shuffling in more cases + Medium: PE: Bug LF:1906 - Remove an optimization in native_merge_weights() causing group scores to behave eratically + Medium: PE: Make use of target_rc data to correctly process resource operations + Medium: PE: Prevent a possible use of NULL in sort_clone_instance() + Medium: TE: Include target rc in the transition key - used to correctly determin operation failure * Thu May 22 2008 Andrew Beekhof - 0.6.4-1 - Update source tarball to revision: 226d8e356924 tip - Statistics: Changesets: 55 Diff: 199 files changed, 7103 insertions(+), 12378 deletions(-) - Changes since Pacemaker-0.6.3 + High: crmd: Bug LF:1881 LF:1882 - Overhaul the logic for operation cancelation and deletion + High: crmd: Bug LF:1894 - Make sure cancelled recurring operations are cleaned out from the CIB + High: PE: Bug N:387749 - Colocation with clones causes unnecessary clone instance shuffling + High: PE: Ensure 'master' monitor actions are cancelled _before_ we demote the resource + High: PE: Fix assert failure leading to core dump - make sure variable is properly initialized + High: PE: Make sure 'slave' monitoring happens after the resource has been demoted + High: PE: Prevent failure stickiness underflows (where too many failures become a _positive_ preference) + Medium: Admin: crm_mon - Only complain if the output file could not be opened + Medium: Common: filter_action_parameters - enable legacy handling only for older versions + Medium: PE: Bug N:385265 - The failure stickiness of group children is ignored until it reaches -INFINITY + Medium: PE: Implement master and clone colocation by exlcuding nodes rather than setting ones score to INFINITY (similar to cs: 756afc42dc51) + Medium: TE: Bug LF:1875 - Correctly find actions to cancel when their node leaves the cluster * Wed Apr 23 2008 Andrew Beekhof - 0.6.3-1 - Update source tarball to revision: fd8904c9bc67 tip - Statistics: Changesets: 117 Diff: 354 files changed, 19094 insertions(+), 11338 deletions(-) - Changes since Pacemaker-0.6.2 + High: Admin: Bug LF:1848 - crm_resource - Pass set name and id to delete_resource_attr() in the correct order + High: Build: SNMP has been moved to the management/pygui project + High: crmd: Bug LF1837 - Unmanaged resources prevent crmd from shutting down + High: crmd: Prevent use-after-free in lrm interface code (Patch based on work by Keisuke MORI) + High: PE: Allow the cluster to make progress by not retrying failed demote actions + High: PE: Anti-colocation with slave should not prevent master colocation + High: PE: Bug LF 1768 - Wait more often for STONITH ops to complete before starting resources + High: PE: Bug LF1836 - Allow is-managed-default=false to be overridden by individual resources + High: PE: Bug LF185 - Prevent pointless master/slave instance shuffling by ignoring the master-pref of stopped instances + High: PE: Bug N-191176 - Implement interleaved ordering for clone-to-clone scenarios + High: PE: Bug N-347004 - Ensure clone notifications are always sent when an instance is stopped/started + High: PE: Bug N-347004 - Include notification ordering is correct for interleaved clones + High: PE: Bug PM-11 - Directly link probe_complete to starting clone instances + High: PE: Bug PM1 - Fix setting failcounts when applied to complex resources + High: PE: Bug PM12, LF1648 - Extensive revision of group ordering + High: PE: Bug PM7 - Ensure masters are always demoted before they are stopped + High: PE: Create probes after allocation to allow smarter handling of anonymous clones + High: PE: Do not prioritize clone instances that must be moved + High: PE: Fix error in previous commit that allowed more than the required number of masters to be promoted + High: PE: Group start ordering fixes + High: PE: Implement promote/demote ordering for cloned groups + High: TE: Repair failcount updates + High: TE: Use the correct offset when updating failcount + Medium: Admin: Add a summary output that can be easily parsed by CTS for audit purposes + Medium: Build: Make configure fail if bz2 or libxml2 are not present + Medium: Build: Re-instate a better default for LCRSODIR + Medium: CIB: Bug LF-1861 - Filter irrelvant error status from synchronous CIB clients + Medium: Core: Bug 1849 - Invalid conversion of ordinal leap year to gregorian date + Medium: Core: Drop compataibility code for 2.0.4 and 2.0.5 clusters + Medium: crmd: Bug LF-1860 - Automatically cancel recurring ops before demote and promote operations (not only stops) + Medium: crmd: Save the current CIB contents if we detect the PE crashed + Medium: PE: Bug LF:1866 - Fix version check when applying compatability handling for failed start operations + Medium: PE: Bug LF:1866 - Restore the ability to have start failures not be fatal + Medium: PE: Bug PM1 - Failcount applies to all instances of non-unique clone + Medium: PE: Correctly set the state of partially active master/slave groups + Medium: PE: Do not claim to be stopping an already stopped orphan + Medium: PE: Ensure implies_left ordering constraints are always effective + Medium: PE: Indicate each resources 'promotion' score + Medium: PE: Prevent a possible use-of-NULL + Medium: PE: Reprocess the current action if it changed (so that any prior dependancies are updated) + Medium: TE: Bug LF-1859 - Wait for fail-count updates to complete before terminating the transition + Medium: TE: Bug LF:1859 - Do not abort graphs due to our own failcount updates + Medium: TE: Bug LF:1859 - Prevent the TE from interupting itself * Thu Feb 14 2008 Andrew Beekhof - 0.6.2-1 - Update source tarball to revision: 28b1a8c1868b tip - Statistics: Changesets: 11 Diff: 7 files changed, 58 insertions(+), 18 deletions(-) - Changes since Pacemaker-0.6.1 + haresources2cib.py: set default-action-timeout to the default (20s) + haresources2cib.py: update ra parameters lists + Medium: SNMP: Allow the snmp subagent to be built (patch from MATSUDA, Daiki) + Medium: Tools: Make sure the autoconf variables in haresources2cib are expanded * Tue Feb 12 2008 Andrew Beekhof - 0.6.1-1 - Update source tarball to revision: e7152d1be933 tip - Statistics: Changesets: 25 Diff: 37 files changed, 1323 insertions(+), 227 deletions(-) - Changes since Pacemaker-0.6.0 + High: CIB: Ensure changes to top-level attributes (like admin_epoch) cause a disk write + High: CIB: Ensure the archived file hits the disk before returning + High: CIB: Repair the ability to do 'atomic incriment' updates (value="value++") + High: crmd: Bug #7 - Connecting to the crmd immediately after startup causes use-of-NULL + Medium: CIB: Mask cib_diff_resync results from the caller - they do not need to know + Medium: crmd: Delay starting the IPC server until we are fully functional + Medium: CTS: Fix the startup patterns + Medium: PE: Bug 1820 - Allow the first resource in a group to be migrated + Medium: PE: Bug 1820 - Check the colocation dependancies of resources to be migrated * Mon Jan 14 2008 Andrew Beekhof - 0.6.0-2 - This is the first release of the Pacemaker Cluster Resource Manager formerly part of Heartbeat. - For those looking for the GUI, mgmtd, CIM or TSA components, they are now found in the new pacemaker-pygui project. Build dependancies prevent them from being included in Heartbeat (since the built-in CRM is no longer supported) and, being non-core components, are not included with Pacemaker. - Update source tarball to revision: c94b92d550cf - Statistics: Changesets: 347 Diff: 2272 files changed, 132508 insertions(+), 305991 deletions(-) - Test hardware: + 6-node vmware cluster (sles10-sp1/256Mb/vmware stonith) on a single host (opensuse10.3/2Gb/2.66Ghz Quad Core2) + 7-node EMC Centera cluster (sles10/512Mb/2Ghz Xeon/ssh stonith) - Notes: Heartbeat Stack + All testing was performed with STONITH enabled + The CRM was enabled using the "crm respawn" directive - Notes: OpenAIS Stack + This release contains a preview of support for the OpenAIS cluster stack + The current release of the OpenAIS project is missing two important patches that we require. OpenAIS packages containing these patches are available for most major distributions at: http://download.opensuse.org/repositories/server:/ha-clustering + The OpenAIS stack is not currently recommended for use in clusters that have shared data as STONITH support is not yet implimented + pingd is not yet available for use with the OpenAIS stack + 3 significant OpenAIS issues were found during testing of 4 and 6 node clusters. We are activly working together with the OpenAIS project to get these resolved. - Pending bugs encountered during testing: + OpenAIS #1736 - Openais membership took 20s to stabilize + Heartbeat #1750 - ipc_bufpool_update: magic number in head does not match + OpenAIS #1793 - Assertion failure in memb_state_gather_enter() + OpenAIS #1796 - Cluster message corruption - Changes since Heartbeat-2.1.2-24 + High: Add OpenAIS support + High: Admin: crm_uuid - Look in the right place for Heartbeat UUID files + High: admin: Exit and indicate a problem if the crmd exits while crmadmin is performing a query + High: cib: Fix CIB_OP_UPDATE calls that modify the whole CIB + High: cib: Fix compilation when supporting the heartbeat stack + High: cib: Fix memory leaks caused by the switch to get_message_xml() + High: cib: HA_VALGRIND_ENABLED needs to be set _and_ set to 1|yes|true + High: cib: Use get_message_xml() in preference to cl_get_struct() + High: cib: Use the return value from call to write() in cib_send_plaintext() + High: Core: ccm nodes can legitimately have a node id of 0 + High: Core: Fix peer-process tracking for the Heartbeat stack + High: Core: Heartbeat does not send status notifications for nodes that were already part of the cluster. Fake them instead + High: CRM: Add children to HA_Messages such that the field name matches F_XML_TAGNAME + High: crm: Adopt a more flexible appraoch to enabling Valgrind + High: crm: Fix compilation when bzip2 is not installed + High: CRM: Future-proof get_message_xml() + High: crmd: Filter election responses based on time not FSA state + High: crmd: Handle all possible peer states in crmd_ha_status_callback() + High: crmd: Make sure the current date/time is set - prevents use-of-NULL when evaluating rules + High: crmd: Relax an assertion regrading ccm membership instances + High: crmd: Use (node->processes&crm_proc_ais) to accurately update the CIB after replace operations + High: crmd: Heartbeat: Accurately record peer client status + High: PE: Bug 1777 - Allow colocation with a resource in the Stopped state + High: PE: Bug 1822 - Prevent use-of-NULL in PromoteRsc() + High: PE: Implement three recovery policies based on op_status and op_rc + High: PE: Parse fail-count correctly (it may be set to ININFITY) + High: PE: Prevent graph-loop when stonith agents need to be moved around before a STONITH op + High: PE: Prevent graph-loops when two operations have the same name+interval + High: te: Cancel active timers when destroying graphs + High: TE: Ensure failcount is set correctly for failed stops/starts + High: TE: Update failcount for oeprations that time out + Medium: admin: Prevent hang in crm_mon -1 when there is no cib connection - Patch from Junko IKEDA + Medium: cib: Require --force|-f when performing potentially dangerous commands with cibadmin + Medium: cib: Tweak the shutdown code + Medium: Common: Only count peer processes of active nodes + Medium: Core: Create generic cluster sign-in method + Medium: core: Fix compilation when Heartbeat support is disabled + Medium: Core: General cleanup for supporting two stacks + Medium: Core: iso6601 - Support parsing of time-only strings + Medium: core: Isolate more code that is only needed when SUPPORT_HEARTBEAT is enabled + Medium: crm: Improved logging of errors in the XML parser + Medium: crmd: Fix potential use-of-NULL in string comparison + Medium: crmd: Reimpliment syncronizing of CIB queries and updates when invoking the PE + Medium: crm_mon: Indicate when a node is both in standby mode and offline + Medium: PE: Bug 1822 - Do not try an promote groups if not all of it is active + Medium: PE: on_fail=nothing is an alias for 'ignore' not 'restart' + Medium: PE: Prevent a potential use-of-NULL in cron_range_satisfied() + snmp subagent: fix a problem on displaying an unmanaged group + snmp subagent: use the syslog setting + snmp: v2 support (thanks to Keisuke MORI) + snmp_subagent - made it not complain about some things if shutting down * Mon Dec 10 2007 Andrew Beekhof - 0.6.0-1 - Initial opensuse package check-in diff --git a/pengine/Makefile.am b/pengine/Makefile.am index 2eb5d0dbc6..ada7d996c5 100644 --- a/pengine/Makefile.am +++ b/pengine/Makefile.am @@ -1,90 +1,93 @@ # # Copyright (C) 2004 Andrew Beekhof # # 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 INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir) -I$(top_srcdir) \ -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl halibdir = $(CRM_DAEMON_DIR) PE_TESTS = $(wildcard test10/*.scores) testdir = $(datadir)/$(PACKAGE)/tests/pengine test_SCRIPTS = regression.sh test_DATA = regression.core.sh test10dir = $(datadir)/$(PACKAGE)/tests/pengine/test10 test10_DATA = $(PE_TESTS) $(PE_TESTS:%.scores=%.xml) $(PE_TESTS:%.scores=%.exp) $(PE_TESTS:%.scores=%.dot) COMMONLIBS = \ $(top_builddir)/lib/common/libcrmcommon.la \ $(top_builddir)/lib/pengine/libpe_status.la \ libpengine.la $(CURSESLIBS) $(CLUSTERLIBS) ## libraries lib_LTLIBRARIES = libpengine.la ## binary progs halib_PROGRAMS = pengine sbin_PROGRAMS = ptest man8_MANS = if BUILD_HELP man8_MANS += ptest.8 ptest.8: ptest help2man --output $@ --no-info --section 8 --name "Part of the Pacemaker cluster resource manager" $(top_builddir)/pengine/$< endif if BUILD_XML_HELP man8_MANS += pengine.8 pengine.xml: pengine $(top_builddir)/pengine/$< metadata | $(XSLTPROC) --nonet --novalid --stringparam man.name $< $(top_srcdir)/xml/ocf-meta2man.xsl - > $(top_builddir)/pengine/$@ pengine.8: pengine.xml $(XSLTPROC) $(MANPAGE_XSLT) $(top_builddir)/pengine/$< endif ## SOURCES noinst_HEADERS = allocate.h utils.h pengine.h #utils.h pengine.h libpengine_la_LDFLAGS = -version-info 3:0:0 # -L$(top_builddir)/lib/pils -lpils -export-dynamic -module -avoid-version libpengine_la_SOURCES = pengine.c allocate.c utils.c constraints.c \ native.c group.c clone.c master.c graph.c pengine_SOURCES = main.c pengine_LDADD = $(COMMONLIBS) $(top_builddir)/lib/cib/libcib.la # libcib for get_object_root() # $(top_builddir)/lib/hbclient/libhbclient.la ptest_SOURCES = ptest.c ptest_LDADD = $(COMMONLIBS) \ $(top_builddir)/lib/cib/libcib.la \ $(top_builddir)/lib/transition/libtransitioner.la install-exec-local: $(mkinstalldirs) $(DESTDIR)/$(PE_STATE_DIR) -chown $(CRM_DAEMON_USER) $(DESTDIR)/$(PE_STATE_DIR) -chgrp $(CRM_DAEMON_GROUP) $(DESTDIR)/$(PE_STATE_DIR) -chmod 750 $(DESTDIR)/$(PE_STATE_DIR) uninstall-local: + +clean-generic: + rm -f test10/*.pe.* diff --git a/pengine/regression.core.sh.in b/pengine/regression.core.sh.in index 56644f1822..54d72fbbb6 100644 --- a/pengine/regression.core.sh.in +++ b/pengine/regression.core.sh.in @@ -1,229 +1,229 @@ # Copyright (C) 2004 Andrew Beekhof # # 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 # verbose=$1 num_failed=0 force_local=0 VALGRIND_CMD="" diff_opts="--ignore-all-space -u -N" test_home=`dirname $0` test_name=`basename $0` function info() { printf "$*\n" } function error() { printf " * ERROR: $*\n" } function failed() { printf " * FAILED: $*\n" } function show_test() { name=$1; shift printf " Test %-25s $*\n" "$name:" } info "Test home is:\t$test_home" test_binary=@abs_top_builddir@/tools/crm_simulate failed=$test_home/.regression.failed.diff # zero out the error log > $failed while true ; do case "$1" in -v|--valgrind) export G_SLICE=always-malloc VALGRIND_CMD="valgrind -q --show-reachable=no --leak-check=full --trace-children=no --time-stamp=yes --num-callers=20 --suppressions=./ptest.supp" test_binary=`which crm_simulate` shift;; -b|--binary) test_binary=$2; shift; shift;; -?|--help) echo "$0 [--binary name] [--force-local]"; shift; exit 0;; --) shift ; break ;; "") break;; *) echo "unknown option: $1"; exit 1;; esac done if [ ! -x $test_binary ]; then test_binary=`which crm_simulate` fi if [ "x$test_binary" = "x" ]; then info "crm_simulate not installed. Aborting." exit 1 fi info "Test binary is:\t$test_binary" if [ "x$VALGRIND_CMD" != "x" ]; then info "Activating memory testing with valgrind"; fi info " " test_cmd="$VALGRIND_CMD $test_binary" #echo $test_cmd if [ $USER != root ]; then declare -x CIB_shadow_dir=/tmp fi function do_test { expected_rc=0 base=$1; shift name=$1; shift input=$io_dir/${base}.xml output=$io_dir/${base}.pe.out expected=$io_dir/${base}.exp te_output=$io_dir/${base}.te.out te_expected=$io_dir/${base}.te.exp dot_output=$io_dir/${base}.pe.dot dot_expected=$io_dir/${base}.dot dot_png=$io_dir/${base}.png scores=$io_dir/${base}.scores score_output=$io_dir/${base}.pe.scores if [ "x$1" = "x--rc" ]; then expected_rc=$2 shift; shift; fi show_test "$base" "$name" if [ ! -f $input ]; then error "No input"; num_failed=`expr $num_failed + 1` return; fi if [ "$create_mode" != "true" -a ! -f $expected ]; then error "no stored output"; # return; fi # ../admin/crm_verify -X $input - $test_binary -x $input -D $dot_output -G $output -SQ -s $* > $score_output + CIB_shadow_dir=$io_dir $test_binary -x $input -D $dot_output -G $output -SQ -s $* > $score_output rc=$? if [ $rc != $expected_rc ]; then failed "Test returned: $rc"; num_failed=`expr $num_failed + 1` fi if [ -s core ]; then error "Core-file detected: core.${base}"; num_failed=`expr $num_failed + 1` rm -f $test_home/core.$base mv core $test_home/core.$base fi if [ ! -s $output ]; then error "No graph produced"; num_failed=`expr $num_failed + 1` rm $output return; # else # mv $output $output.sed # cat $output.sed | sed 's/id=.[0-9]*.\ //g' >> $output fi if [ ! -s $dot_output ]; then error "No dot-file summary produced"; num_failed=`expr $num_failed + 1` rm $output return; else echo "digraph \"g\" {" > $dot_output.sort LC_ALL=POSIX sort -u $dot_output | grep -v -e ^}$ -e digraph >> $dot_output.sort echo "}" >> $dot_output.sort mv -f $dot_output.sort $dot_output fi if [ ! -s $score_output ]; then error "No allocation scores produced"; num_failed=`expr $num_failed + 1` rm $output return; fi if [ "$create_mode" = "true" ]; then cp "$output" "$expected" cp "$dot_output" "$dot_expected" cp "$score_output" "$scores" info " Created expected outputs" fi diff $diff_opts $dot_expected $dot_output >/dev/null rc=$? if [ $rc != 0 ]; then failed "dot-file summary changed"; diff $diff_opts $dot_expected $dot_output 2>/dev/null >> $failed echo "" >> $failed num_failed=`expr $num_failed + 1` else rm $dot_output fi diff $diff_opts $expected $output >/dev/null rc2=$? if [ $rc2 != 0 ]; then failed "xml-file changed"; diff $diff_opts $expected $output 2>/dev/null >> $failed echo "" >> $failed num_failed=`expr $num_failed + 1` else rm $output fi diff $diff_opts $scores $score_output >/dev/null rc=$? if [ $rc != 0 ]; then failed "scores-file changed"; diff $diff_opts $scores $score_output 2>/dev/null >> $failed echo "" >> $failed num_failed=`expr $num_failed + 1` else rm $score_output fi rm -f $output } function test_results { if [ $num_failed != 0 ]; then if [ -s $failed ]; then if [ "$verbose" = "-v" ]; then error "Results of $num_failed failed tests...." less $failed else error "Results of $num_failed failed tests are in $failed...." error "Use $0 -v to display them automatically." fi else error "$num_failed tests failed (no diff results)" rm $failed fi fi exit $num_failed } diff --git a/rpmlintrc b/rpmlintrc index 0beeba47f5..5a2b83babe 100644 --- a/rpmlintrc +++ b/rpmlintrc @@ -1 +1,10 @@ -addFilter("hardcoded-library-path .*/lib/ocf") +addFilter("E: non-standard-dir-perm .* 0750") +addFilter("E: hardcoded-library-path in /usr/lib/ocf") +addFilter("W: spelling-error") +addFilter("W: non-standard-uid .* hacluster") +addFilter("W: non-standard-gid .* haclient") +addFilter("W: shared-lib-calls-exit") +addFilter("W: invalid-url Source0:") +addFilter("pacemaker.src: W: strange-permission .* 0600") +addFilter("pacemaker.src: E: invalid-spec-name") +addFilter("W: mixed-use-of-spaces-and-tabs") diff --git a/shell/crm b/shell/crm old mode 100644 new mode 100755 index fd90dab04a..34268c9f05 --- a/shell/crm +++ b/shell/crm @@ -1,45 +1,49 @@ #!/usr/bin/python # # 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 # minimum_version = '2.4' import sys from distutils import version v_min = version.StrictVersion(minimum_version) v_this = version.StrictVersion(sys.version[:3]) if v_min > v_this: sys.stderr.write("abort: minimum python version support is %s\n", \ minimum_version) sys.exit(-1) try: - import crm.main + from crm import main except ImportError: - sys.stderr.write("abort: couldn't find crm libraries in [%s]\n" % + try: + # Perhaps we're running from the source directory + from modules import main + except ImportError: + sys.stderr.write("abort: couldn't find crm libraries in [%s]\n" % ' '.join(sys.path)) - sys.stderr.write("(check your install and PYTHONPATH)\n") - sys.exit(-1) + sys.stderr.write("(check your install and PYTHONPATH)\n") + sys.exit(-1) try: - crm.main.run() + main.run() except KeyboardInterrupt: print "Ctrl-C, leaving" sys.exit(1) # vim:ts=4:sw=4:et: diff --git a/shell/modules/help.py.in b/shell/modules/help.py.in index cf62991ebe..52d8181e9b 100644 --- a/shell/modules/help.py.in +++ b/shell/modules/help.py.in @@ -1,276 +1,279 @@ # 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 # import os import re from cache import WCache +from userprefs import Options from utils import odict, page_string from msg import * # # help or make users feel less lonely # def add_shorthelp(topic,shorthelp,topic_help): ''' Join topics ("%s,%s") if they share the same short description. ''' for i in range(len(topic_help)): if topic_help[i][1] == shorthelp: topic_help[i][0] = "%s,%s" % (topic_help[i][0], topic) return topic_help.append([topic, shorthelp]) def dump_short_help(help_tab): topic_help = [] for topic in help_tab: if topic == '.': continue # with odict, for whatever reason, python parses differently: # help_tab["..."] = ("...","...") and # help_tab["..."] = ("...",""" # ...""") # a parser bug? if type(help_tab[topic][0]) == type(()): shorthelp = help_tab[topic][0][0] else: shorthelp = help_tab[topic][0] add_shorthelp(topic,shorthelp,topic_help) for t,d in topic_help: print "\t%-16s %s" % (t,d) def overview(help_tab): print "" print help_tab['.'][1] print "" print "Available commands:" print "" dump_short_help(help_tab) print "" def topic_help(help_tab,topic): if topic not in help_tab: print "There is no help for topic %s" % topic return if type(help_tab[topic][0]) == type(()): shorthelp = help_tab[topic][0][0] longhelp = help_tab[topic][0][1] else: shorthelp = help_tab[topic][0] longhelp = help_tab[topic][1] if longhelp: page_string(longhelp) else: print shorthelp def cmd_help(help_tab,topic = ''): "help!" # help_tab is an odict (ordered dictionary): # help_tab[topic] = (short_help,long_help) # topic '.' is a special entry for the top level if not help_tab: common_info("sorry, help not available") return if not topic: overview(help_tab) else: topic_help(help_tab,topic) def is_level(s): return len(s.split("_")) == 2 def help_short(s): r = re.search("help_[^,]+,(.*)\]\]", s) return r and r.group(1) or '' class HelpSystem(object): ''' The help system. All help is in the following form in the manual: [[cmdhelp__,]] === ... Long help text. ... [[cmdhelp__,]] Help for the level itself is like this: [[cmdhelp_,]] ''' help_text_file = "@datadir@/@PACKAGE@/crm_cli.txt" index_file = "%s/%s" % (os.getenv("HOME"),".crm_help_index") def __init__(self): self.key_pos = {} self.leveld = {} self.no_help_file = False # don't print repeatedly messages self.bad_index = False # don't print repeatedly warnings for bad index def open_file(self,name,mode): try: f = open(name,mode) return f except IOError,msg: common_err("%s open: %s"%(name,msg)) common_err("extensive help system is not available") self.no_help_file = True return None def drop_index(self): common_info("removing index") os.unlink(self.index_file) self.key_pos = {} self.leveld = {} self.bad_index = True def mk_index(self): ''' Prepare an index file, sorted by topic, with seek positions Do we need a hash on content? ''' if self.no_help_file: return False crm_help_v = os.getenv("CRM_HELP_FILE") if crm_help_v: self.help_text_file = crm_help_v help_f = self.open_file(self.help_text_file,"r") if not help_f: return False idx_f = self.open_file(self.index_file,"w") if not idx_f: return False - common_info("building help index") + if not options.regression_tests: + common_info("building help index") key_pos = odict() while 1: pos = help_f.tell() s = help_f.readline() if not s: break if s.startswith("[["): r = re.search(r'..([^,]+),', s) if r: key_pos[r.group(1)] = pos help_f.close() for key in key_pos: print >>idx_f, '%s %d' % (key,key_pos[key]) idx_f.close() return True def is_index_old(self): try: t_idx = os.path.getmtime(self.index_file) except: return True try: t_help = os.path.getmtime(self.help_text_file) except: return True return t_help > t_idx def load_index(self): if self.is_index_old(): self.mk_index() self.key_pos = {} self.leveld = {} idx_f = self.open_file(self.index_file,"r") if not idx_f: return False cur_lvl = '' for s in idx_f: a = s.split() if len(a) != 2: if not self.bad_index: common_err("index file corrupt") idx_f.close() self.drop_index() return self.load_index() # this runs only once return False key = a[0] fpos = long(a[1]) if key.startswith("cmdhelp_"): if is_level(key): if key != cur_lvl: cur_lvl = key self.leveld[cur_lvl] = [] else: self.leveld[cur_lvl].append(key) self.key_pos[key] = fpos idx_f.close() return True def __filter(self,s): if '<<' in s: return re.sub(r'<<[^,]+,(.+)>>', r'\1', s) else: return s def __load_help_one(self,key,skip = 2): longhelp = '' self.help_f.seek(self.key_pos[key]) shorthelp = help_short(self.help_f.readline()) for i in range(skip-1): self.help_f.readline() l = [] for s in self.help_f: if s.startswith("[[") or s.startswith("="): break l.append(self.__filter(s)) if l and l[-1] == '\n': # drop the last line of empty l.pop() if l: longhelp = ''.join(l) if not shorthelp or not longhelp: if not self.bad_index: common_warn("help topic %s not found" % key) self.drop_index() return shorthelp,longhelp def cmdhelp(self,s): if not self.key_pos and not self.load_index(): return None,None if not s in self.key_pos: if not self.bad_index: common_warn("help topic %s not found" % s) self.drop_index() return None,None return self.__load_help_one(s) def __load_level(self,lvl): ''' For the given level, create a help table. ''' if wcache.is_cached("lvl_help_tab_%s" % lvl): return wcache.retrieve("lvl_help_tab_%s" % lvl) if not self.key_pos and not self.load_index(): return None self.help_f = self.open_file(self.help_text_file,"r") if not self.help_f: return None lvl_s = "cmdhelp_%s" % lvl if not lvl_s in self.leveld: if not self.bad_index: common_warn("help table for level %s not found" % lvl) self.drop_index() return None common_debug("loading help table for level %s" % lvl) help_tab = odict() help_tab["."] = self.__load_help_one(lvl_s) try: for key in self.leveld[lvl_s]: cmd = key[len(lvl_s)+1:] help_tab[cmd] = self.__load_help_one(key) except: pass self.help_f.close() help_tab["quit"] = ("exit the program", "") help_tab["help"] = ("show help", "") help_tab["end"] = ("go back one level", "") return help_tab def load_level(self,lvl): help_tab = self.__load_level(lvl) if self.bad_index: # try again help_tab = self.__load_level(lvl) return wcache.store("lvl_help_tab_%s" % lvl, help_tab) wcache = WCache.getInstance() +options = Options.getInstance() # vim:ts=4:sw=4:et: diff --git a/shell/modules/main.py b/shell/modules/main.py index 3d2e800546..a2b340fcf2 100644 --- a/shell/modules/main.py +++ b/shell/modules/main.py @@ -1,279 +1,282 @@ # 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 # import sys import shlex import readline import getopt from utils import * from userprefs import Options, UserPrefs from vars import Vars from msg import * from ui import cmd_exit, TopLevel, completer from levels import Levels def load_rc(rcfile): try: f = open(rcfile) except: return save_stdin = sys.stdin sys.stdin = f while True: inp = multi_input() if inp == None: break try: parse_line(levels,shlex.split(inp)) except ValueError, msg: common_err(msg) f.close() sys.stdin = save_stdin def multi_input(prompt = ''): """ Get input from user Allow multiple lines using a continuation character """ line = [] while True: try: text = raw_input(prompt) except EOFError: return None err_buf.incr_lineno() if options.regression_tests: print ".INP:",text sys.stdout.flush() sys.stderr.flush() stripped = text.strip() if stripped.endswith('\\'): stripped = stripped.rstrip('\\') line.append(stripped) if prompt: prompt = '> ' else: line.append(stripped) break return ''.join(line) def check_args(args,argsdim): if not argsdim: return True if len(argsdim) == 1: minargs = argsdim[0] return len(args) >= minargs else: minargs,maxargs = argsdim return len(args) >= minargs and len(args) <= maxargs # # Note on parsing # # Parsing tables are python dictionaries. # # Keywords are used as keys and the corresponding values are # lists (actually tuples, since they should be read-only) or # classes. In the former case, the keyword is a terminal and # in the latter, a new object for the class is created. The class # must have the cmd_table variable. # # The list has the following content: # # function: a function to handle this command # numargs_list: number of minimum/maximum arguments; for example, # (0,1) means one optional argument, (1,1) one required; if the # list is empty then the function will parse arguments itself # required minimum skill level: operator, administrator, expert # (encoded as a small integer from 0 to 2) # list of completer functions (optional) # def show_usage(cmd): p = None try: p = cmd.__doc__ except: pass if p: print >> sys.stderr, p else: syntax_err(cmd.__name__) def parse_line(lvl,s): if not s: return True if s[0].startswith('#'): return True lvl.mark() pt = lvl.parse_root cmd = None i = 0 for i in range(len(s)): token = s[i] if token in pt: if type(pt[token]) == type(object): lvl.new_level(pt[token],token) pt = lvl.parse_root # move to the next level else: cmd = pt[token] # terminal symbol break # and stop parsing else: syntax_err(s[i:]) lvl.release() return False if cmd: # found a terminal symbol if not user_prefs.check_skill_level(cmd[2]): lvl.release() skill_err(s[i]) return False args = s[i+1:] if not check_args(args,cmd[1]): lvl.release() show_usage(cmd[0]) return False args = s[i:] d = lambda: cmd[0](*args) rv = d() # execute the command lvl.release() return rv != False return True def prereqs(): proglist = "which cibadmin crm_resource crm_attribute crm_mon crm_standby crm_failcount" for prog in proglist.split(): if not is_program(prog): print >> sys.stderr, "%s not available, check your installation"%prog sys.exit(1) # three modes: interactive (no args supplied), batch (input from # a file), half-interactive (args supplied, but not batch) def cib_prompt(): return vars.cib_in_use or "live" def setup_readline(): readline.set_history_length(100) readline.parse_and_bind("tab: complete") readline.set_completer(completer) readline.set_completer_delims(\ readline.get_completer_delims().replace('-','').replace('/','').replace('=','')) try: readline.read_history_file(vars.hist_file) except: pass def usage(): print >> sys.stderr, """ usage: crm [-D display_type] [-f file] [-hF] [args] Use crm without arguments for an interactive session. Supply one or more arguments for a "single-shot" use. Specify with -f a file which contains a script. Use '-' for standard input or use pipe/redirection. crm displays cli format configurations using a color scheme and/or in uppercase. Pick one of "color" or "uppercase", or use "-D color,uppercase" if you want colorful uppercase. Get plain output by "-D plain". The default may be set in user preferences (options). -F stands for force, if set all operations will behave as if force was specified on the line (e.g. configure commit). Examples: # crm -f stopapp2.cli # crm < stopapp2.cli # crm resource stop global_www # crm status """ sys.exit(1) user_prefs = UserPrefs.getInstance() options = Options.getInstance() err_buf = ErrorBuffer.getInstance() vars = Vars.getInstance() levels = Levels.getInstance() +# prefer the user set PATH +os.putenv("PATH", "%s:%s" % (os.getenv("PATH"),vars.crm_daemon_dir)) + def run(): prereqs() inp_file = '' load_rc(vars.rc_file) if not sys.stdin.isatty(): err_buf.reset_lineno() options.batch = True else: options.interactive = True try: opts, args = getopt.getopt(sys.argv[1:], \ 'hdf:FRD:', ("help","debug","file=",\ "force","regression-tests","display=")) for o,p in opts: if o in ("-h","--help"): usage() elif o == "-d": user_prefs.set_debug() elif o == "-R": options.regression_tests = True elif o in ("-D","--display"): user_prefs.set_output(p) elif o in ("-F","--force"): user_prefs.set_force() elif o in ("-f","--file"): options.batch = True err_buf.reset_lineno() inp_file = p except getopt.GetoptError,msg: print msg usage() if len(args) == 1 and args[0].startswith("conf"): parse_line(levels,["configure"]) options.interactive = True elif len(args) > 0: err_buf.reset_lineno() options.interactive = False if parse_line(levels,shlex.split(' '.join(args))): # if the user entered a level, then just continue if levels.previous(): if not inp_file and sys.stdin.isatty(): options.interactive = True else: sys.exit(0) else: sys.exit(1) if inp_file == "-": pass elif inp_file: try: f = open(inp_file) except IOError, msg: common_err(msg) usage() sys.stdin = f if options.interactive and not options.batch: setup_readline() while True: if options.interactive and not options.batch: vars.prompt = "crm(%s)%s# " % (cib_prompt(),levels.getprompt()) inp = multi_input(vars.prompt) if inp == None: cmd_exit("eof") try: parse_line(levels,shlex.split(inp)) except ValueError, msg: common_err(msg) # vim:ts=4:sw=4:et: diff --git a/shell/modules/ra.py.in b/shell/modules/ra.py.in index 2b0bdc0b5a..123e670c48 100644 --- a/shell/modules/ra.py.in +++ b/shell/modules/ra.py.in @@ -1,596 +1,595 @@ # 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 # import os import sys import subprocess import copy import xml.dom.minidom import re import glob from userprefs import Options, UserPrefs from cache import WCache from vars import Vars from utils import * from msg import * # # Resource Agents interface (meta-data, parameters, etc) # ocf_root = os.getenv("OCF_ROOT") if not ocf_root: ocf_root = "@OCF_ROOT_DIR@" if not ocf_root: ocf_root = "/usr/lib/ocf" os.putenv("OCF_ROOT",ocf_root) class RaLrmd(object): ''' Getting information from the resource agents. ''' lrmadmin_prog = "lrmadmin" def __init__(self): self.good = self.is_lrmd_accessible() def lrmadmin(self, opts, xml = False): ''' Get information directly from lrmd using lrmadmin. ''' l = stdout2list("%s %s" % (self.lrmadmin_prog,opts)) if l and not xml: l = l[1:] # skip the first line return l def is_lrmd_accessible(self): if not (is_program(self.lrmadmin_prog) and is_process("lrmd")): return False return subprocess.call(\ add_sudo(">/dev/null 2>&1 %s -C" % self.lrmadmin_prog), \ shell=True) == 0 def meta(self, ra_class,ra_type,ra_provider): return self.lrmadmin("-M %s %s %s"%(ra_class,ra_type,ra_provider),True) def providers(self, ra_type,ra_class = "ocf"): 'List of providers for a class:type.' return self.lrmadmin("-P %s %s" % (ra_class,ra_type),True) def classes(self): 'List of providers for a class:type.' return self.lrmadmin("-C") def types(self, ra_class = "ocf", ra_provider = ""): 'List of types for a class.' return self.lrmadmin("-T %s" % ra_class) class RaOS(object): ''' Getting information from the resource agents (direct). ''' def __init__(self): self.good = True def meta(self, ra_class,ra_type,ra_provider): l = [] if ra_class == "ocf": l = stdout2list("%s/resource.d/%s/%s meta-data" % \ (ocf_root,ra_provider,ra_type)) elif ra_class == "stonith": l = stdout2list("stonith -m -t %s" % ra_type) return l def providers(self, ra_type,ra_class = "ocf"): 'List of providers for a class:type.' l = [] if ra_class == "ocf": for s in glob.glob("%s/resource.d/*/%s" % (ocf_root,ra_type)): a = s.split("/") if len(a) == 7: l.append(a[5]) return l def classes(self): 'List of classes.' return "heartbeat lsb ocf stonith".split() def types(self, ra_class = "ocf", ra_provider = ""): 'List of types for a class.' l = [] prov = ra_provider and ra_provider or "*" if ra_class == "ocf": l = os_types_list("%s/resource.d/%s/*" % (ocf_root,prov)) elif ra_class == "lsb": l = os_types_list("/etc/init.d/*") elif ra_class == "stonith": l = stdout2list("stonith -L") l = list(set(l)) l.sort() return l def ra_if(): if vars.ra_if: return vars.ra_if vars.ra_if = RaLrmd() if not vars.ra_if.good: vars.ra_if = RaOS() return vars.ra_if def ra_classes(): ''' List of RA classes. ''' if wcache.is_cached("ra_classes"): return wcache.retrieve("ra_classes") l = ra_if().classes() l.sort() return wcache.store("ra_classes",l) def ra_providers(ra_type,ra_class = "ocf"): 'List of providers for a class:type.' id = "ra_providers-%s-%s" % (ra_class,ra_type) if wcache.is_cached(id): return wcache.retrieve(id) l = ra_if().providers(ra_type,ra_class) l.sort() return wcache.store(id,l) def ra_providers_all(ra_class = "ocf"): ''' List of providers for a class. ''' id = "ra_providers_all-%s" % ra_class if wcache.is_cached(id): return wcache.retrieve(id) dir = ocf_root + "/resource.d" l = [] for s in os.listdir(dir): if os.path.isdir("%s/%s" % (dir,s)): l.append(s) l.sort() return wcache.store(id,l) def ra_types(ra_class = "ocf", ra_provider = ""): ''' List of RA type for a class. ''' if not ra_class: ra_class = "ocf" id = "ra_types-%s-%s" % (ra_class,ra_provider) if wcache.is_cached(id): return wcache.retrieve(id) if ra_provider: list = [] for ra in ra_if().types(ra_class): if ra_provider in ra_providers(ra,ra_class): list.append(ra) else: list = ra_if().types(ra_class) list.sort() return wcache.store(id,list) -def prog_meta(s): +def prog_meta(prog): ''' Do external program metadata. ''' - prog = "@CRM_DAEMON_DIR@/%s" % s l = [] if is_program(prog): l = stdout2list("%s metadata" % prog) return l def get_nodes_text(n,tag): try: node = n.getElementsByTagName(tag)[0] for c in node.childNodes: if c.nodeType == c.TEXT_NODE: return c.data.strip() except: return '' def mk_monitor_name(role,depth): depth = depth == "0" and "" or ("_%s" % depth) return role and role != "Started" and \ "monitor_%s%s" % (role,depth) or \ "monitor%s" % depth def monitor_name_node(node): depth = node.getAttribute("depth") or '0' role = node.getAttribute("role") return mk_monitor_name(role,depth) def monitor_name_pl(pl): depth = find_value(pl, "depth") or '0' role = find_value(pl, "role") return mk_monitor_name(role,depth) def crm_msec(t): ''' See lib/common/utils.c:crm_get_msec(). ''' convtab = { 'ms': (1,1), 'msec': (1,1), 'us': (1,1000), 'usec': (1,1000), '': (1000,1), 's': (1000,1), 'sec': (1000,1), 'm': (60*1000,1), 'min': (60*1000,1), 'h': (60*60*1000,1), 'hr': (60*60*1000,1), } if not t: return -1 r = re.match("\s*(\d+)\s*([a-zA-Z]+)?", t) if not r: return -1 if not r.group(2): q = '' else: q = r.group(2).lower() try: mult,div = convtab[q] except: return -1 return (int(r.group(1))*mult)/div def crm_time_cmp(a, b): return crm_msec(a) - crm_msec(b) class RAInfo(object): ''' A resource agent and whatever's useful about it. ''' ra_tab = " " # four horses required_ops = ("start", "stop") skip_ops = ("meta-data", "validate-all") skip_op_attr = ("name", "depth", "role") def __init__(self,ra_class,ra_type,ra_provider = "heartbeat"): self.ra_class = ra_class self.ra_type = ra_type self.ra_provider = ra_provider if not self.ra_provider: self.ra_provider = "heartbeat" self.ra_node = None def ra_string(self): return self.ra_class == "ocf" and \ "%s:%s:%s" % (self.ra_class, self.ra_provider, self.ra_type) or \ "%s:%s" % (self.ra_class, self.ra_type) def error(self, s): common_err("%s: %s" % (self.ra_string(), s)) def warn(self, s): common_warn("%s: %s" % (self.ra_string(), s)) def add_extra_stonith_params(self): if not vars.stonithd_metadata: vars.stonithd_metadata = RAInfo("stonithd","metadata") if not vars.stonithd_metadata.mk_ra_node(): return try: params_node = self.doc.getElementsByTagName("parameters")[0] except: params_node = self.doc.createElement("parameters") self.ra_node.appendChild(params_node) for n in vars.stonithd_metadata.ra_node.getElementsByTagName("parameter"): params_node.appendChild(self.doc.importNode(n,1)) def mk_ra_node(self): ''' Return the resource_agent node. ''' if self.ra_node: return self.ra_node meta = self.meta() try: self.doc = xml.dom.minidom.parseString('\n'.join(meta)) except: self.error("could not parse meta-data: %s" % '\n'.join(meta)) self.ra_node = None return None try: self.ra_node = self.doc.getElementsByTagName("resource-agent")[0] except: self.error("meta-data contains no resource-agent element") self.ra_node = None return None if self.ra_class == "stonith": self.add_extra_stonith_params() return self.ra_node def param_type_default(self,n): try: content = n.getElementsByTagName("content")[0] type = content.getAttribute("type") default = content.getAttribute("default") return type,default except: return None,None def params(self): ''' Construct a dict of dicts: parameters are keys and dictionary of attributes/values are values. Cached too. ''' id = "ra_params-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if not self.mk_ra_node(): return None d = {} for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): name = c.getAttribute("name") if not name: continue required = c.getAttribute("required") unique = c.getAttribute("unique") type,default = self.param_type_default(c) d[name] = { "required": required, "unique": unique, "type": type, "default": default, } return wcache.store(id,d) def actions(self): ''' Construct a dict of dicts: actions are keys and dictionary of attributes/values are values. Cached too. ''' id = "ra_actions-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if not self.mk_ra_node(): return None d = {} for pset in self.ra_node.getElementsByTagName("actions"): for c in pset.getElementsByTagName("action"): name = c.getAttribute("name") if not name or name in self.skip_ops: continue if name == "monitor": name = monitor_name_node(c) d[name] = {} for a in c.attributes.keys(): if a in self.skip_op_attr: continue v = c.getAttribute(a) if v: d[name][a] = v # add monitor ops without role, if they don't already # exist d2 = {} for op in d.keys(): if re.match("monitor_[^0-9]", op): norole_op = re.sub(r'monitor_[^0-9_]+_(.*)', r'monitor_\1', op) if not norole_op in d: d2[norole_op] = d[op] d.update(d2) return wcache.store(id,d) def reqd_params_list(self): ''' List of required parameters. ''' d = self.params() if not d: return [] return [x for x in d if d[x]["required"] == '1'] def param_default(self,pname): ''' Parameter's default. ''' d = self.params() try: return d[pname]["default"] except: return None def sanity_check_params(self, id, pl): ''' pl is a list of (attribute,value) pairs. - are all required parameters defined - do all parameters exist ''' rc = 0 d = {} for p,v in pl: d[p] = v for p in self.reqd_params_list(): if p not in d: common_err("%s: required parameter %s not defined" % (id,p)) rc |= user_prefs.get_check_rc() for p in d: if p not in self.params(): common_err("%s: parameter %s does not exist" % (id,p)) rc |= user_prefs.get_check_rc() return rc def sanity_check_ops(self, id, ops, default_timeout): ''' ops is a dict, operation names are keys and values are lists of (attribute,value) pairs. - do all operations exist - are timeouts sensible ''' rc = 0 n_ops = {} for op in ops: n_op = op == "monitor" and monitor_name_pl(ops[op]) or op n_ops[n_op] = {} for p,v in ops[op]: if p in self.skip_op_attr: continue n_ops[n_op][p] = v for req_op in self.required_ops: if req_op not in n_ops: n_ops[req_op] = {} for op in n_ops: if op not in self.actions(): common_warn("%s: action %s not advertised in meta-data, it may not be supported by the RA" % (id,op)) rc |= 1 continue try: adv_timeout = self.actions()[op]["timeout"] except: continue if "timeout" in n_ops[op]: v = n_ops[op]["timeout"] timeout_string = "specified timeout" else: v = default_timeout timeout_string = "default timeout" if crm_msec(v) < 0: continue if crm_time_cmp(adv_timeout,v) > 0: common_warn("%s: %s %s for %s is smaller than the advised %s" % \ (id,timeout_string,v,op,adv_timeout)) rc |= 1 return rc def meta(self): ''' RA meta-data as raw xml. ''' id = "ra_meta-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if self.ra_class in ("crmd","pengine","stonithd"): l = prog_meta(self.ra_class) else: l = ra_if().meta(self.ra_class,self.ra_type,self.ra_provider) return wcache.store(id, l) def meta_pretty(self): ''' Print the RA meta-data in a human readable form. ''' if not self.mk_ra_node(): return '' l = [] title = self.meta_title() l.append(title) longdesc = get_nodes_text(self.ra_node,"longdesc") if longdesc: l.append(longdesc) if self.ra_class != "heartbeat": params = self.meta_parameters() if params: l.append(params.rstrip()) actions = self.meta_actions() if actions: l.append(actions) return '\n\n'.join(l) def get_shortdesc(self,n): name = n.getAttribute("name") shortdesc = get_nodes_text(n,"shortdesc") longdesc = get_nodes_text(n,"longdesc") if shortdesc and shortdesc not in (name,longdesc,self.ra_type): return shortdesc return '' def meta_title(self): s = self.ra_string() shortdesc = self.get_shortdesc(self.ra_node) if shortdesc: s = "%s (%s)" % (shortdesc,s) return s def meta_param_head(self,n): name = n.getAttribute("name") if not name: return None s = name if n.getAttribute("required") == "1": s = s + "*" type,default = self.param_type_default(n) if type and default: s = "%s (%s, [%s])" % (s,type,default) elif type: s = "%s (%s)" % (s,type) shortdesc = self.get_shortdesc(n) s = "%s: %s" % (s,shortdesc) return s def format_parameter(self,n): l = [] head = self.meta_param_head(n) if not head: self.error("no name attribute for parameter") return "" l.append(head) longdesc = get_nodes_text(n,"longdesc") if longdesc: longdesc = self.ra_tab + longdesc.replace("\n","\n"+self.ra_tab) + '\n' l.append(longdesc) return '\n'.join(l) def meta_parameter(self,param): if not self.mk_ra_node(): return '' l = [] for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): if c.getAttribute("name") == param: return self.format_parameter(c) def meta_parameters(self): if not self.mk_ra_node(): return '' l = [] for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): s = self.format_parameter(c) if s: l.append(s) if l: return "Parameters (* denotes required, [] the default):\n\n" + '\n'.join(l) def meta_action_head(self,n): name = n.getAttribute("name") if not name: return '' if name in self.skip_ops: return '' if name == "monitor": name = monitor_name_node(n) s = "%-13s" % name for a in n.attributes.keys(): if a in self.skip_op_attr: continue v = n.getAttribute(a) if v: s = "%s %s=%s" % (s,a,v) return s def meta_actions(self): l = [] for aset in self.ra_node.getElementsByTagName("actions"): for c in aset.getElementsByTagName("action"): s = self.meta_action_head(c) if s: l.append(self.ra_tab + s) if l: return "Operations' defaults (advisory minimum):\n\n" + '\n'.join(l) # # resource type definition # def ra_type_validate(s, ra_class, provider, rsc_type): ''' Only ocf ra class supports providers. ''' if not rsc_type: common_err("bad resource type specification %s"%s) return False if ra_class == "ocf": if not provider: common_err("provider could not be determined for %s"%s) return False else: if provider: common_warn("ra class %s does not support providers"%ra_class) return True return True def disambiguate_ra_type(s): ''' Unravel [class:[provider:]]type ''' l = s.split(':') if not l or len(l) > 3: return None if len(l) == 3: return l elif len(l) == 2: ra_class,ra_type = l else: ra_class = "ocf" ra_type = l[0] ra_provider = '' if ra_class == "ocf": pl = ra_providers(ra_type,ra_class) if pl and len(pl) == 1: ra_provider = pl[0] elif not pl: ra_provider = 'heartbeat' return ra_class,ra_provider,ra_type wcache = WCache.getInstance() vars = Vars.getInstance() # vim:ts=4:sw=4:et: diff --git a/shell/modules/vars.py.in b/shell/modules/vars.py.in index bf2f9a4afe..697ebf413e 100644 --- a/shell/modules/vars.py.in +++ b/shell/modules/vars.py.in @@ -1,134 +1,135 @@ # 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 # import os from singletonmixin import Singleton class Vars(Singleton): cib_cli_map = { "node": "node", "primitive": "primitive", "group": "group", "clone": "clone", "master": "ms", "rsc_location": "location", "rsc_colocation": "colocation", "rsc_order": "order", "cluster_property_set": "property", "rsc_defaults": "rsc_defaults", "op_defaults": "op_defaults", } container_tags = ("group", "clone", "ms", "master") clonems_tags = ("clone", "ms", "master") resource_tags = ("primitive","group","clone","ms","master") constraint_tags = ("rsc_location","rsc_colocation","rsc_order") constraint_rsc_refs = ("rsc","with-rsc","first","then") children_tags = ("group", "primitive") nvpairs_tags = ("meta_attributes", "instance_attributes", "utilization") defaults_tags = ("rsc_defaults","op_defaults") resource_cli_names = ("primitive","group","clone","ms","master") constraint_cli_names = ("location","colocation","collocation","order") nvset_cli_names = ("property","rsc_defaults","op_defaults") op_cli_names = ("monitor", "start", "stop", "migrate_to", "migrate_from","promote","demote","notify") ra_operations = ("probe", "monitor", "start", "stop", "promote", "demote", "notify", "migrate_to", "migrate_from") subpfx_list = { "instance_attributes": "instance_attributes", "meta_attributes": "meta_attributes", "utilization": "utilization", "operations": "ops", "rule": "rule", "expression": "expression", "date_expression": "expression", "duration": "duration", "date_spec": "date_spec", } lrm_exit_codes = { "success": "0", "unknown": "1", "args": "2", "unimplemented": "3", "perm": "4", "installed": "5", "configured": "6", "not_running": "7", "master": "8", "failed_master": "9", } lrm_status_codes = { "pending": "-1", "done": "0", "cancelled": "1", "timeout": "2", "notsupported": "3", "error": "4", } node_states = ("online", "offline", "unclean") precious_attrs = ("id-ref",) time_op_attrs = ("timeout",) req_op_attributes = ("name", "id") op_attributes = ( "interval", "timeout", "requires", "enabled", "role", "on-fail", "start-delay", "interval-origin", "record-pending", "description", ) rsc_meta_attributes = ( "allow-migrate", "is-managed", "interval-origin", "migration-threshold", "priority", "multiple-active", "failure-timeout", "resource-stickiness", "target-role", "restart-type", "description", ) clone_meta_attributes = ( "ordered", "notify", "interleave", "globally-unique", "clone-max", "clone-node-max", "clone-state", "description", ) ms_meta_attributes = ( "master-max", "master-node-max", "description", ) score_types = {'advisory': '0','mandatory': 'INFINITY'} boolean_ops = ('or','and') binary_ops = ('lt','gt','lte','gte','eq','ne') binary_types = ('string' , 'version' , 'number') unary_ops = ('defined','not_defined') simple_date_ops = ('lt','gt') date_ops = ('lt','gt','in_range','date_spec') date_spec_names = '''hours monthdays weekdays yearsdays months \ weeks years weekyears moon'''.split() in_range_attrs = ('start','end') roles_names = ('Stopped', 'Started', 'Master', 'Slave') actions_names = ( 'start', 'promote', 'demote', 'stop') node_default_type = "normal" node_attributes_keyw = ("attributes","utilization") shadow_envvar = "CIB_shadow" prompt = '' tmpfiles = [] this_node = os.uname()[1] cib_in_use = os.getenv(shadow_envvar) hist_file = os.environ.get('HOME')+"/.crm_history" rc_file = os.environ.get('HOME')+"/.crm.rc" tmpl_conf_dir = "%s/%s" % (os.getenv("HOME"),".crmconf") tmpl_dir = "@datadir@/@PACKAGE@/templates" pe_dir = "@PE_STATE_DIR@" crm_conf_dir = "@CRM_CONFIG_DIR@" + crm_daemon_dir = "@CRM_DAEMON_DIR@" ra_if = None # class interface to RA stonithd_metadata = None # stonithd meta data pe_metadata = None # PE meta data crmd_metadata = None # crmd meta data # vim:ts=4:sw=4:et: diff --git a/shell/regression/Makefile.am b/shell/regression/Makefile.am index afa53cdd34..d3f63369b7 100644 --- a/shell/regression/Makefile.am +++ b/shell/regression/Makefile.am @@ -1,27 +1,27 @@ # # Author: Sun Jiang Dong # Copyright (c) 2004 International Business Machines # # 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 SUBDIRS = testcases testdir = $(datadir)/$(PACKAGE)/tests/shell -test_SCRIPTS = regression.sh evaltest.sh lrmregtest-lsb +test_SCRIPTS = regression.sh evaltest.sh test_DATA = README.regression defaults descriptions crm-interface empty.xml # shouldn't need this, but we do for some versions of autofoo tools EXTRA_DIST = $(test_SCRIPTS) $(test_DATA) diff --git a/shell/regression/crm-interface b/shell/regression/crm-interface index 3a01028d7d..7298dec3e4 100644 --- a/shell/regression/crm-interface +++ b/shell/regression/crm-interface @@ -1,56 +1,61 @@ +crm_setup() { + $CRM_NO_REG options check-frequency on-verify + $CRM_NO_REG options check-mode relaxed +} crm_mksample() { cp empty.xml sample.xml CIB_file=sample.xml $CRM_NO_REG< + diff --git a/shell/regression/evaltest.sh b/shell/regression/evaltest.sh index 2bb528f9d7..a1b26f2709 100755 --- a/shell/regression/evaltest.sh +++ b/shell/regression/evaltest.sh @@ -1,123 +1,123 @@ #!/bin/sh # Copyright (C) 2007 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 # : ${TESTDIR:=testcases} : ${CRM:=/usr/sbin/crm} -: ${TESTDIR:=testcases} CRM_NO_REG="$CRM" CRM="$CRM -R" export PYTHONUNBUFFERED=1 . ./defaults . ./crm-interface . ./descriptions resetvars() { unset args unset extcheck } # # special operations squad # specopt_setenv() { eval $rest } specopt_ext() { eval $rest } specopt_extcheck() { extcheck="$rest" set $extcheck which "$1" >/dev/null 2>&1 || # a program in the PATH extcheck="$TESTDIR/$extcheck" # or our script } specopt_repeat() { repeat_limit=$rest } specopt() { cmd=`echo $cmd | sed 's/%//'` # strip leading '%' echo ".`echo $cmd | tr '[a-z]' '[A-Z]'` $rest" # show what we got specopt_$cmd # do what they asked for } # # substitute variables in the test line # substvars() { sed " s/%t/$test_cnt/g s/%l/$line/g s/%i/$repeat_cnt/g " } dotest_session() { echo -n "." >&3 test_cnt=$(($test_cnt+1)) describe_session $* # show what we are about to do crm_$cmd | # and execute the command { [ "$extcheck" ] && $extcheck || cat;} } dotest_single() { echo -n "." >&3 test_cnt=$(($test_cnt+1)) describe_single $* # show what we are about to do crm_single $* | # and execute the command { [ "$extcheck" ] && $extcheck || cat;} if [ "$showobj" ]; then crm_showobj $showobj fi } runtest_session() { while read line; do if [ "$line" = . ]; then break fi echo "$line" done | dotest_session $* } runtest_single() { while [ $repeat_cnt -le $repeat_limit ]; do dotest_single $* resetvars # unset all variables repeat_cnt=$(($repeat_cnt+1)) done repeat_limit=1 repeat_cnt=1 } # # run the tests # repeat_limit=1 repeat_cnt=1 line=1 test_cnt=1 +crm_setup crm_mksample while read cmd rest; do case "$cmd" in "") : empty ;; "#"*) : a comment ;; "%stop") break ;; "%"*) specopt ;; show|showxml|session) runtest_session $rest ;; *) runtest_single $cmd $rest ;; esac line=$(($line+1)) done diff --git a/shell/regression/lrmregtest-lsb.in b/shell/regression/lrmregtest-lsb.in deleted file mode 100644 index 83d23988c3..0000000000 --- a/shell/regression/lrmregtest-lsb.in +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# -# WARNING: This script is for LRM regressions tests only -# - -. @sysconfdir@/ha.d/resource.d/hto-mapfuncs - -OCF_TYPE=lrmregtest -OCF_RESOURCE_INSTANCE=lsb -export OCF_TYPE OCF_RESOURCE_INSTANCE - -ra_execocf $1 diff --git a/shell/regression/regression.sh.in b/shell/regression/regression.sh similarity index 84% rename from shell/regression/regression.sh.in rename to shell/regression/regression.sh index e8f10e0436..d35b9d3ed8 100755 --- a/shell/regression/regression.sh.in +++ b/shell/regression/regression.sh @@ -1,217 +1,187 @@ #!/bin/sh # Copyright (C) 2007 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 # rootdir=`dirname $0` TESTDIR=${TESTDIR:-$rootdir/testcases} DFLT_TESTSET=basicset OUTDIR=${OUTDIR:-crmtestout} CRM_OUTF="$OUTDIR/crm.out" CRM_LOGF="$OUTDIR/crm.log" CRM_DEBUGF="$OUTDIR/crm.debug" OUTF="$OUTDIR/regression.out" LRMD_OPTS="" DIFF_OPTS="--ignore-all-space -U 1" common_filter=$TESTDIR/common.filter common_exclf=$TESTDIR/common.excl -LSB_RA=@INITDIR@/lrmregtest export OUTDIR logmsg() { echo "`date`: $*" | tee -a $CRM_DEBUGF | tee -a $CRM_LOGF } abspath() { echo $1 | grep -qs "^/" && echo $1 || echo `pwd`/$1 } usage() { cat<$OUTF 2>&1 -if [ "$SILENT" = 1 ]; then - exec 3>/dev/null -else - exec 3>/dev/tty -fi - -start_lrmd() { - $HA_BIN/lrmd -s 2>/dev/null - if [ $? -eq 3 ]; then - echo "starting lrmd" >&3 - STOP_LRMD=1 - $HA_BIN/lrmd $LRMD_OPTS >$CRM_OUTF 2>&1 & - sleep 1 - $HA_BIN/lrmd -s 2>/dev/null - else - STOP_LRMD= - fi -} -stop_lrmd() { - if [ "$STOP_LRMD" ]; then - echo "stopping lrmd" >&3 - $HA_BIN/lrmd -k - fi -} -cp_ra() { - if [ ! -e $LSB_RA ]; then - cp -p $rootdir/lrmregtest-lsb $LSB_RA - lrmregtest_lsb=1 - fi - chmod +x $LSB_RA -} -rm_ra() { - [ "$lrmregtest_lsb" ] && rm -f $LSB_RA -} -trap "stop_lrmd; rm_ra" EXIT -cp_ra -start_lrmd || exit $? +# Where to send user output +# evaltest.sh also uses >&3 for printing progress dots +case $output_mode in + silent) exec 3>/dev/null;; + buildbot) exec 3>$CRM_OUTF;; + *) exec 3>/dev/tty;; +esac setenvironment() { filterf=$TESTDIR/$testcase.filter exclf=$TESTDIR/$testcase.excl log_filter=$TESTDIR/$testcase.log_filter expf=$TESTDIR/$testcase.exp outf=$OUTDIR/$testcase.out difff=$OUTDIR/$testcase.diff } filter_output() { { [ -x $common_filter ] && $common_filter || cat;} | { [ -f $common_exclf ] && egrep -vf $common_exclf || cat;} | { [ -x $filterf ] && $filterf || cat;} | { [ -f $exclf ] && egrep -vf $exclf || cat;} } dumpcase() { cat<&3 logmsg "BEGIN testcase $testcase" ( cd $rootdir ./evaltest.sh ) < $TESTDIR/$testcase > $outf 2>&1 filter_output < $outf | if [ "$prepare" ]; then echo " saving to expect file" >&3 cat > $expf else echo -n " checking..." >&3 if head -2 $expf | grep -qs '^ $difff if [ $? -ne 0 ]; then echo " FAIL" >&3 dumpcase return 1 else echo " PASS" >&3 rm -f $outf $difff fi fi sed -n "/BEGIN testcase $testcase/,\$p" $CRM_LOGF | { [ -x $log_filter ] && $log_filter || cat;} | egrep '(CRIT|ERROR):' logmsg "END testcase $testcase" } [ "$1" = prepare ] && { prepare=1; shift 1;} [ $# -eq 0 ] && set "set:$DFLT_TESTSET" for a; do if [ "$a" -a -f "$TESTDIR/$a" ]; then testcase=$a runtestcase else echo "$a" | grep -q "^set:" && TESTSET=$TESTDIR/`echo $a | sed 's/set://'` while read testcase; do runtestcase done < $TESTSET fi done if egrep -wv '(BEGIN|END) testcase' $OUTF >/dev/null then echo "seems like some tests failed or else something not expected" echo "check $OUTF and diff files in $OUTDIR" echo "in case you wonder what lrmd was doing, read $CRM_LOGF and $CRM_DEBUGF" exit 1 -else - rm -f $OUTF $CRM_OUTF fi >&3 diff --git a/shell/regression/testcases/confbasic b/shell/regression/testcases/confbasic index be431e01f5..b8e4c80bd6 100644 --- a/shell/regression/testcases/confbasic +++ b/shell/regression/testcases/confbasic @@ -1,60 +1,62 @@ show Basic configure node node1 delete node1 node node1 \ attributes mem=16G node pingnode:ping -primitive st stonith:null \ +primitive st stonith:ssh \ params hostlist='node1' \ - meta yoyo-meta="yoyo 2" \ - op start requires=nothing \ - op monitor interval=60m + meta target-role="Started" \ + op start requires=nothing timeout=60s \ + op monitor interval=60m timeout=60s primitive d1 ocf:heartbeat:Dummy \ operations $id=d1-ops \ op monitor interval=60m \ op monitor interval=120m OCF_CHECK_LEVEL=10 monitor d1 60s:30s primitive d2 ocf:heartbeat:Delay \ - params mondelay=60 + params mondelay=60 \ + op start timeout=60s \ + op stop timeout=60s monitor d2:Started 60s:30s group g1 d1 d2 primitive d3 ocf:heartbeat:Dummy clone c d3 \ meta clone-max=1 primitive d4 ocf:heartbeat:Dummy ms m d4 delete m master m d4 primitive d5 ocf:heartbeat:Dummy \ operations $id-ref=d1-ops primitive d6 ocf:heartbeat:Dummy \ operations $id-ref=d1 location l1 g1 100: node1 location l2 c \ rule $id=l2-rule1 100: #uname eq node1 location l3 d5 \ rule inf: #uname eq node1 and pingd gt 0 location l4 d5 \ rule -inf: not_defined pingd or pingd lte 0 location l5 d5 \ rule -inf: not_defined pingd or pingd lte 0 \ rule inf: #uname eq node1 and pingd gt 0 \ rule inf: date lt "2009-05-26" and \ date in_range start="2009-05-26" end="2009-07-26" and \ date in_range start="2009-05-26" years="2009" and \ date date_spec years="2009" hours="09-17" location l6 d5 \ rule $id-ref=l2-rule1 location l7 d5 \ rule $id-ref=l2 collocation c1 inf: d5 d6 collocation c2 inf: d5:Started d6:Started order o1 mandatory: d5 d6 order o2 advisory: d5:start d6:promote property stonith-enabled=true property $id=cpset2 maintenance-mode=true rsc_defaults failure-timeout=10m op_defaults $id=opsdef2 record-pending=true _test verify . diff --git a/shell/regression/testcases/confbasic-xml b/shell/regression/testcases/confbasic-xml index fa408abd2e..896b90ba0a 100644 --- a/shell/regression/testcases/confbasic-xml +++ b/shell/regression/testcases/confbasic-xml @@ -1,60 +1,62 @@ showxml Basic configure (xml dump) node node1 delete node1 node node1 \ attributes mem=16G node pingnode:ping -primitive st stonith:null \ +primitive st stonith:ssh \ params hostlist='node1' \ - meta yoyo-meta="yoyo 2" \ - op start requires=nothing \ - op monitor interval=60m + meta target-role="Started" \ + op start requires=nothing timeout=60s \ + op monitor interval=60m timeout=60s primitive d1 ocf:heartbeat:Dummy \ operations $id=d1-ops \ op monitor interval=60m \ op monitor interval=120m OCF_CHECK_LEVEL=10 monitor d1 60s:30s primitive d2 ocf:heartbeat:Delay \ - params mondelay=60 + params mondelay=60 \ + op start timeout=60s \ + op stop timeout=60s monitor d2:Started 60s:30s group g1 d1 d2 primitive d3 ocf:heartbeat:Dummy clone c d3 \ meta clone-max=1 primitive d4 ocf:heartbeat:Dummy ms m d4 delete m master m d4 primitive d5 ocf:heartbeat:Dummy \ operations $id-ref=d1-ops primitive d6 ocf:heartbeat:Dummy \ operations $id-ref=d1 location l1 g1 100: node1 location l2 c \ rule $id=l2-rule1 100: #uname eq node1 location l3 d5 \ rule inf: #uname eq node1 and pingd gt 0 location l4 d5 \ rule -inf: not_defined pingd or pingd lte 0 location l5 d5 \ rule -inf: not_defined pingd or pingd lte 0 \ rule inf: #uname eq node1 and pingd gt 0 \ rule inf: date lt "2009-05-26" and \ date in_range start="2009-05-26" end="2009-07-26" and \ date in_range start="2009-05-26" years="2009" and \ date date_spec years="2009" hours="09-17" location l6 d5 \ rule $id-ref=l2-rule1 location l7 d5 \ rule $id-ref=l2 collocation c1 inf: d5 d6 collocation c2 inf: d5:Started d6:Started order o1 mandatory: d5 d6 order o2 advisory: d5:start d6:promote property stonith-enabled=true property $id=cpset2 maintenance-mode=true rsc_defaults failure-timeout=10m op_defaults $id=opsdef2 record-pending=true _test verify . diff --git a/shell/regression/testcases/confbasic-xml.exp b/shell/regression/testcases/confbasic-xml.exp index 2d0c118d85..f59021b383 100644 --- a/shell/regression/testcases/confbasic-xml.exp +++ b/shell/regression/testcases/confbasic-xml.exp @@ -1,130 +1,133 @@ + - - - + + + + - - - - + + - + + + + - + - - + + - - - + + + - - - - - - - - - - - + - + - - + + + + + + + + + + + + - - - - - - + + + + + + - \ No newline at end of file + diff --git a/shell/regression/testcases/confbasic.exp b/shell/regression/testcases/confbasic.exp index acdba35e33..92953e7f81 100644 --- a/shell/regression/testcases/confbasic.exp +++ b/shell/regression/testcases/confbasic.exp @@ -1,95 +1,97 @@ .TRY Basic configure .INP: configure .INP: _regtest on .INP: erase .INP: erase nodes .INP: node node1 .INP: delete node1 .INP: node node1 attributes mem=16G .INP: node pingnode:ping -.INP: primitive st stonith:null params hostlist='node1' meta yoyo-meta="yoyo 2" op start requires=nothing op monitor interval=60m +.INP: primitive st stonith:ssh params hostlist='node1' meta target-role="Started" op start requires=nothing timeout=60s op monitor interval=60m timeout=60s .INP: primitive d1 ocf:heartbeat:Dummy operations $id=d1-ops op monitor interval=60m op monitor interval=120m OCF_CHECK_LEVEL=10 .INP: monitor d1 60s:30s -.INP: primitive d2 ocf:heartbeat:Delay params mondelay=60 +.INP: primitive d2 ocf:heartbeat:Delay params mondelay=60 op start timeout=60s op stop timeout=60s .INP: monitor d2:Started 60s:30s .INP: group g1 d1 d2 .INP: primitive d3 ocf:heartbeat:Dummy .INP: clone c d3 meta clone-max=1 .INP: primitive d4 ocf:heartbeat:Dummy .INP: ms m d4 .INP: delete m .INP: master m d4 .INP: primitive d5 ocf:heartbeat:Dummy operations $id-ref=d1-ops .INP: primitive d6 ocf:heartbeat:Dummy operations $id-ref=d1 .INP: location l1 g1 100: node1 .INP: location l2 c rule $id=l2-rule1 100: #uname eq node1 .INP: location l3 d5 rule inf: #uname eq node1 and pingd gt 0 .INP: location l4 d5 rule -inf: not_defined pingd or pingd lte 0 .INP: location l5 d5 rule -inf: not_defined pingd or pingd lte 0 rule inf: #uname eq node1 and pingd gt 0 rule inf: date lt "2009-05-26" and date in_range start="2009-05-26" end="2009-07-26" and date in_range start="2009-05-26" years="2009" and date date_spec years="2009" hours="09-17" .INP: location l6 d5 rule $id-ref=l2-rule1 .INP: location l7 d5 rule $id-ref=l2 .INP: collocation c1 inf: d5 d6 .INP: collocation c2 inf: d5:Started d6:Started .INP: order o1 mandatory: d5 d6 .INP: order o2 advisory: d5:start d6:promote .INP: property stonith-enabled=true .INP: property $id=cpset2 maintenance-mode=true .INP: rsc_defaults failure-timeout=10m .INP: op_defaults $id=opsdef2 record-pending=true .INP: _test .INP: verify .INP: show node node1 \ attributes mem="16G" node pingnode:ping primitive d1 ocf:heartbeat:Dummy \ operations $id="d1-ops" \ op monitor interval="60m" \ op monitor interval="120m" OCF_CHECK_LEVEL="10" \ op monitor interval="60s" timeout="30s" primitive d2 ocf:heartbeat:Delay \ params mondelay="60" \ + op start interval="0" timeout="60s" \ + op stop interval="0" timeout="60s" \ op monitor interval="60s" role="Started" timeout="30s" primitive d3 ocf:heartbeat:Dummy primitive d4 ocf:heartbeat:Dummy primitive d5 ocf:heartbeat:Dummy \ operations $id-ref="d1-ops" primitive d6 ocf:heartbeat:Dummy \ operations $id-ref="d1-ops" -primitive st stonith:null \ +primitive st stonith:ssh \ params hostlist="node1" \ - meta yoyo-meta="yoyo 2" \ - op start interval="0" requires="nothing" \ - op monitor interval="60m" + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" group g1 d1 d2 ms m d4 clone c d3 \ meta clone-max="1" location l1 g1 100: node1 location l2 c \ rule $id="l2-rule1" 100: #uname eq node1 location l3 d5 \ rule $id="l3-rule" inf: #uname eq node1 and pingd gt 0 location l4 d5 \ rule $id="l4-rule" -inf: not_defined pingd or pingd lte 0 location l5 d5 \ rule $id="l5-rule" -inf: not_defined pingd or pingd lte 0 \ rule $id="l5-rule-0" inf: #uname eq node1 and pingd gt 0 \ rule $id="l5-rule-1" inf: date lt "2009-05-26" and date in_range start="2009-05-26" end="2009-07-26" and date in_range start="2009-05-26" years="2009" and date date_spec hours="09-17" years="2009" location l6 d5 \ rule $id-ref="l2-rule1" location l7 d5 \ rule $id-ref="l2-rule1" colocation c1 inf: d5 d6 colocation c2 inf: d5:Started d6:Started order o1 inf: d5 d6 order o2 0: d5:start d6:promote property $id="cib-bootstrap-options" \ stonith-enabled="true" property $id="cpset2" \ maintenance-mode="true" rsc_defaults $id="rsc-options" \ failure-timeout="10m" op_defaults $id="opsdef2" \ record-pending="true" .INP: commit diff --git a/shell/regression/testcases/delete b/shell/regression/testcases/delete index 661dfd5972..f258a52007 100644 --- a/shell/regression/testcases/delete +++ b/shell/regression/testcases/delete @@ -1,59 +1,63 @@ session Delete/Rename test configure # erase to start from scratch erase erase nodes # create one stonith so that verify does not complain -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist='node1' \ + meta target-role="Started" \ + op start requires=nothing timeout=60s \ + op monitor interval=60m timeout=60s primitive d1 ocf:heartbeat:Dummy primitive d2 ocf:heartbeat:Dummy location d1-pref d1 100: node1 show _test rename d1 p1 show # delete primitive delete d2 _test show # delete primitive with constraint delete p1 _test show primitive d1 ocf:heartbeat:Dummy location d1-pref d1 100: node1 _test # delete primitive belonging to a group primitive d2 ocf:heartbeat:Dummy _test group g1 d2 d1 delete d2 show _test delete g1 show verify # delete a group which is in a clone primitive d2 ocf:heartbeat:Dummy group g1 d2 d1 clone c1 g1 delete g1 show _test group g1 d2 d1 clone c1 g1 _test # delete group from a clone (again) delete g1 show _test group g1 d2 d1 clone c1 g1 # delete primitive and its group and their clone delete d2 d1 c1 g1 show _test # verify verify commit . diff --git a/shell/regression/testcases/delete.exp b/shell/regression/testcases/delete.exp index 1c35f0bc09..7b10766de1 100644 --- a/shell/regression/testcases/delete.exp +++ b/shell/regression/testcases/delete.exp @@ -1,103 +1,139 @@ .TRY Delete/Rename test .INP: configure .INP: # erase to start from scratch .INP: erase .INP: erase nodes .INP: # create one stonith so that verify does not complain -.INP: primitive st stonith:ssh +.INP: primitive st stonith:ssh params hostlist='node1' meta target-role="Started" op start requires=nothing timeout=60s op monitor interval=60m timeout=60s .INP: primitive d1 ocf:heartbeat:Dummy .INP: primitive d2 ocf:heartbeat:Dummy .INP: location d1-pref d1 100: node1 .INP: show primitive d1 ocf:heartbeat:Dummy primitive d2 ocf:heartbeat:Dummy -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" location d1-pref d1 100: node1 .INP: _test .INP: rename d1 p1 INFO: 12: resource references in location:d1-pref updated .INP: show primitive d2 ocf:heartbeat:Dummy primitive p1 ocf:heartbeat:Dummy -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" location d1-pref p1 100: node1 .INP: # delete primitive .INP: delete d2 .INP: _test .INP: show primitive p1 ocf:heartbeat:Dummy -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" location d1-pref p1 100: node1 .INP: # delete primitive with constraint .INP: delete p1 INFO: 19: hanging location:d1-pref deleted .INP: _test .INP: show -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" .INP: primitive d1 ocf:heartbeat:Dummy .INP: location d1-pref d1 100: node1 .INP: _test .INP: # delete primitive belonging to a group .INP: primitive d2 ocf:heartbeat:Dummy .INP: _test .INP: group g1 d2 d1 INFO: 28: resource references in location:d1-pref updated .INP: delete d2 .INP: show primitive d1 ocf:heartbeat:Dummy -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" group g1 d1 location d1-pref g1 100: node1 .INP: _test .INP: delete g1 INFO: 32: resource references in location:d1-pref updated .INP: show primitive d1 ocf:heartbeat:Dummy -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" location d1-pref d1 100: node1 .INP: verify .INP: # delete a group which is in a clone .INP: primitive d2 ocf:heartbeat:Dummy .INP: group g1 d2 d1 INFO: 37: resource references in location:d1-pref updated .INP: clone c1 g1 INFO: 38: resource references in location:d1-pref updated .INP: delete g1 INFO: 39: resource references in location:d1-pref updated INFO: 39: resource references in location:d1-pref updated .INP: show primitive d1 ocf:heartbeat:Dummy primitive d2 ocf:heartbeat:Dummy -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" location d1-pref d2 100: node1 .INP: _test .INP: group g1 d2 d1 INFO: 42: resource references in location:d1-pref updated .INP: clone c1 g1 INFO: 43: resource references in location:d1-pref updated .INP: _test .INP: # delete group from a clone (again) .INP: delete g1 INFO: 46: resource references in location:d1-pref updated INFO: 46: resource references in location:d1-pref updated .INP: show primitive d1 ocf:heartbeat:Dummy primitive d2 ocf:heartbeat:Dummy -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" location d1-pref d2 100: node1 .INP: _test .INP: group g1 d2 d1 INFO: 49: resource references in location:d1-pref updated .INP: clone c1 g1 INFO: 50: resource references in location:d1-pref updated .INP: # delete primitive and its group and their clone .INP: delete d2 d1 c1 g1 INFO: 52: resource references in location:d1-pref updated INFO: 52: resource references in location:d1-pref updated INFO: 52: hanging location:d1-pref deleted .INP: show -primitive st stonith:ssh +primitive st stonith:ssh \ + params hostlist="node1" \ + meta target-role="Started" \ + op start interval="0" timeout="60s" requires="nothing" \ + op monitor interval="60m" timeout="60s" .INP: _test .INP: # verify .INP: verify .INP: commit diff --git a/shell/regression/testcases/file.exp b/shell/regression/testcases/file.exp index b1b84910a0..d5b0b12465 100644 --- a/shell/regression/testcases/file.exp +++ b/shell/regression/testcases/file.exp @@ -1,31 +1,35 @@ .TRY configure save sample.txt .EXT cat sample.txt node node1 primitive p0 ocf:heartbeat:Dummy primitive p1 ocf:heartbeat:Dummy primitive p2 ocf:heartbeat:Delay \ params startdelay="2" mondelay="2" stopdelay="2" primitive p3 ocf:heartbeat:Dummy primitive st stonith:null \ params hostlist="node1" ms m1 p2 clone c1 p1 +property $id="cib-bootstrap-options" \ + default-action-timeout="60s" .TRY configure erase nodes .TRY configure load replace sample.txt .TRY Load update .INP: configure .INP: erase .INP: erase nodes .INP: load update sample.txt .TRY configure show node node1 primitive p0 ocf:heartbeat:Dummy primitive p1 ocf:heartbeat:Dummy primitive p2 ocf:heartbeat:Delay \ params startdelay="2" mondelay="2" stopdelay="2" primitive p3 ocf:heartbeat:Dummy primitive st stonith:null \ params hostlist="node1" ms m1 p2 clone c1 p1 +property $id="cib-bootstrap-options" \ + default-action-timeout="60s" .EXT rm sample.txt diff --git a/shell/regression/testcases/ra b/shell/regression/testcases/ra index 11b92f0b34..1a64d40a44 100644 --- a/shell/regression/testcases/ra +++ b/shell/regression/testcases/ra @@ -1,8 +1,7 @@ session RA interface ra providers IPaddr providers Dummy -info IPaddr ocf -info external/ssh stonith -info lrmregtest lsb +info IPaddr +info stonith:external/ssh . diff --git a/shell/regression/testcases/ra.exp b/shell/regression/testcases/ra.exp index d3e8fc90ed..b9af2791d0 100644 --- a/shell/regression/testcases/ra.exp +++ b/shell/regression/testcases/ra.exp @@ -1,114 +1,102 @@ .TRY RA interface .INP: ra .INP: providers IPaddr heartbeat .INP: providers Dummy heartbeat pacemaker -.INP: info IPaddr ocf +.INP: info IPaddr Manages virtual IPv4 addresses (portable version) (ocf:heartbeat:IPaddr) This script manages IP alias IP addresses It can add an IP alias, or remove one. Parameters (* denotes required, [] the default): ip* (string): IPv4 address The IPv4 address to be configured in dotted quad notation, for example "192.168.1.1". nic (string, [eth0]): Network interface The base network interface on which the IP address will be brought online. If left empty, the script will try and determine this from the routing table. Do NOT specify an alias interface in the form eth0:1 or anything here; rather, specify the base interface only. cidr_netmask (string): Netmask The netmask for the interface in CIDR format. (ie, 24), or in dotted quad notation 255.255.255.0). If unspecified, the script will also try to determine this from the routing table. broadcast (string): Broadcast address Broadcast address associated with the IP. If left empty, the script will determine this from the netmask. iflabel (string): Interface label You can specify an additional label for your IP address here. lvs_support (boolean, [false]): Enable support for LVS DR Enable support for LVS Direct Routing configurations. In case a IP address is stopped, only move it to the loopback device to allow the local node to continue to service requests, but no longer advertise it on the network. local_stop_script (string): Script called when the IP is released local_start_script (string): Script called when the IP is added ARP_INTERVAL_MS (integer, [500]): milliseconds between gratuitous ARPs milliseconds between ARPs ARP_REPEAT (integer, [10]): repeat count How many gratuitous ARPs to send out when bringing up a new address ARP_BACKGROUND (boolean, [yes]): run in background run in background (no longer any reason to do this) ARP_NETMASK (string, [ffffffffffff]): netmask for ARP netmask for ARP - in nonstandard hexadecimal format. Operations' defaults (advisory minimum): - start timeout=90 - stop timeout=100 + start timeout=20s + stop timeout=20s monitor_0 interval=5s timeout=20s -.INP: info external/ssh stonith +.INP: info stonith:external/ssh ssh STONITH external device (stonith:external/ssh) ssh-based Linux host reset Fine for testing, but not suitable for production! +Only reboot action supported, no poweroff, and, surprisingly enough, no poweron. Parameters (* denotes required, [] the default): hostlist* (string): Hostlist The list of hosts that the STONITH device controls livedangerously (enum): Live Dangerously!! Set to "yes" if you want to risk your system's integrity. Of course, since this plugin isn't for production, using it in production at all is a bad idea. On the other hand, setting this parameter to yes makes it an even worse idea. Viva la Vida Loca! stonith-timeout (time, [60s]): How long to wait for the STONITH action to complete. Overrides the stonith-timeout cluster property priority (integer, [0]): The priority of the stonith resource. The lower the number, the higher the priority. Operations' defaults (advisory minimum): - start timeout=15 + start timeout=60 stop timeout=15 - status timeout=15 - monitor_0 interval=15 timeout=15 start-delay=15 -.INP: info lrmregtest lsb -lsb:lrmregtest - -lrmregtest - -Operations' defaults (advisory minimum): - - start timeout=15 - stop timeout=15 - status timeout=15 - restart timeout=15 - force-reload timeout=15 - monitor_0 interval=15 timeout=15 start-delay=15 + status timeout=60 + monitor_0 interval=3600 timeout=60 diff --git a/tools/ccm_epoche.c b/tools/ccm_epoche.c index 1c604e5ea8..ec424c722a 100644 --- a/tools/ccm_epoche.c +++ b/tools/ccm_epoche.c @@ -1,446 +1,447 @@ /* * Copyright (C) 2004 Andrew Beekhof * * 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 */ #include #include #include #include #include #include #include #include #include /* for basename() */ #include #include #include #include int command = 0; int ccm_fd = 0; int try_hb = 1; int try_ais = 1; gboolean do_quiet = FALSE; char *target_uuid = NULL; char *target_uname = NULL; const char *standby_value = NULL; const char *standby_scope = NULL; void ais_membership_destroy(gpointer user_data); gboolean ais_membership_dispatch(AIS_Message *wrapper, char *data, int sender); #include <../lib/common/stack.h> #if SUPPORT_HEARTBEAT # include # include # include # define UUID_LEN 16 oc_ev_t *ccm_token = NULL; void oc_ev_special(const oc_ev_t *, oc_ev_class_t , int ); void ccm_age_callback( oc_ed_t event, void *cookie, size_t size, const void *data); gboolean ccm_age_connect(int *ccm_fd); static int read_local_hb_uuid(void) { int rc = 0; cl_uuid_t uuid; char *buffer = NULL; long start = 0, read_len = 0; FILE *input = fopen(UUID_FILE, "r"); if(input == NULL) { cl_perror("Could not open UUID file %s\n", UUID_FILE); return 1; } /* see how big the file is */ start = ftell(input); fseek(input, 0L, SEEK_END); if(UUID_LEN != ftell(input)) { fprintf(stderr, "%s must contain exactly %d bytes\n", UUID_FILE, UUID_LEN); abort(); } fseek(input, 0L, start); if(start != ftell(input)) { fprintf(stderr, "fseek not behaving: %ld vs. %ld\n", start, ftell(input)); rc = 2; goto bail; } buffer = malloc(50); read_len = fread(uuid.uuid, 1, UUID_LEN, input); if(read_len != UUID_LEN) { fprintf(stderr, "Expected and read bytes differ: %d vs. %ld\n", UUID_LEN, read_len); rc = 3; goto bail; } else if(buffer != NULL) { cl_uuid_unparse(&uuid, buffer); fprintf(stdout, "%s\n", buffer); } else { fprintf(stderr, "No buffer to unparse\n"); rc = 4; } bail: free(buffer); fclose(input); return rc; } #endif static struct crm_option long_options[] = { /* Top-level Options */ {"help", 0, 0, '?', "\tThis text"}, {"version", 0, 0, '$', "\tVersion information" }, {"verbose", 0, 0, 'V', "\tIncrease debug output"}, {"quiet", 0, 0, 'Q', "\tEssential output only"}, {"-spacer-", 1, 0, '-', "\nStack:", SUPPORT_HEARTBEAT}, {"openais", 0, 0, 'A', "\tOnly try connecting to an OpenAIS-based cluster", SUPPORT_HEARTBEAT}, {"heartbeat", 0, 0, 'H', "Only try connecting to a Heartbeat-based cluster", SUPPORT_HEARTBEAT}, {"-spacer-", 1, 0, '-', "\nCommands:"}, {"epoch", 0, 0, 'e', "\tDisplay the epoch during which this node joined the cluster"}, {"quorum", 0, 0, 'q', "\tDisplay a 1 if our partition has quorum, 0 if not"}, {"list", 0, 0, 'l', "(AIS-Only) Display all known members (past and present) of this cluster"}, {"partition", 0, 0, 'p', "Display the members of this partition"}, {"cluster-id", 0, 0, 'i', "Display this node's cluster id"}, {"remove", 1, 0, 'R', "(Advanced, AIS-Only) Remove the (stopped) node with the specified nodeid from the cluster"}, {"-spacer-", 1, 0, '-', "\nAdditional Options:"}, {"force", 0, 0, 'f'}, {0, 0, 0, 0} }; int local_id = 0; int main(int argc, char ** argv) { int flag = 0; int argerr = 0; gboolean force_flag = FALSE; gboolean dangerous_cmd = FALSE; int option_index = 0; crm_peer_init(); crm_log_init(basename(argv[0]), LOG_WARNING, FALSE, FALSE, argc, argv); crm_set_options("?V$qepHR:ifl", "command [options]", long_options, "Tool for displaying low-level node information"); while (flag >= 0) { flag = crm_get_option(argc, argv, &option_index); switch(flag) { case -1: break; case 'V': cl_log_enable_stderr(TRUE); alter_debug(DEBUG_INC); break; case '$': case '?': crm_help(flag, LSB_EXIT_OK); break; case 'Q': do_quiet = TRUE; break; case 'H': try_ais = 0; break; case 'A': try_hb = 0; break; case 'f': force_flag = TRUE; break; case 'R': dangerous_cmd = TRUE; command = flag; target_uname = optarg; break; case 'p': case 'e': case 'q': case 'i': case 'l': command = flag; break; default: ++argerr; break; } } if (optind > argc) { ++argerr; } if (argerr) { crm_help('?', LSB_EXIT_GENERIC); } if(dangerous_cmd && force_flag == FALSE) { fprintf(stderr, "The supplied command is considered dangerous." " To prevent accidental destruction of the cluster," " the --force flag is required in order to proceed.\n"); fflush(stderr); exit(LSB_EXIT_GENERIC); } #if SUPPORT_AIS if(try_ais && init_ais_connection( ais_membership_dispatch, ais_membership_destroy, NULL, NULL, &local_id)) { GMainLoop* amainloop = NULL; switch(command) { case 'R': send_ais_text(crm_class_rmpeer, target_uname, TRUE, NULL, crm_msg_ais); return 0; case 'e': /* Age makes no sense (yet) in an AIS cluster */ fprintf(stdout, "1\n"); return 0; case 'q': send_ais_text(crm_class_quorum, NULL, TRUE, NULL, crm_msg_ais); break; case 'l': case 'p': crm_info("Requesting the list of configured nodes"); send_ais_text(crm_class_members, __FUNCTION__, TRUE, NULL, crm_msg_ais); break; case 'i': printf("%d\n", local_id); + return 0; default: fprintf(stderr, "Unknown option '%c'\n", command); crm_help('?', LSB_EXIT_GENERIC); } amainloop = g_main_new(FALSE); g_main_run(amainloop); } #endif #if SUPPORT_HEARTBEAT if(try_hb && command == 'i') { return read_local_hb_uuid(); } else if(try_hb && ccm_age_connect(&ccm_fd)) { int rc = 0; fd_set rset; oc_ev_t *ccm_token = NULL; while (1) { sleep(1); FD_ZERO(&rset); FD_SET(ccm_fd, &rset); errno = 0; rc = select(ccm_fd + 1, &rset, NULL,NULL,NULL); if(rc > 0 && oc_ev_handle_event(ccm_token) != 0) { crm_err("oc_ev_handle_event failed"); return 1; } else if(rc < 0 && errno != EINTR) { crm_perror(LOG_ERR, "select failed"); return 1; } } } #endif return(1); } #if SUPPORT_HEARTBEAT gboolean ccm_age_connect(int *ccm_fd) { gboolean did_fail = FALSE; int ret = 0; crm_debug("Registering with CCM"); ret = oc_ev_register(&ccm_token); if (ret != 0) { crm_warn("CCM registration failed"); did_fail = TRUE; } if(did_fail == FALSE) { crm_debug("Setting up CCM callbacks"); ret = oc_ev_set_callback(ccm_token, OC_EV_MEMB_CLASS, ccm_age_callback, NULL); if (ret != 0) { crm_warn("CCM callback not set"); did_fail = TRUE; } } if(did_fail == FALSE) { oc_ev_special(ccm_token, OC_EV_MEMB_CLASS, 0/*don't care*/); crm_debug("Activating CCM token"); ret = oc_ev_activate(ccm_token, ccm_fd); if (ret != 0){ crm_warn("CCM Activation failed"); did_fail = TRUE; } } return !did_fail; } void ccm_age_callback(oc_ed_t event, void *cookie, size_t size, const void *data) { int lpc; int node_list_size; const oc_ev_membership_t *oc = (const oc_ev_membership_t *)data; node_list_size = oc->m_n_member; if(command == 'q') { crm_debug("Processing \"%s\" event.", event==OC_EV_MS_NEW_MEMBERSHIP?"NEW MEMBERSHIP": event==OC_EV_MS_NOT_PRIMARY?"NOT PRIMARY": event==OC_EV_MS_PRIMARY_RESTORED?"PRIMARY RESTORED": event==OC_EV_MS_EVICTED?"EVICTED": "NO QUORUM MEMBERSHIP"); if(ccm_have_quorum(event)) { fprintf(stdout, "1\n"); } else { fprintf(stdout, "0\n"); } } else if(command == 'e') { crm_debug("Searching %d members for our birth", oc->m_n_member); } for(lpc=0; lpcm_array[oc->m_memb_idx+lpc].node_uname); } else if(command == 'e') { if(oc_ev_is_my_nodeid(ccm_token, &(oc->m_array[lpc]))){ crm_debug("MATCH: nodeid=%d, uname=%s, born=%d", oc->m_array[oc->m_memb_idx+lpc].node_id, oc->m_array[oc->m_memb_idx+lpc].node_uname, oc->m_array[oc->m_memb_idx+lpc].node_born_on); fprintf(stdout, "%d\n", oc->m_array[oc->m_memb_idx+lpc].node_born_on); } } } oc_ev_callback_done(cookie); if(command == 'p') { fprintf(stdout, "\n"); } fflush(stdout); exit(0); } #endif #if SUPPORT_AIS void ais_membership_destroy(gpointer user_data) { crm_err("AIS connection terminated"); ais_fd_sync = -1; exit(1); } #endif static gint member_sort(gconstpointer a, gconstpointer b) { const crm_node_t *node_a = a; const crm_node_t *node_b = b; return strcmp(node_a->uname, node_b->uname); } static void crm_add_member( gpointer key, gpointer value, gpointer user_data) { GList **list = user_data; crm_node_t *node = value; if(node->uname != NULL) { *list = g_list_insert_sorted(*list, node, member_sort); } } gboolean ais_membership_dispatch(AIS_Message *wrapper, char *data, int sender) { switch(wrapper->header.id) { case crm_class_members: case crm_class_notify: case crm_class_quorum: break; default: return TRUE; break; } if(command == 'q') { if(crm_have_quorum) { fprintf(stdout, "1\n"); } else { fprintf(stdout, "0\n"); } } else if(command == 'l') { GList *nodes = NULL; g_hash_table_foreach(crm_peer_cache, crm_add_member, &nodes); slist_iter(node, crm_node_t, nodes, lpc, fprintf(stdout, "%u %s %s\n", node->id, node->uname, node->state); ); fprintf(stdout, "\n"); } else if(command == 'p') { GList *nodes = NULL; g_hash_table_foreach(crm_peer_cache, crm_add_member, &nodes); slist_iter(node, crm_node_t, nodes, lpc, if(node->uname && crm_is_member_active(node)) { fprintf(stdout, "%s ", node->uname); } ); fprintf(stdout, "\n"); } exit(0); return TRUE; } diff --git a/tools/cib_shadow.c b/tools/cib_shadow.c index c7c9aab041..848c7376c0 100644 --- a/tools/cib_shadow.c +++ b/tools/cib_shadow.c @@ -1,556 +1,561 @@ /* * Copyright (C) 2004 Andrew Beekhof * * 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 */ #include #include #include #include #include #include #include #include #include #include #include #include #include int exit_code = cib_ok; GMainLoop *mainloop = NULL; IPC_Channel *crmd_channel = NULL; const char *host = NULL; void usage(const char *cmd, int exit_status); int command_options = cib_sync_call; const char *cib_action = NULL; cib_t *real_cib = NULL; int dump_data_element( int depth, char **buffer, int *max, int *offset, const char *prefix, xmlNode *data, gboolean formatted); void print_xml_diff(FILE *where, xmlNode *diff); static int force_flag = 0; static int batch_flag = 0; static char *get_shadow_prompt(const char *name) { int len = 16; char *prompt = NULL; CRM_ASSERT(name != NULL); len += strlen(name); crm_malloc0(prompt, len); snprintf(prompt, len, "shadow[%s] # ", name); return prompt; } static void shadow_setup(char *name, gboolean do_switch) { const char *prompt = getenv("PS1"); const char *shell = getenv("SHELL"); char *new_prompt = get_shadow_prompt(name); printf("Setting up shadow instance\n"); if(safe_str_eq(new_prompt, prompt)) { /* nothing to do */ goto done; } else if(batch_flag == FALSE && shell != NULL) { setenv("PS1", new_prompt, 1); setenv("CIB_shadow", name, 1); printf("Type Ctrl-D to exit the crm_shadow shell\n"); execl(shell, "--norc", "--noprofile", NULL); } else if (do_switch) { printf("To switch to the named shadow instance, paste the following into your shell:\n"); } else { printf("A new shadow instance was created. To begin using it paste the following into your shell:\n"); } printf(" CIB_shadow=%s ; export CIB_shadow\n", name); done: crm_free(new_prompt); } static void shadow_teardown(char *name) { const char *prompt = getenv("PS1"); char *our_prompt = get_shadow_prompt(name); if(prompt != NULL && strstr(prompt, our_prompt)) { printf("Now type Ctrl-D to exit the crm_shadow shell\n"); } else { printf("Please remember to unset the CIB_shadow variable by pasting the following into your shell:\n"); printf(" unset CIB_shadow\n"); } crm_free(our_prompt); } static struct crm_option long_options[] = { /* Top-level Options */ {"help", 0, 0, '?', "\t\tThis text"}, {"version", 0, 0, '$', "\t\tVersion information" }, {"verbose", 0, 0, 'V', "\t\tIncrease debug output"}, {"-spacer-", 1, 0, '-', "\nQueries:"}, {"which", no_argument, NULL, 'w', "\t\tIndicate the active shadow copy"}, - {"display", no_argument, NULL, 'p', "\t\tDisplay the contents of the shadow copy"}, - {"edit", no_argument, NULL, 'E', "\t\tEdit the contents of the named shadow copy with your favorite $EDITOR"}, - {"diff", no_argument, NULL, 'd', "\t\tDisplay the changes in the shadow copy\n"}, + {"display", no_argument, NULL, 'p', "\t\tDisplay the contents of the active shadow copy"}, + {"edit", no_argument, NULL, 'E', "\t\tEdit the contents of the active shadow copy with your favorite $EDITOR"}, + {"diff", no_argument, NULL, 'd', "\t\tDisplay the changes in the active shadow copy\n"}, + {"file", no_argument, NULL, 'F', "\t\tDisplay the location of the active shadow copy file\n"}, {"-spacer-", 1, 0, '-', "\nCommands:"}, {"create", required_argument, NULL, 'c', "\tCreate the named shadow copy of the active cluster configuration"}, {"create-empty", required_argument, NULL, 'e', "Create the named shadow copy with an empty cluster configuration"}, {"commit", required_argument, NULL, 'C', "\tUpload the contents of the named shadow copy to the cluster"}, {"delete", required_argument, NULL, 'D', "\tDelete the contents of the named shadow copy"}, {"reset", required_argument, NULL, 'r', "\tRecreate the named shadow copy from the active cluster configuration"}, {"switch", required_argument, NULL, 's', "\t(Advanced) Switch to the named shadow copy"}, {"-spacer-", 1, 0, '-', "\nAdditional Options:"}, {"force", no_argument, NULL, 'f', "\t\t(Advanced) Force the action to be performed"}, {"batch", no_argument, NULL, 'b', "\t\t(Advanced) Don't spawn a new shell" }, {"-spacer-", 1, 0, '-', "\nExamples:", pcmk_option_paragraph}, {"-spacer-", 1, 0, '-', "Create a blank shadow configuration:", pcmk_option_paragraph}, {"-spacer-", 1, 0, '-', " crm_shadow --create-empty myShadow", pcmk_option_example}, {"-spacer-", 1, 0, '-', "Create a shadow configuration from the running cluster:", pcmk_option_paragraph}, {"-spacer-", 1, 0, '-', " crm_shadow --create myShadow", pcmk_option_example}, {"-spacer-", 1, 0, '-', "Display the current shadow configuration:", pcmk_option_paragraph}, {"-spacer-", 1, 0, '-', " crm_shadow --display", pcmk_option_example}, {"-spacer-", 1, 0, '-', "Discard the current shadow configuration (named myShadow):", pcmk_option_paragraph}, {"-spacer-", 1, 0, '-', " crm_shadow --delete myShadow", pcmk_option_example}, {"-spacer-", 1, 0, '-', "Upload the current shadow configuration (named myShadow) to the running cluster:", pcmk_option_paragraph}, {"-spacer-", 1, 0, '-', " crm_shadow --commit myShadow", pcmk_option_example}, {0, 0, 0, 0} }; int main(int argc, char **argv) { int rc = 0; int flag; int argerr = 0; static int command = '?'; char *shadow = NULL; char *shadow_file = NULL; gboolean dangerous_cmd = FALSE; struct stat buf; int option_index = 0; crm_log_init("crm_shadow", LOG_CRIT, FALSE, FALSE, argc, argv); - crm_set_options("V$?bfwc:dr:C:D:ps:Ee:", "(query|command) [modifiers]", long_options, + crm_set_options("V$?bfwc:dr:C:D:ps:Ee:F", "(query|command) [modifiers]", long_options, "Perform configuration changes in a sandbox before updating the live cluster." "\n\nSets up an environment in which configuration tools (cibadmin, crm_resource, etc) work" " offline instead of against a live cluster, allowing changes to be previewed and tested" " for side-effects.\n"); if(argc < 2) { crm_help('?', LSB_EXIT_EINVAL); } while (1) { flag = crm_get_option(argc, argv, &option_index); if (flag == -1 || flag == 0) break; switch(flag) { case 'd': case 'E': case 'p': case 'w': + case 'F': command = flag; shadow = crm_strdup(getenv("CIB_shadow")); break; case 'e': case 'c': case 's': case 'r': command = flag; shadow = crm_strdup(optarg); break; case 'C': case 'D': command = flag; dangerous_cmd = TRUE; shadow = crm_strdup(optarg); break; case 'V': command_options = command_options | cib_verbose; cl_log_enable_stderr(TRUE); alter_debug(DEBUG_INC); break; case '$': case '?': crm_help(flag, LSB_EXIT_OK); break; case 'f': command_options |= cib_quorum_override; force_flag = 1; break; case 'b': batch_flag = 1; break; default: printf("Argument code 0%o (%c)" " is not (?yet?) supported\n", flag, flag); ++argerr; break; } } if (optind < argc) { printf("non-option ARGV-elements: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); crm_help('?', LSB_EXIT_EINVAL); } if (optind > argc) { ++argerr; } if (argerr) { crm_help('?', LSB_EXIT_GENERIC); } if(command == 'w') { /* which shadow instance is active? */ const char *local = getenv("CIB_shadow"); if(local == NULL) { fprintf(stderr, "No shadow instance provided\n"); return cib_NOTEXISTS; } fprintf(stdout, "%s\n", local); return 0; } if(shadow == NULL) { fprintf(stderr, "No shadow instance provided\n"); fflush(stderr); return CIBRES_MISSING_FIELD; } else if(command != 's' && command != 'c') { const char *local = getenv("CIB_shadow"); if(local != NULL && safe_str_neq(local, shadow) && force_flag == FALSE) { fprintf(stderr, "The supplied shadow instance (%s) is not the same as the active one (%s).\n" " To prevent accidental destruction of the cluster," " the --force flag is required in order to proceed.\n", shadow, local); fflush(stderr); exit(LSB_EXIT_GENERIC); } } if(dangerous_cmd && force_flag == FALSE) { fprintf(stderr, "The supplied command is considered dangerous." " To prevent accidental destruction of the cluster," " the --force flag is required in order to proceed.\n"); fflush(stderr); exit(LSB_EXIT_GENERIC); } shadow_file = get_shadow_file(shadow); if(command == 'D') { /* delete the file */ rc = stat(shadow_file, &buf); if(rc == 0) { rc = unlink(shadow_file); if(rc != 0) { fprintf(stderr, "Could not remove shadow instance '%s': %s\n", shadow, strerror(errno)); return rc; } } shadow_teardown(shadow); return rc; + } else if(command == 'F') { + printf("%s\n", shadow_file); + return 0; } if(command == 'd' || command == 'r' || command == 'c' || command == 'C') { real_cib = cib_new_no_shadow(); rc = real_cib->cmds->signon(real_cib, crm_system_name, cib_command); if(rc != cib_ok) { fprintf(stderr, "Signon to CIB failed: %s\n", cib_error2string(rc)); return rc; } } rc = stat(shadow_file, &buf); if(command == 'e' || command == 'c') { if (rc == 0 && force_flag == FALSE) { fprintf(stderr, "A shadow instance '%s' already exists.\n" " To prevent accidental destruction of the cluster," " the --force flag is required in order to proceed.\n", shadow); return cib_EXISTS; } } else if(rc != 0) { fprintf(stderr, "Could not access shadow instance '%s': %s\n", shadow, strerror(errno)); return cib_NOTEXISTS; } rc = cib_ok; if(command == 'c' || command == 'e') { xmlNode *output = NULL; /* create a shadow instance based on the current cluster config */ if(command == 'c') { rc = real_cib->cmds->query(real_cib, NULL, &output, command_options); if(rc != cib_ok) { fprintf(stderr, "Could not connect to the CIB: %s\n", cib_error2string(rc)); return rc; } } else { output = createEmptyCib(); crm_xml_add(output, XML_ATTR_GENERATION, "0"); crm_xml_add(output, XML_ATTR_NUMUPDATES, "0"); crm_xml_add(output, XML_ATTR_GENERATION_ADMIN, "0"); crm_xml_add(output, XML_ATTR_VALIDATION, LATEST_SCHEMA_VERSION); } rc = write_xml_file(output, shadow_file, FALSE); if(rc < 0) { fprintf(stderr, "Could not create the shadow instance '%s': %s\n", shadow, strerror(errno)); return rc; } shadow_setup(shadow, FALSE); rc = cib_ok; } else if(command == 'E') { const char *err = NULL; char *editor = getenv("EDITOR"); if(editor == NULL) { fprintf(stderr, "No value for $EDITOR defined\n"); return cib_missing; } execlp(editor, "--", shadow_file, NULL); err = strerror(errno); fprintf(stderr, "Could not invoke $EDITOR (%s %s)\n", editor, shadow_file); return cib_missing; } else if(command == 's') { shadow_setup(shadow, TRUE); return 0; } else if(command == 'P') { /* display the current contents */ char *output_s = NULL; xmlNode *output = filename2xml(shadow_file); output_s = dump_xml_formatted(output); printf("%s", output_s); crm_free(output_s); free_xml(output); } else if(command == 'd') { /* diff against cluster */ xmlNode *diff = NULL; xmlNode *old_config = NULL; xmlNode *new_config = filename2xml(shadow_file); rc = real_cib->cmds->query(real_cib, NULL, &old_config, command_options); if(rc != cib_ok) { fprintf(stderr, "Could not query the CIB: %s\n", cib_error2string(rc)); return rc; } diff = diff_xml_object(old_config, new_config, FALSE); if(diff != NULL) { print_xml_diff(stdout, diff); return 1; } return 0; } else if(command == 'C') { /* commit to the cluster */ xmlNode *input = filename2xml(shadow_file); rc = real_cib->cmds->replace(real_cib, NULL, input, command_options); if(rc != cib_ok) { fprintf(stderr, "Could not commit shadow instance '%s' to the CIB: %s\n", shadow, cib_error2string(rc)); return rc; } shadow_teardown(shadow); } return rc; } #define bhead(buffer, offset) ((*buffer) + (*offset)) #define bremain(max, offset) ((*max) - (*offset)) #define update_buffer_head(len) do { \ int total = (*offset) + len + 1; \ if(total >= (*max)) { /* too late */ \ (*buffer) = EOS; return -1; \ } else if(((*max) - total) < 256) { \ (*max) *= 10; \ crm_realloc(*buffer, (*max)); \ } \ (*offset) += len; \ } while(0) extern int print_spaces(char *buffer, int depth, int max); int dump_data_element( int depth, char **buffer, int *max, int *offset, const char *prefix, xmlNode *data, gboolean formatted) { int printed = 0; int has_children = 0; const char *name = NULL; CRM_CHECK(data != NULL, return 0); name = crm_element_name(data); CRM_CHECK(name != NULL, return 0); CRM_CHECK(buffer != NULL && *buffer != NULL, return 0); crm_debug_5("Dumping %s...", name); if(prefix) { printed = snprintf(bhead(buffer, offset), bremain(max, offset), "%s", prefix); update_buffer_head(printed); } if(formatted) { printed = print_spaces(bhead(buffer, offset), depth, bremain(max, offset)); update_buffer_head(printed); } printed = snprintf(bhead(buffer, offset), bremain(max, offset), "<%s", name); update_buffer_head(printed); xml_prop_iter(data, prop_name, prop_value, crm_debug_5("Dumping <%s %s=\"%s\"...", name, prop_name, prop_value); printed = snprintf(bhead(buffer, offset), bremain(max, offset), " %s=\"%s\"", prop_name, prop_value); update_buffer_head(printed); ); has_children = xml_has_children(data); printed = snprintf(bhead(buffer, offset), bremain(max, offset), "%s>%s", has_children==0?"/":"", formatted?"\n":""); update_buffer_head(printed); if(has_children == 0) { return 0; } xml_child_iter(data, child, if(dump_data_element(depth+1, buffer, max, offset, prefix, child, formatted) < 0) { return -1; } ); if(prefix) { printed = snprintf(bhead(buffer, offset), bremain(max, offset), "%s", prefix); update_buffer_head(printed); } if(formatted) { printed = print_spaces(bhead(buffer, offset), depth, bremain(max, offset)); update_buffer_head(printed); } printed = snprintf(bhead(buffer, offset), bremain(max, offset), "%s", name, formatted?"\n":""); update_buffer_head(printed); crm_debug_5("Dumped %s...", name); return has_children; } void print_xml_diff(FILE *where, xmlNode *diff) { char *buffer = NULL; int max = 1024, len = 0; gboolean is_first = TRUE; xmlNode *added = find_xml_node(diff, "diff-added", FALSE); xmlNode *removed = find_xml_node(diff, "diff-removed", FALSE); is_first = TRUE; xml_child_iter( removed, child, len = 0; max = 1024; crm_free(buffer); crm_malloc0(buffer, max); if(is_first) { is_first = FALSE; } else { fprintf(where, " --- \n"); } CRM_CHECK(dump_data_element( 0, &buffer, &max, &len, "-", child, TRUE) >= 0, continue); fprintf(where, "%s", buffer); ); is_first = TRUE; xml_child_iter( added, child, len = 0; max = 1024; crm_free(buffer); crm_malloc0(buffer, max); if(is_first) { is_first = FALSE; } else { fprintf(where, " +++ \n"); } CRM_CHECK(dump_data_element( 0, &buffer, &max, &len, "+", child, TRUE) >= 0, continue); fprintf(where, "%s", buffer); ); } diff --git a/tools/crm_inject.c b/tools/crm_inject.c index a46e48434f..0286675f59 100644 --- a/tools/crm_inject.c +++ b/tools/crm_inject.c @@ -1,1098 +1,1098 @@ /* * Copyright (C) 2009 Andrew Beekhof * * 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 */ #include #include #include #include #include #include #include #include #include #include #include #include #include cib_t *global_cib = NULL; GListPtr op_fail = NULL; gboolean quiet = FALSE; #define node_template "//"XML_CIB_TAG_STATE"[@uname='%s']" #define rsc_template "//"XML_CIB_TAG_STATE"[@uname='%s']//"XML_LRM_TAG_RESOURCE"[@id='%s']" #define op_template "//"XML_CIB_TAG_STATE"[@uname='%s']//"XML_LRM_TAG_RESOURCE"[@id='%s']/"XML_LRM_TAG_RSC_OP"[@id='%s']" /* #define op_template "//"XML_CIB_TAG_STATE"[@uname='%s']//"XML_LRM_TAG_RESOURCE"[@id='%s']/"XML_LRM_TAG_RSC_OP"[@id='%s' and @"XML_LRM_ATTR_CALLID"='%d']" */ #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" #define quiet_log(fmt, args...) do { \ if(quiet == FALSE) { \ printf(fmt , ##args); \ } \ } while(0) extern xmlNode * do_calculations( pe_working_set_t *data_set, xmlNode *xml_input, ha_time_t *now); static xmlNode *find_resource(xmlNode *cib_node, const char *resource) { char *xpath = NULL; xmlNode *match = NULL; const char *node = crm_element_value(cib_node, XML_ATTR_UNAME); int max = strlen(rsc_template) + strlen(resource) + strlen(node) + 1; crm_malloc0(xpath, max); snprintf(xpath, max, rsc_template, node, resource); match = get_xpath_object(xpath, cib_node, LOG_DEBUG_2); crm_free(xpath); return match; } static xmlNode *inject_node_state(cib_t *cib_conn, char *node) { int rc = cib_ok; int max = strlen(rsc_template) + strlen(node) + 1; char *xpath = NULL; xmlNode *cib_object = NULL; crm_malloc0(xpath, max); snprintf(xpath, max, node_template, node); rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object, cib_xpath|cib_sync_call|cib_scope_local); if(rc == cib_NOTEXISTS) { char *uuid = NULL; cib_object = create_xml_node(NULL, XML_CIB_TAG_STATE); determine_host(cib_conn, &node, &uuid); crm_xml_add(cib_object, XML_ATTR_UUID, uuid); crm_xml_add(cib_object, XML_ATTR_UNAME, node); cib_conn->cmds->create(cib_conn, XML_CIB_TAG_STATUS, cib_object, cib_sync_call|cib_scope_local); rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object, cib_xpath|cib_sync_call|cib_scope_local); } crm_free(xpath); CRM_ASSERT(rc == cib_ok); return cib_object; } static xmlNode *modify_node(cib_t *cib_conn, char *node, gboolean up) { xmlNode *cib_node = inject_node_state(cib_conn, node); if(up) { crm_xml_add(cib_node, XML_CIB_ATTR_HASTATE, ACTIVESTATUS); crm_xml_add(cib_node, XML_CIB_ATTR_INCCM, XML_BOOLEAN_YES); crm_xml_add(cib_node, XML_CIB_ATTR_CRMDSTATE, ONLINESTATUS); crm_xml_add(cib_node, XML_CIB_ATTR_JOINSTATE, CRMD_JOINSTATE_MEMBER); crm_xml_add(cib_node, XML_CIB_ATTR_EXPSTATE, CRMD_JOINSTATE_MEMBER); } else { crm_xml_add(cib_node, XML_CIB_ATTR_HASTATE, DEADSTATUS); crm_xml_add(cib_node, XML_CIB_ATTR_INCCM, XML_BOOLEAN_NO); crm_xml_add(cib_node, XML_CIB_ATTR_CRMDSTATE, OFFLINESTATUS); crm_xml_add(cib_node, XML_CIB_ATTR_JOINSTATE, CRMD_JOINSTATE_DOWN); crm_xml_add(cib_node, XML_CIB_ATTR_EXPSTATE, CRMD_JOINSTATE_DOWN); } crm_xml_add(cib_node, XML_ATTR_ORIGIN, crm_system_name); return cib_node; } static void inject_transient_attr(xmlNode *cib_node, const char *name, const char *value) { xmlNode *attrs = NULL; xmlNode *container = NULL; xmlNode *nvp = NULL; const char *node_uuid = ID(cib_node); char *nvp_id = crm_concat(name, node_uuid, '-'); crm_info("Injecting attribute %s=%s into %s '%s'", name, value, xmlGetNodePath(cib_node), ID(cib_node)); attrs = first_named_child(cib_node, XML_TAG_TRANSIENT_NODEATTRS); if(attrs == NULL) { attrs = create_xml_node(cib_node, XML_TAG_TRANSIENT_NODEATTRS); crm_xml_add(attrs, XML_ATTR_ID, node_uuid); } container = first_named_child(attrs, XML_TAG_ATTR_SETS); if(container == NULL) { container = create_xml_node(attrs, XML_TAG_ATTR_SETS); crm_xml_add(container, XML_ATTR_ID, node_uuid); } nvp = create_xml_node(container, XML_CIB_TAG_NVPAIR); crm_xml_add(nvp, XML_ATTR_ID, nvp_id); crm_xml_add(nvp, XML_NVPAIR_ATTR_NAME, name); crm_xml_add(nvp, XML_NVPAIR_ATTR_VALUE, value); crm_free(nvp_id); } static xmlNode *inject_resource(xmlNode *cib_node, const char *resource, const char *rclass, const char *rtype, const char *rprovider) { xmlNode *lrm = NULL; xmlNode *container = NULL; xmlNode *cib_resource = NULL; cib_resource = find_resource(cib_node, resource); if(cib_resource != NULL) { return cib_resource; } /* One day, add query for class, provider, type */ if(rclass == NULL || rtype == NULL) { fprintf(stderr, "Resource %s not found in the status section of %s." " Please supply the class and type to continue\n", resource, ID(cib_node)); return NULL; } else if(safe_str_neq(rclass, "ocf") && safe_str_neq(rclass, "stonith") && safe_str_neq(rclass, "heartbeat") && safe_str_neq(rclass, "lsb")) { fprintf(stderr, "Invalid class for %s: %s\n", resource, rclass); return NULL; } else if(safe_str_eq(rclass, "ocf") && rprovider == NULL) { fprintf(stderr, "Please specify the provider for resource %s\n", resource); return NULL; } crm_info("Injecting new resource %s into %s '%s'", resource, xmlGetNodePath(cib_node), ID(cib_node)); lrm = first_named_child(cib_node, XML_CIB_TAG_LRM); if(lrm == NULL) { const char *node_uuid = ID(cib_node); lrm = create_xml_node(cib_node, XML_CIB_TAG_LRM); crm_xml_add(lrm, XML_ATTR_ID, node_uuid); } container = first_named_child(lrm, XML_LRM_TAG_RESOURCES); if(container == NULL) { container = create_xml_node(lrm, XML_LRM_TAG_RESOURCES); } cib_resource = create_xml_node(container, XML_LRM_TAG_RESOURCE); crm_xml_add(cib_resource, XML_ATTR_ID, resource); crm_xml_add(cib_resource, XML_AGENT_ATTR_CLASS, rclass); crm_xml_add(cib_resource, XML_AGENT_ATTR_PROVIDER, rprovider); crm_xml_add(cib_resource, XML_ATTR_TYPE, rtype); return cib_resource; } static lrm_op_t *create_op( xmlNode *cib_resource, const char *task, int interval, int outcome) { lrm_op_t *op = NULL; crm_malloc0(op, sizeof(lrm_op_t)); op->app_name = crm_strdup(crm_system_name); op->rsc_id = crm_strdup(ID(cib_resource)); op->interval = interval; op->op_type = crm_strdup(task); op->rc = outcome; op->op_status = 0; op->params = NULL; /* TODO: Fill me in */ op->call_id = 0; xml_child_iter(cib_resource, xop, int tmp = 0; crm_element_value_int(xop, XML_LRM_ATTR_CALLID, &tmp); if(tmp > op->call_id) { op->call_id = tmp; } ); op->call_id++; return op; } static xmlNode *inject_op(xmlNode *cib_resource, lrm_op_t *op, int target_rc) { return create_operation_update(cib_resource, op, CRM_FEATURE_SET, target_rc, crm_system_name); } static void update_failcounts(xmlNode *cib_node, const char *resource, int interval, int rc) { if(rc == 0) { return; } else if(rc == 7 && interval == 0) { return; } else { char *name = NULL; char *now = crm_itoa(time(NULL)); name = crm_concat("fail-count", resource, '-'); inject_transient_attr(cib_node, name, "value++"); name = crm_concat("last-failure", resource, '-'); inject_transient_attr(cib_node, name, now); crm_free(name); crm_free(now); } } static gboolean exec_pseudo_action(crm_graph_t *graph, crm_action_t *action) { action->confirmed = TRUE; update_graph(graph, action); return TRUE; } static gboolean exec_rsc_action(crm_graph_t *graph, crm_action_t *action) { int rc = 0; lrm_op_t *op = NULL; int target_outcome = 0; const char *rtype = NULL; const char *rclass = NULL; const char *resource = NULL; const char *rprovider = NULL; const char *target_rc_s = crm_meta_value(action->params, XML_ATTR_TE_TARGET_RC); xmlNode *cib_op = NULL; xmlNode *cib_node = NULL; xmlNode *cib_object = NULL; xmlNode *cib_resource = NULL; xmlNode *action_rsc = first_named_child(action->xml, XML_CIB_TAG_RESOURCE); char *node = crm_element_value_copy(action->xml, XML_LRM_ATTR_TARGET); if(safe_str_eq(crm_element_value(action->xml, "operation"), "probe_complete")) { crm_info("Skipping %s op for %s\n", crm_element_value(action->xml, "operation"), node); goto done; } if(action_rsc == NULL) { crm_log_xml_err(action->xml, "Bad"); return FALSE; } resource = ID(action_rsc); rclass = crm_element_value(action_rsc, XML_AGENT_ATTR_CLASS); rtype = crm_element_value(action_rsc, XML_ATTR_TYPE); rprovider = crm_element_value(action_rsc, XML_AGENT_ATTR_PROVIDER); if(target_rc_s != NULL) { target_outcome = crm_parse_int(target_rc_s, "0"); } CRM_ASSERT(global_cib->cmds->query(global_cib, NULL, &cib_object, cib_sync_call|cib_scope_local) == cib_ok); cib_node = inject_node_state(global_cib, node); CRM_ASSERT(cib_node != NULL); cib_resource = inject_resource(cib_node, resource, rclass, rtype, rprovider); CRM_ASSERT(cib_resource != NULL); op = convert_graph_action(cib_resource, action, 0, target_outcome); quiet_log(" * Executing action %d: %s_%s_%d on %s\n", action->id, resource, op->op_type, op->interval, node); slist_iter(spec, char, op_fail, lpc, char *key = NULL; crm_malloc0(key, strlen(spec)); snprintf(key, strlen(spec), "%s_%s_%d@%s=", resource, op->op_type, op->interval, node); if(strncasecmp(key, spec, strlen(key)) == 0) { rc = sscanf(spec, "%*[^=]=%d", &op->rc); action->failed = TRUE; graph->abort_priority = INFINITY; printf("\tPretending action %d failed with rc=%d\n", action->id, op->rc); update_failcounts(cib_node, resource, op->interval, op->rc); break; } ); cib_op = inject_op(cib_resource, op, target_outcome); rc = global_cib->cmds->modify(global_cib, XML_CIB_TAG_STATUS, cib_node, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); done: action->confirmed = TRUE; update_graph(graph, action); return TRUE; } static gboolean exec_crmd_action(crm_graph_t *graph, crm_action_t *action) { action->confirmed = TRUE; update_graph(graph, action); return TRUE; } #define STATUS_PATH_MAX 512 static gboolean exec_stonith_action(crm_graph_t *graph, crm_action_t *action) { int rc = 0; char xpath[STATUS_PATH_MAX]; char *target = crm_element_value_copy(action->xml, XML_LRM_ATTR_TARGET); xmlNode *cib_node = modify_node(global_cib, target, FALSE); crm_xml_add(cib_node, XML_ATTR_ORIGIN, __FUNCTION__); CRM_ASSERT(cib_node != NULL); quiet_log(" * Fencing %s\n", target); rc = global_cib->cmds->replace(global_cib, XML_CIB_TAG_STATUS, cib_node, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); snprintf(xpath, STATUS_PATH_MAX, "//node_state[@uname='%s']/%s", target, XML_CIB_TAG_LRM); rc = global_cib->cmds->delete(global_cib, xpath, NULL, cib_xpath|cib_sync_call|cib_scope_local); snprintf(xpath, STATUS_PATH_MAX, "//node_state[@uname='%s']/%s", target, XML_TAG_TRANSIENT_NODEATTRS); rc = global_cib->cmds->delete(global_cib, xpath, NULL, cib_xpath|cib_sync_call|cib_scope_local); action->confirmed = TRUE; update_graph(graph, action); return TRUE; } static char * add_list_element(char *list, const char *value) { int len = 0; int last = 0; if(value == NULL) { return list; } if(list) { last = strlen(list); } len = last + 2; /* +1 space, +1 EOS */ len += strlen(value); crm_realloc(list, len); sprintf(list + last, " %s", value); return list; } static void print_cluster_status(pe_working_set_t *data_set) { char *online_nodes = NULL; char *offline_nodes = NULL; slist_iter(node, node_t, data_set->nodes, lpc2, const char *node_mode = NULL; if(node->details->unclean) { if(node->details->online && node->details->unclean) { node_mode = "UNCLEAN (online)"; } else if(node->details->pending) { node_mode = "UNCLEAN (pending)"; } else { node_mode = "UNCLEAN (offline)"; } } else if(node->details->pending) { node_mode = "pending"; } else if(node->details->standby_onfail && node->details->online) { node_mode = "standby (on-fail)"; } else if(node->details->standby) { if(node->details->online) { node_mode = "standby"; } else { node_mode = "OFFLINE (standby)"; } } else if(node->details->online) { node_mode = "online"; online_nodes = add_list_element(online_nodes, node->details->uname); continue; } else { node_mode = "OFFLINE"; offline_nodes = add_list_element(offline_nodes, node->details->uname); continue; } if(safe_str_eq(node->details->uname, node->details->id)) { printf("Node %s: %s\n", node->details->uname, node_mode); } else { printf("Node %s (%s): %s\n", node->details->uname, node->details->id, node_mode); } ); if(online_nodes) { printf("Online: [%s ]\n", online_nodes); crm_free(online_nodes); } if(offline_nodes) { printf("OFFLINE: [%s ]\n", offline_nodes); crm_free(offline_nodes); } fprintf(stdout, "\n"); slist_iter(rsc, resource_t, data_set->resources, lpc, if(is_set(rsc->flags, pe_rsc_orphan) && rsc->role == RSC_ROLE_STOPPED) { continue; } rsc->fns->print(rsc, NULL, pe_print_printf, stdout); ); fprintf(stdout, "\n"); } static int run_simulation(pe_working_set_t *data_set) { crm_graph_t *transition = NULL; enum transition_status graph_rc = -1; crm_graph_functions_t exec_fns = { exec_pseudo_action, exec_rsc_action, exec_crmd_action, exec_stonith_action, }; set_graph_functions(&exec_fns); quiet_log("\nExecuting cluster transition:\n"); transition = unpack_graph(data_set->graph, crm_system_name); print_graph(LOG_DEBUG, transition); do { graph_rc = run_graph(transition); } while(graph_rc == transition_active); if(graph_rc != transition_complete) { fprintf(stderr, "Transition failed: %s\n", transition_status(graph_rc)); print_graph(LOG_ERR, transition); } destroy_graph(transition); CRM_CHECK(graph_rc == transition_complete, fprintf(stderr, "An invalid transition was produced")); if(quiet == FALSE) { xmlNode *cib_object = NULL; ha_time_t *a_date = data_set->now; int rc = global_cib->cmds->query(global_cib, NULL, &cib_object, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); quiet_log("\nRevised cluster status:\n"); set_working_set_defaults(data_set); data_set->input = cib_object; data_set->now = a_date; cluster_status(data_set); print_cluster_status(data_set); } if(graph_rc != transition_complete) { return graph_rc; } return 0; } static char * create_action_name(action_t *action) { char *action_name = NULL; const char *action_host = NULL; if(action->node) { action_host = action->node->details->uname; action_name = crm_concat(action->uuid, action_host, ' '); } else if(action->pseudo) { action_name = crm_strdup(action->uuid); } else { action_host = ""; action_name = crm_concat(action->uuid, action_host, ' '); } if(safe_str_eq(action->task, RSC_CANCEL)) { char *tmp_action_name = action_name; action_name = crm_concat("Cancel", tmp_action_name, ' '); crm_free(tmp_action_name); } return action_name; } static void create_dotfile(pe_working_set_t *data_set, const char *dot_file, gboolean all_actions) { FILE *dot_strm = fopen(dot_file, "w"); if(dot_strm == NULL) { crm_perror(LOG_ERR,"Could not open %s for writing", dot_file); return; } fprintf(dot_strm, " digraph \"g\" {\n"); slist_iter( action, action_t, data_set->actions, lpc, const char *style = "filled"; const char *font = "black"; const char *color = "black"; const char *fill = NULL; char *action_name = create_action_name(action); crm_debug_3("Action %d: %p", action->id, action); if(action->pseudo) { font = "orange"; } style = "dashed"; if(action->dumped) { style = "bold"; color = "green"; } else if(action->rsc != NULL && is_not_set(action->rsc->flags, pe_rsc_managed)) { color = "purple"; if(all_actions == FALSE) { goto dont_write; } } else if(action->optional) { color = "blue"; if(all_actions == FALSE) { goto dont_write; } } else { color = "red"; CRM_CHECK(action->runnable == FALSE, ;); } action->dumped = TRUE; fprintf(dot_strm, "\"%s\" [ style=%s color=\"%s\" fontcolor=\"%s\" %s%s]\n", action_name, style, color, font, fill?"fillcolor=":"", fill?fill:""); dont_write: crm_free(action_name); ); slist_iter( action, action_t, data_set->actions, lpc, slist_iter( before, action_wrapper_t, action->actions_before, lpc2, char *before_name = NULL; char *after_name = NULL; const char *style = "dashed"; gboolean optional = TRUE; if(before->state == pe_link_dumped) { optional = FALSE; style = "bold"; } else if(action->pseudo && (before->type & pe_order_stonith_stop)) { continue; } else if(before->state == pe_link_dup) { continue; } else if(before->type == pe_order_none) { continue; } else if(action->dumped && before->action->dumped) { optional = FALSE; } if(all_actions || optional == FALSE) { before_name = create_action_name(before->action); after_name = create_action_name(action); fprintf(dot_strm, "\"%s\" -> \"%s\" [ style = %s]\n", before_name, after_name, style); crm_free(before_name); crm_free(after_name); } ); ); fprintf(dot_strm, "}\n"); if(dot_strm != NULL) { fflush(dot_strm); fclose(dot_strm); } } static void modify_configuration( pe_working_set_t *data_set, const char *quorum, GListPtr node_up, GListPtr node_down, GListPtr node_fail, GListPtr op_inject) { int rc = cib_ok; xmlNode *cib_op = NULL; xmlNode *cib_node = NULL; xmlNode *cib_resource = NULL; lrm_op_t *op = NULL; if(quorum) { xmlNode *top = create_xml_node(NULL, XML_TAG_CIB); quiet_log(" + Setting quorum: %s\n", quorum); /* crm_xml_add(top, XML_ATTR_DC_UUID, dc_uuid); */ crm_xml_add(top, XML_ATTR_HAVE_QUORUM, quorum); rc = global_cib->cmds->modify(global_cib, NULL, top, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); } slist_iter(node, char, node_up, lpc, quiet_log(" + Bringing node %s online\n", node); cib_node = modify_node(global_cib, node, TRUE); CRM_ASSERT(cib_node != NULL); rc = global_cib->cmds->modify(global_cib, XML_CIB_TAG_STATUS, cib_node, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); ); slist_iter(node, char, node_down, lpc, quiet_log(" + Taking node %s offline\n", node); cib_node = modify_node(global_cib, node, FALSE); CRM_ASSERT(cib_node != NULL); rc = global_cib->cmds->modify(global_cib, XML_CIB_TAG_STATUS, cib_node, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); ); slist_iter(node, char, node_fail, lpc, quiet_log(" + Failing node %s\n", node); cib_node = modify_node(global_cib, node, TRUE); crm_xml_add(cib_node, XML_CIB_ATTR_INCCM, XML_BOOLEAN_NO); CRM_ASSERT(cib_node != NULL); rc = global_cib->cmds->modify(global_cib, XML_CIB_TAG_STATUS, cib_node, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); ); slist_iter(spec, char, op_inject, lpc, int rc = 0; int outcome = 0; int interval = 0; char *key = NULL; char *node = NULL; char *task = NULL; char *resource = NULL; const char *rtype = NULL; const char *rclass = NULL; const char *rprovider = NULL; resource_t *rsc = NULL; quiet_log(" + Injecting %s into the configuration\n", spec); crm_malloc0(key, strlen(spec)); crm_malloc0(node, strlen(spec)); rc = sscanf(spec, "%[^@]@%[^=]=%d", key, node, &outcome); CRM_CHECK(rc == 3, fprintf(stderr, "Invalid operation spec: %s. Only found %d fields\n", spec, rc); continue); parse_op_key(key, &resource, &task, &interval); rsc = pe_find_resource(data_set->resources, resource); CRM_CHECK(rsc != NULL, fprintf(stderr, "Invalid resource name: %s\n", resource); continue); rclass = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS); rtype = crm_element_value(rsc->xml, XML_ATTR_TYPE); rprovider = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER); cib_node = inject_node_state(global_cib, node); CRM_ASSERT(cib_node != NULL); update_failcounts(cib_node, resource, interval, rc); cib_resource = inject_resource(cib_node, resource, rclass, rtype, rprovider); CRM_ASSERT(cib_resource != NULL); op = create_op(cib_resource, task, interval, outcome); CRM_ASSERT(op != NULL); cib_op = inject_op(cib_resource, op, 0); CRM_ASSERT(cib_op != NULL); rc = global_cib->cmds->modify(global_cib, XML_CIB_TAG_STATUS, cib_node, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); ); } static void setup_input(const char *input, const char *output) { int rc = cib_ok; cib_t *cib_conn = NULL; xmlNode *cib_object = NULL; if(input == NULL) { /* Use live CIB */ cib_conn = cib_new(); rc = cib_conn->cmds->signon(cib_conn, crm_system_name, cib_command); if(rc == cib_ok) { cib_object = get_cib_copy(cib_conn); } cib_conn->cmds->signoff(cib_conn); cib_delete(cib_conn); cib_conn = NULL; if(cib_object == NULL) { fprintf(stderr, "Live CIB query failed: empty result\n"); exit(3); } } else if(safe_str_eq(input, "-")) { cib_object = filename2xml(NULL); } else { cib_object = filename2xml(input); } if(cli_config_update(&cib_object, NULL, FALSE) == FALSE) { free_xml(cib_object); exit(cib_STALE); } if(validate_xml(cib_object, NULL, FALSE) != TRUE) { free_xml(cib_object); exit(cib_dtd_validation); } if(output == NULL) { char *pid = crm_itoa(getpid()); output = get_shadow_file(pid); crm_free(pid); } rc = write_xml_file(cib_object, output, FALSE); free_xml(cib_object); cib_object = NULL; if(rc < 0) { fprintf(stderr, "Could not create '%s': %s\n", output, strerror(errno)); exit(rc); } setenv("CIB_file", output, 1); } static struct crm_option long_options[] = { /* Top-level Options */ {"help", 0, 0, '?', "\tThis text"}, {"version", 0, 0, '$', "\tVersion information" }, {"quiet", 0, 0, 'Q', "\tDisplay only essentialoutput"}, {"verbose", 0, 0, 'V', "\tIncrease debug output"}, {"-spacer-", 0, 0, '-', "\nOperations:"}, {"run", 0, 0, 'R', "\tDetermine the cluster's response to the given configuration and status"}, {"simulate", 0, 0, 'S', "Simulate the transition's execution and display the resulting cluster status"}, {"in-place", 0, 0, 'X', "Simulate the transition's execution and store the result back to the input file"}, {"show-scores", 0, 0, 's', "Show allocation scores"}, {"show-utilization", 0, 0, 'U', "Show utilization information"}, {"-spacer-", 0, 0, '-', "\nSynthetic Cluster Events:"}, {"node-up", 1, 0, 'u', "\tBring a node online"}, {"node-down", 1, 0, 'd', "\tTake a node offline"}, {"node-fail", 1, 0, 'f', "\tMark a node as failed"}, {"op-inject", 1, 0, 'i', "\t$rsc_$task_$interval@$node=$rc - Inject the specified task before running the simulation"}, {"op-fail", 1, 0, 'F', "\t$rsc_$task_$interval@$node=$rc - Fail the specified task while running the simulation"}, {"set-datetime", 1, 0, 't', "Set date/time"}, {"quorum", 1, 0, 'q', "\tSpecify a value for quorum"}, {"-spacer-", 0, 0, '-', "\nOutput Options:"}, {"save-input", 1, 0, 'I', "\tSave the input configuration to the named file"}, {"save-output", 1, 0, 'O', "Save the output configuration to the named file"}, {"save-graph", 1, 0, 'G', "\tSave the transition graph (XML format) to the named file"}, {"save-dotfile", 1, 0, 'D', "Save the transition graph (DOT format) to the named file"}, {"all-actions", 0, 0, 'a', "\tDisplay all possible actions in the DOT graph - even ones not part of the transition"}, {"-spacer-", 0, 0, '-', "\nData Source:"}, {"live-check", 0, 0, 'L', "\tConnect to the CIB and use the current contents as input"}, {"xml-file", 1, 0, 'x', "\tRetrieve XML from the named file"}, {"xml-pipe", 0, 0, 'p', "\tRetrieve XML from stdin"}, {0, 0, 0, 0} }; int main(int argc, char ** argv) { int rc = 0; guint modified = 0; gboolean store = FALSE; gboolean process = FALSE; gboolean verbose = FALSE; gboolean simulate = FALSE; gboolean all_actions = FALSE; pe_working_set_t data_set; ha_time_t *a_date = NULL; const char *xml_file = "-"; const char *quorum = NULL; const char *dot_file = NULL; const char *graph_file = NULL; const char *input_file = NULL; const char *output_file = NULL; int flag = 0; int index = 0; int argerr = 0; char *use_date = NULL; GListPtr node_up = NULL; GListPtr node_down = NULL; GListPtr node_fail = NULL; GListPtr op_inject = NULL; xmlNode *input = NULL; crm_log_init("crm_simulate", LOG_ERR, FALSE, FALSE, argc, argv); - crm_set_options("?$VQx:Lpu:d:f:i:RSXD:G:I:O:sUaF:t:q", "datasource operation [additional options]", + crm_set_options("?$VQx:Lpu:d:f:i:RSXD:G:I:O:sUaF:t:q:", "datasource operation [additional options]", long_options, "Tool for simulating the cluster's response to events"); if(argc < 2) { crm_help('?', LSB_EXIT_EINVAL); } while (1) { flag = crm_get_option(argc, argv, &index); if (flag == -1) break; switch(flag) { case 'V': verbose = TRUE; alter_debug(DEBUG_INC); cl_log_enable_stderr(TRUE); break; case '?': case '$': crm_help(flag, LSB_EXIT_OK); break; case 'p': xml_file = "-"; break; case 'Q': quiet = TRUE; break; case 'L': xml_file = NULL; break; case 'x': xml_file = optarg; break; case 'u': modified++; node_up = g_list_append(node_up, optarg); break; case 'd': modified++; node_down = g_list_append(node_down, optarg); break; case 'f': modified++; node_fail = g_list_append(node_fail, optarg); break; case 't': use_date = crm_strdup(optarg); break; case 'i': modified++; op_inject = g_list_append(op_inject, optarg); break; case 'F': process = TRUE; simulate = TRUE; op_fail = g_list_append(op_fail, optarg); break; case 'q': modified++; quorum = optarg; break; case 'a': all_actions = TRUE; break; case 's': process = TRUE; show_scores = TRUE; break; case 'U': process = TRUE; show_utilization = TRUE; break; case 'S': process = TRUE; simulate = TRUE; break; case 'X': store = TRUE; process = TRUE; simulate = TRUE; break; case 'R': process = TRUE; break; case 'D': process = TRUE; dot_file = optarg; break; case 'G': process = TRUE; graph_file = optarg; break; case 'I': input_file = optarg; break; case 'O': simulate = TRUE; output_file = optarg; break; default: ++argerr; break; } } if (optind > argc) { ++argerr; } if (argerr) { crm_help('?', LSB_EXIT_GENERIC); } setup_input(xml_file, store?xml_file:output_file); global_cib = cib_new(); global_cib->cmds->signon(global_cib, crm_system_name, cib_command); if(use_date != NULL) { a_date = parse_date(&use_date); quiet_log(" + Setting effective cluster time: %s", use_date); log_date(LOG_WARNING, "Set fake 'now' to", a_date, ha_log_date|ha_log_time); } if(quiet == FALSE) { xmlNode *cib_object = NULL; rc = global_cib->cmds->query(global_cib, NULL, &cib_object, cib_sync_call|cib_scope_local); CRM_ASSERT(rc == cib_ok); set_working_set_defaults(&data_set); data_set.input = cib_object; data_set.now = a_date; cluster_status(&data_set); quiet_log("\nCurrent cluster status:\n"); print_cluster_status(&data_set); if(process == FALSE && modified == FALSE) { return 0; } } if(modified) { quiet_log("Performing requested modifications\n"); modify_configuration(&data_set, quorum, node_up, node_down, node_fail, op_inject); } rc = global_cib->cmds->query(global_cib, NULL, &input, cib_sync_call); if(rc != cib_ok) { fprintf(stderr, "Could not connect to the CIB for input: %s\n", cib_error2string(rc)); return rc; } if(input_file != NULL) { rc = write_xml_file(input, input_file, FALSE); if(rc < 0) { fprintf(stderr, "Could not create '%s': %s\n", input_file, strerror(errno)); return rc; } free_xml(input); } rc = 0; if(process || simulate) { if(show_scores && show_utilization) { printf("Allocation scores and utilization information:\n"); } else if(show_scores) { printf("Allocation scores:\n"); } else if(show_utilization) { printf("Utilization information:\n"); } do_calculations(&data_set, input, a_date); if(graph_file != NULL) { char *msg_buffer = dump_xml_formatted(data_set.graph); FILE *graph_strm = fopen(graph_file, "w"); if(graph_strm == NULL) { crm_perror(LOG_ERR,"Could not open %s for writing", graph_file); } else { if(fprintf(graph_strm, "%s\n\n", msg_buffer) < 0) { crm_perror(LOG_ERR,"Write to %s failed", graph_file); } fflush(graph_strm); fclose(graph_strm); } crm_free(msg_buffer); } if(dot_file != NULL) { create_dotfile(&data_set, dot_file, all_actions); } if(quiet == FALSE && verbose == FALSE) { quiet_log("%sTransition Summary:\n", show_scores||show_utilization||modified?"\n":""); fflush(stdout); crm_log_level = LOG_NOTICE; cl_log_enable_stderr(TRUE); slist_iter( rsc, resource_t, data_set.resources, lpc, LogActions(rsc, &data_set); ); cl_log_enable_stderr(FALSE); } } if(simulate) { rc = run_simulation(&data_set); } global_cib->cmds->signoff(global_cib); cib_delete(global_cib); fflush(stderr); return rc; } diff --git a/tools/regression.sh b/tools/regression.sh index c60158ce5c..a0ecb66cb0 100755 --- a/tools/regression.sh +++ b/tools/regression.sh @@ -1,184 +1,186 @@ #!/bin/bash : ${shadow=tools-regression} base=`dirname $0` num_errors=0 num_passed=0 GREP_OPTIONS= function assert() { rc=$1; shift target=$1; shift app=$1; shift msg=$1; shift exit_code=$1; shift cibadmin -Q if [ $rc -ne $target ]; then num_errors=`expr $num_errors + 1` printf "* Failed (rc=%.3d): %-14s - %s\n" $rc $app "$msg" if [ ! -z $exit_code ]; then echo "Aborting tests" exit $exit_code fi exit 1 else printf "* Passed: %-14s - %s\n" $app "$msg" num_passed=`expr $num_passed + 1` fi } function usage() { echo "Usage: ./regression.sh [-s(ave)] [-x] [-v(erbose)]" exit $1 } done=0 do_save=0 while test "$done" = "0"; do case "$1" in -v) verbose=1; shift;; -x) set -x; shift;; -s) do_save=1; shift;; + -p) PATH="$2:$PATH"; export PATH; shift 1;; -?) usage 0;; -*) echo "unknown option: $1"; usage 1;; *) done=1;; esac done function test_tools() { + export CIB_shadow_dir=$base crm_shadow --batch --force --create-empty $shadow - CIB_shadow=$shadow ; export CIB_shadow + export CIB_shadow=$shadow cibadmin -Q cibadmin -E assert $? 1 cibadmin "Require --force for CIB erasure" cibadmin -E --force assert $? 0 cibadmin "Allow CIB erasure with --force" cibadmin -Q > /tmp/$$.existing.xml assert $? 0 cibadmin "Query CIB" crm_attribute -n cluster-delay -v 60s assert $? 0 crm_attribute "Set cluster option" cibadmin -Q -o crm_config | grep cib-bootstrap-options-cluster-delay assert $? 0 cibadmin "Query new cluster option" cibadmin -Q -o crm_config > /tmp/$$.opt.xml assert $? 0 cibadmin "Query cluster options" cibadmin -D -o crm_config --xml-text '' assert $? 0 cibadmin "Delete nvpair" cibadmin -C -o crm_config --xml-file /tmp/$$.opt.xml assert $? 21 cibadmin "Create operaton should fail with: -21, The object already exists" cibadmin -M -o crm_config --xml-file /tmp/$$.opt.xml assert $? 0 cibadmin "Modify cluster options section" cibadmin -Q -o crm_config | grep cib-bootstrap-options-cluster-delay assert $? 0 cibadmin "Query updated cluster option" crm_attribute -n cluster-delay -v 40s -s duplicate assert $? 0 crm_attribute "Set duplicate cluster option" crm_attribute -n cluster-delay -v 30s assert $? 216 crm_attribute "Setting multiply defined cluster option should fail with -216, Could not set cluster option" crm_attribute -n cluster-delay -v 30s -s duplicate assert $? 0 crm_attribute "Set cluster option with -s" crm_attribute -n cluster-delay -D -i cib-bootstrap-options-cluster-delay assert $? 0 crm_attribute "Delete cluster option with -i" cibadmin -C -o nodes --xml-text '' assert $? 0 cibadmin "Create node entry" cibadmin -C -o status --xml-text '' assert $? 0 cibadmin "Create node status entry" crm_attribute -n ram -v 1024M -U clusterNode-UNAME -t nodes assert $? 0 crm_attribute "Create node attribute" cibadmin -Q -o nodes | grep clusterNode-UUID-ram assert $? 0 cibadmin "Query new node attribute" cibadmin -Q | cibadmin -5 -p 2>&1 > /dev/null assert $? 0 cibadmin "Digest calculation" # This update will fail because it has version numbers cibadmin -R --xml-file /tmp/$$.existing.xml assert $? 45 cibadmin "Replace operation should fail with: -45, Update was older than existing configuration" crm_standby -N clusterNode-UNAME -G assert $? 0 crm_standby "Default standby value" crm_standby -N clusterNode-UNAME -v true assert $? 0 crm_standby "Set standby status" crm_standby -N clusterNode-UNAME -G assert $? 0 crm_standby "Query standby value" crm_standby -N clusterNode-UNAME -D assert $? 0 crm_standby "Delete standby value" cibadmin -C -o resources --xml-text '' assert $? 0 cibadmin "Create a resource" crm_resource -r dummy --meta -p is-managed -v false assert $? 0 crm_resource "Create a resource meta attribute" crm_resource -r dummy --meta -g is-managed assert $? 0 crm_resource "Query a resource meta attribute" crm_resource -r dummy --meta -d is-managed assert $? 0 crm_resource "Remove a resource meta attribute" crm_resource -r dummy -p delay -v 10s assert $? 0 crm_resource "Create a resource attribute" crm_resource -L assert $? 0 crm_resource "List the configured resources" crm_failcount -r dummy -v 10 -N clusterNode-UNAME assert $? 0 crm_resource "Set a resource's fail-count" crm_resource -r dummy -M assert $? 244 crm_resource "Require a destination when migrating a resource that is stopped" crm_resource -r dummy -M -N i.dont.exist assert $? 234 crm_resource "Don't support migration to non-existant locations" crm_resource -r dummy -M -N clusterNode-UNAME assert $? 0 crm_resource "Migrate a resource" crm_resource -r dummy -U assert $? 0 crm_resource "Un-migrate a resource" } test_tools 2>&1 | sed s/cib-last-written.*\>/\>/ > $base/regression.out rc=$? if [ $do_save = 1 ]; then cp $base/regression.out $base/regression.exp fi grep -e "^*" $base/regression.out diff -u $base/regression.exp $base/regression.out diff_rc=$? if [ $rc != 0 ]; then echo Tests failed exit 1 elif [ $diff_rc != 0 ]; then echo Tests passed but diff failed exit 2 else echo Tests passed exit 0 fi