Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3152098
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
59 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/.gitignore b/.gitignore
index f7277bf04..ec30a3bb0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,153 +1,154 @@
*.swp
Makefile.in
aclocal.m4
autoconf
autoheader
autom4te.cache
automake
autoscan.log
compile
configure
configure.scan
config.guess
config.log
config.sub
config.status
Makefile
depcomp
install-sh
libtoolize
ltmain.sh
libtool
make/stamp-h1
make/clusterautoconfig.h*
missing
*.pc
.deps
.libs
*.o
*.la
*.lo
*.loT
rgmanager/src/resources/*
!rgmanager/src/resources/*.in
rgmanager/src/resources/Makefile.in
rgmanager/src/resources/utils/config-utils.sh
resource-agents-*
.version
# generated by ./autogen.sh && ./configure
doc/man/*.7
doc/man/*.xml
heartbeat/ocf-binaries
heartbeat/ocf-directories
heartbeat/ocf-shellfuncs
heartbeat/send_ua
heartbeat/shellfuncs
heartbeat/*.pyc
heartbeat/AoEtarget
heartbeat/CTDB
heartbeat/ManageRAID
heartbeat/ManageVE
heartbeat/Squid
heartbeat/SysInfo
heartbeat/aws-vpc-route53
heartbeat/azure-events
heartbeat/clvm
heartbeat/conntrackd
heartbeat/dnsupdate
heartbeat/dummypy
heartbeat/eDir88
heartbeat/fio
heartbeat/galera
heartbeat/gcp-pd-move
heartbeat/gcp-vpc-move-ip
heartbeat/gcp-vpc-move-route
heartbeat/gcp-vpc-move-vip
heartbeat/iSCSILogicalUnit
heartbeat/iSCSITarget
heartbeat/jira
heartbeat/kamailio
heartbeat/lxc
heartbeat/lxd-info
heartbeat/machine-info
heartbeat/mariadb
heartbeat/mpathpersist
heartbeat/nfsnotify
heartbeat/openstack-info
heartbeat/rabbitmq-cluster
heartbeat/redis
heartbeat/rsyslog
heartbeat/sg_persist
heartbeat/slapd
heartbeat/smb-share
heartbeat/storage-mon
heartbeat/sybaseASE
heartbeat/syslog-ng
heartbeat/vsftpd
include/agent_config.h
include/config.h
include/config.h.in
include/stamp-h1
include/stamp-h2
ldirectord/ldirectord
ldirectord/ldirectord.8
ldirectord/OCF/ldirectord
ldirectord/init.d/ldirectord
ldirectord/init.d/ldirectord.debian
ldirectord/init.d/ldirectord.debian.default
ldirectord/systemd/ldirectord.service
systemd/resource-agents.conf
tools/findif
+tools/nfsconvert
tools/ocf-tester
tools/send_arp
tools/storage_mon
tools/tickle_tcp
tools/ocft/README
tools/ocft/README.zh_CN
tools/ocft/caselib
tools/ocft/ocft
*.cache
*.upgrade.xml
py-compile
ylwrap
__pycache__
# BEAM Entries
*.beam
parser-messages
MISC_ERRORS
cscope.files
cscope.out
patches
updates
logs
# OS and Editor Artifacts
.DS_Store
.bomb
*.rej
*.bz2
*.gz
*.xz
*.sed
*.diff
*.patch
*.gres
*~
# Misc
HTML
TAGS
GPATH
GRTAGS
GSYMS
GTAGS
.gres.*
*.orig
.gdb_history
*~
\#*
.changes
pacemaker.tar.gz
diff --git a/configure.ac b/configure.ac
index c125df98f..058c0f1da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,1069 +1,1074 @@
dnl
dnl autoconf for Agents
dnl
dnl License: GNU General Public License (GPL)
dnl ===============================================
dnl Bootstrap
dnl ===============================================
AC_PREREQ(2.63)
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([resource-agents],
m4_esyscmd([make/git-version-gen .tarball-version]),
[developers@clusterlabs.org])
AC_USE_SYSTEM_EXTENSIONS
CRM_DTD_VERSION="1.0"
AC_CONFIG_AUX_DIR(.)
AC_CONFIG_MACRO_DIR([m4])
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/agent_config.h
dnl - Contains a subset of defines checked here
dnl - Manually edit include/agent_config.h.in to have configure include new defines
dnl - Should not include HAVE_* defines
dnl - Safe to include anywhere
AM_CONFIG_HEADER(include/config.h include/agent_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" ])
dnl
dnl AM_INIT_AUTOMAKE([1.11.1 foreign dist-bzip2 dist-xz])
dnl
AM_INIT_AUTOMAKE([1.10.1 foreign dist-bzip2])
AC_DEFINE_UNQUOTED(AGENTS_VERSION, "$PACKAGE_VERSION", Current agents version)
CC_IN_CONFIGURE=yes
export CC_IN_CONFIGURE
LDD=ldd
dnl ========================================================================
dnl Compiler characteristics
dnl ========================================================================
# check stolen from gnulib/m4/gnu-make.m4
if ! ${MAKE-make} --version /cannot/make/this >/dev/null 2>&1; then
AC_MSG_ERROR([you don't seem to have GNU make; it is required])
fi
AC_PROG_CC dnl Can force other with environment variable "CC".
AM_PROG_CC_C_O
AC_PROG_CC_STDC
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_C_STRINGIZE
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UID_T
AC_TYPE_UINT16_T
AC_TYPE_UINT8_T
AC_TYPE_UINT32_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 CPPFLAGS="$@"
AC_MSG_CHECKING(whether $CC supports "$@")
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
[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=$srcdir/extract_define.$2.${$}
printf "#include <stdio.h>\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}
}
AC_MSG_NOTICE(Sanitizing prefix: ${prefix})
case $prefix in
NONE)
prefix=/usr
dnl Fix default variables - "prefix" variable if not specified
if test "$localstatedir" = "\${prefix}/var"; then
localstatedir="/var"
fi
if test "$sysconfdir" = "\${prefix}/etc"; then
sysconfdir="/etc"
fi
;;
esac
# ordering is important, PKG_PROG_PKG_CONFIG is to be invoked before any other PKG_* related stuff
PKG_PROG_PKG_CONFIG(0.18)
# PKG_CHECK_MODULES will fail if systemd is not found by default, so make sure
# we set the proper vars and deal with it
PKG_CHECK_MODULES([systemd], [systemd], [HAS_SYSTEMD=yes], [HAS_SYSTEMD=no])
if test "x$HAS_SYSTEMD" == "xyes"; then
PKG_CHECK_VAR([SYSTEMD_UNIT_DIR], [systemd], [systemdsystemunitdir])
if test "x$SYSTEMD_UNIT_DIR" == "x"; then
AC_MSG_ERROR([Unable to detect systemd unit dir automatically])
fi
PKG_CHECK_VAR([SYSTEMD_TMPFILES_DIR], [systemd], [tmpfilesdir])
if test "x$SYSTEMD_TMPFILES_DIR" == "x"; then
AC_MSG_ERROR([Unable to detect systemd tmpfiles directory automatically])
fi
# sanitize systed vars when using non standard prefix
if test "$prefix" != "/usr"; then
SYSTEMD_UNIT_DIR="$prefix/$SYSTEMD_UNIT_DIR"
AC_SUBST([SYSTEMD_UNIT_DIR])
SYSTEMD_TMPFILES_DIR="$prefix/$SYSTEMD_TMPFILES_DIR"
AC_SUBST([SYSTEMD_TMPFILES_DIR])
fi
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$HAS_SYSTEMD" == xyes ])
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]])
INITDIR=""
AC_ARG_WITH(initdir,
[ --with-initdir=DIR directory for init (rc) scripts [${INITDIR}]],
[ INITDIR="$withval" ])
OCF_ROOT_DIR="${prefix}/lib/ocf"
AC_ARG_WITH(ocf-root,
[ --with-ocf-root=DIR directory for OCF scripts [${OCF_ROOT_DIR}]],
[ OCF_ROOT_DIR="$withval" ])
HA_RSCTMPDIR=${localstatedir}/run/resource-agents
AC_ARG_WITH(rsctmpdir,
[ --with-rsctmpdir=DIR directory for resource agents state files [${HA_RSCTMPDIR}]],
[ HA_RSCTMPDIR="$withval" ])
AC_ARG_ENABLE([libnet],
[ --enable-libnet Use libnet for ARP based funcationality, [default=try]],
[enable_libnet="$enableval"], [enable_libnet=try])
BUILD_RGMANAGER=0
BUILD_LINUX_HA=0
RASSET=linux-ha
AC_ARG_WITH(ras-set,
[ --with-ras-set=SET build/install only linux-ha, rgmanager or all resource-agents [default: linux-ha]],
[ RASSET="$withval" ])
if test x$RASSET = xyes || test x$RASSET = xall ; then
BUILD_RGMANAGER=1
BUILD_LINUX_HA=1
fi
if test x$RASSET = xlinux-ha; then
BUILD_LINUX_HA=1
fi
if test x$RASSET = xrgmanager; then
BUILD_RGMANAGER=1
fi
if test $BUILD_LINUX_HA -eq 0 && test $BUILD_RGMANAGER -eq 0; then
AC_MSG_ERROR([Are you really sure you want this package?])
exit 1
fi
AM_CONDITIONAL(BUILD_LINUX_HA, test $BUILD_LINUX_HA -eq 1)
AM_CONDITIONAL(BUILD_RGMANAGER, test $BUILD_RGMANAGER -eq 1)
AC_ARG_WITH(compat-habindir,
[ --with-compat-habindir use HA_BIN directory with compatibility for the Heartbeat stack [${libexecdir}]],
[],
[with_compat_habindir=no])
AM_CONDITIONAL(WITH_COMPAT_HABINDIR, test "x$with_compat_habindir" != "xno")
dnl ===============================================
dnl General Processing
dnl ===============================================
echo Our Host OS: $host_os/$host
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 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
if
test -z $INITDIR
then
INITDIR=${sysconfdir}/init.d
fi
AC_MSG_RESULT($INITDIR);;
esac
AC_SUBST(INITDIR)
if test "${prefix}" = "/usr"; then
INITDIRPREFIX="$INITDIR"
else
INITDIRPREFIX="${prefix}/$INITDIR"
fi
AC_SUBST(INITDIRPREFIX)
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
if test "x$with_compat_habindir" != "xno" ; then
libexecdir=${libdir}
fi
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 docdir is a recent addition to autotools
eval docdir="`eval echo ${docdir}`"
if test "x$docdir" = "x"; then
docdir="`eval echo ${datadir}/doc`"
fi
AC_SUBST(docdir)
dnl Home-grown variables
eval INITDIR="${INITDIR}"
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".
REBOOT_OPTIONS="-f"
POWEROFF_OPTIONS="-f"
case "$host_os" in
*bsd*) LIBS="-L/usr/local/lib"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
;;
*solaris*)
REBOOT_OPTIONS="-n"
POWEROFF_OPTIONS="-n"
LDFLAGS+=" -lssp -lssp_nonshared"
;;
*linux*)
AC_DEFINE_UNQUOTED(ON_LINUX, 1, Compiling for Linux platform)
POWEROFF_OPTIONS="-nf"
REBOOT_OPTIONS="-nf"
;;
darwin*)
AC_DEFINE_UNQUOTED(ON_DARWIN, 1, Compiling for Darwin platform)
LIBS="$LIBS -L${prefix}/lib"
CFLAGS="$CFLAGS -I${prefix}/include"
;;
esac
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)
case "$host_cpu" in
s390x)U64T="%lu";;
*64*) U64T="%lu";;
*) U64T="%llu";;
esac
AC_MSG_RESULT($U64T)
AC_DEFINE_UNQUOTED(U64T, "$U64T", Correct printf format for logging uint64_t)
dnl Variables needed for substitution
AC_CHECK_HEADERS(heartbeat/glue_config.h)
if test "$ac_cv_header_heartbeat_glue_config_h" != "yes"; then
enable_libnet=no
fi
AC_DEFINE_UNQUOTED(OCF_ROOT_DIR,"$OCF_ROOT_DIR", OCF root directory - specified by the OCF standard)
AC_SUBST(OCF_ROOT_DIR)
GLUE_STATE_DIR=${localstatedir}/run
AC_DEFINE_UNQUOTED(GLUE_STATE_DIR,"$GLUE_STATE_DIR", Where to keep state files and sockets)
AC_SUBST(GLUE_STATE_DIR)
AC_DEFINE_UNQUOTED(HA_VARRUNDIR,"$GLUE_STATE_DIR", Where Heartbeat keeps state files and sockets - old name)
HA_VARRUNDIR="$GLUE_STATE_DIR"
AC_SUBST(HA_VARRUNDIR)
# Expand $prefix
eval HA_RSCTMPDIR="`eval echo ${HA_RSCTMPDIR}`"
AC_DEFINE_UNQUOTED(HA_RSCTMPDIR,"$HA_RSCTMPDIR", Where Resource agents keep state files)
AC_SUBST(HA_RSCTMPDIR)
dnl Eventually move out of the heartbeat dir tree and create symlinks when needed
HA_VARLIBHBDIR=${localstatedir}/lib/heartbeat
AC_DEFINE_UNQUOTED(HA_VARLIBHBDIR,"$HA_VARLIBHBDIR", Whatever this used to mean)
AC_SUBST(HA_VARLIBHBDIR)
OCF_RA_DIR="${OCF_ROOT_DIR}/resource.d"
AC_DEFINE_UNQUOTED(OCF_RA_DIR,"$OCF_RA_DIR", Location for OCF RAs)
AC_SUBST(OCF_RA_DIR)
OCF_RA_DIR_PREFIX="$OCF_RA_DIR"
AC_SUBST(OCF_RA_DIR_PREFIX)
OCF_LIB_DIR="${OCF_ROOT_DIR}/lib"
AC_DEFINE_UNQUOTED(OCF_LIB_DIR,"$OCF_LIB_DIR", Location for shared code for OCF RAs)
AC_SUBST(OCF_LIB_DIR)
OCF_LIB_DIR_PREFIX="$OCF_LIB_DIR"
AC_SUBST(OCF_LIB_DIR_PREFIX)
dnl ===============================================
dnl rgmanager ras bits
dnl ===============================================
LOGDIR=${localstatedir}/log/cluster
CLUSTERDATA=${datadir}/cluster
AC_SUBST([LOGDIR])
AC_SUBST([CLUSTERDATA])
dnl ===============================================
dnl Program Paths
dnl ===============================================
PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
export PATH
AC_CHECK_PROGS(MAKE, gmake make)
AC_PATH_PROGS(BASH_SHELL, bash)
if test x"${BASH_SHELL}" = x""; then
AC_MSG_ERROR(You need bash installed in order to build ${PACKAGE})
fi
AC_PATH_PROGS(XSLTPROC, xsltproc)
AM_CONDITIONAL(BUILD_DOC, test "x$XSLTPROC" != "x" )
if test "x$XSLTPROC" = "x"; then
AC_MSG_WARN([xsltproc not installed, unable to (re-)build manual pages])
fi
AC_SUBST(XSLTPROC)
AC_PATH_PROGS(XMLCATALOG, xmlcatalog)
AC_PATH_PROGS(SSH, ssh, /usr/bin/ssh)
AC_PATH_PROGS(SCP, scp, /usr/bin/scp)
AC_PATH_PROGS(TAR, tar)
AC_PATH_PROGS(MD5, md5)
AC_PATH_PROGS(TEST, test)
AC_PATH_PROGS(PING, ping, /bin/ping)
AC_PATH_PROGS(IFCONFIG, ifconfig, /sbin/ifconfig)
AC_PATH_PROGS(MAILCMD, mailx mail, mail)
AC_PATH_PROGS(EGREP, egrep)
AC_PATH_PROGS(RM, rm)
AC_SUBST(BASH_SHELL)
AC_SUBST(MAILCMD)
AC_SUBST(EGREP)
AC_SUBST(SHELL)
AC_SUBST(PING)
AC_SUBST(RM)
AC_SUBST(TEST)
dnl Ensure PYTHON is an absolute path
AC_PATH_PROG([PYTHON], [$PYTHON])
AM_PATH_PYTHON
if test -z "$PYTHON"; then
echo "*** Essential program python not found" 1>&2
fi
AC_PYTHON_MODULE(googleapiclient)
AC_PYTHON_MODULE(json)
AC_PYTHON_MODULE(pyroute2)
AS_VERSION_COMPARE([$PYTHON_VERSION], [2.7], [BUILD_OCF_PY=0], [BUILD_OCF_PY=1], [BUILD_OCF_PY=1])
BUILD_AZURE_EVENTS=1
if test -z "$PYTHON" || test $BUILD_OCF_PY -eq 0; then
BUILD_AZURE_EVENTS=0
AC_MSG_WARN("Not building azure-events")
fi
AM_CONDITIONAL(BUILD_AZURE_EVENTS, test $BUILD_AZURE_EVENTS -eq 1)
BUILD_GCP_PD_MOVE=1
if test -z "$PYTHON" || test "x${HAVE_PYMOD_GOOGLEAPICLIENT}" != xyes || test $BUILD_OCF_PY -eq 0; then
BUILD_GCP_PD_MOVE=0
AC_MSG_WARN("Not building gcp-pd-move")
fi
AM_CONDITIONAL(BUILD_GCP_PD_MOVE, test $BUILD_GCP_PD_MOVE -eq 1)
BUILD_GCP_VPC_MOVE_ROUTE=1
if test -z "$PYTHON" || test "x${HAVE_PYMOD_GOOGLEAPICLIENT}" != xyes || \
test "x${HAVE_PYMOD_PYROUTE2}" != xyes || test $BUILD_OCF_PY -eq 0; then
BUILD_GCP_VPC_MOVE_ROUTE=0
AC_MSG_WARN("Not building gcp-vpc-move-route")
fi
AM_CONDITIONAL(BUILD_GCP_VPC_MOVE_ROUTE, test $BUILD_GCP_VPC_MOVE_ROUTE -eq 1)
BUILD_GCP_VPC_MOVE_VIP=1
if test -z "$PYTHON" || test "x${HAVE_PYMOD_GOOGLEAPICLIENT}" != xyes || test $BUILD_OCF_PY -eq 0; then
BUILD_GCP_VPC_MOVE_VIP=0
AC_MSG_WARN("Not building gcp-vpc-move-vip")
fi
AM_CONDITIONAL(BUILD_GCP_VPC_MOVE_VIP, test $BUILD_GCP_VPC_MOVE_VIP -eq 1)
AC_PATH_PROGS(ROUTE, route)
AC_DEFINE_UNQUOTED(ROUTE, "$ROUTE", path to route command)
AC_MSG_CHECKING(ifconfig option to list interfaces)
for IFCONFIG_A_OPT in "-A" "-a" ""
do
$IFCONFIG $IFCONFIG_A_OPT > /dev/null 2>&1
if
test "$?" = 0
then
AC_DEFINE_UNQUOTED(IFCONFIG_A_OPT, "$IFCONFIG_A_OPT", option for ifconfig command)
AC_MSG_RESULT($IFCONFIG_A_OPT)
break
fi
done
AC_SUBST(IFCONFIG_A_OPT)
if test x"${MAKE}" = x""; then
AC_MSG_ERROR(You need (g)make installed in order to build ${PACKAGE})
fi
STYLESHEET_PREFIX=""
if test x"${XSLTPROC}" != x""; then
AC_MSG_CHECKING(docbook to manpage transform)
# first try to figure out correct template using xmlcatalog query,
# resort to extensive (semi-deterministic) file search if that fails
DOCBOOK_XSL_URI='http://docbook.sourceforge.net/release/xsl/current'
DOCBOOK_XSL_PATH='manpages/docbook.xsl'
STYLESHEET_PREFIX=$(${XMLCATALOG} "" ${DOCBOOK_XSL_URI} \
| sed -n 's|^file://||p;q')
if test x"${STYLESHEET_PREFIX}" = x""; then
DIRS=$(find "${datadir}" -name $(basename $(dirname ${DOCBOOK_XSL_PATH})) \
-type d | LC_ALL=C sort)
if test x"${DIRS}" = x""; then
# when datadir is not standard OS path, we cannot find docbook.xsl
# use standard OS path as backup
DIRS=$(find "/usr/share" "/usr/local/share" -name $(basename $(dirname ${DOCBOOK_XSL_PATH})) \
-type d | LC_ALL=C sort)
fi
XSLT=$(basename ${DOCBOOK_XSL_PATH})
for d in ${DIRS}; do
if test -f "${d}/${XSLT}"; then
STYLESHEET_PREFIX=$(echo "${d}" | sed 's/\/manpages//')
break
fi
done
fi
if test x"${STYLESHEET_PREFIX}" = x""; then
AC_MSG_ERROR(You need docbook-style-xsl installed in order to build ${PACKAGE})
fi
fi
AC_MSG_RESULT($STYLESHEET_PREFIX)
AC_SUBST(STYLESHEET_PREFIX)
dnl ===============================================
dnl Libraries
dnl ===============================================
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(gnugetopt, getopt_long) dnl if available
if test "x${enable_thread_safe}" = "xyes"; then
GPKGNAME="gthread-2.0"
else
GPKGNAME="glib-2.0"
fi
PKG_CHECK_MODULES([GLIB], [$GPKGNAME])
CPPFLAGS="$CPPFLAGS $GLIB_CFLAGS"
LIBS="$LIBS $GLIB_LIBS"
dnl ========================================================================
dnl Headers
dnl ========================================================================
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/sockio.h)
AC_CHECK_HEADERS([arpa/inet.h])
AC_CHECK_HEADERS([fcntl.h])
AC_CHECK_HEADERS([limits.h])
AC_CHECK_HEADERS([malloc.h])
AC_CHECK_HEADERS([netdb.h])
AC_CHECK_HEADERS([netinet/in.h])
AC_CHECK_HEADERS([sys/file.h])
AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([sys/param.h])
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([syslog.h])
dnl ========================================================================
dnl Functions
dnl ========================================================================
AC_FUNC_FORK
AC_FUNC_STRNLEN
AC_CHECK_FUNCS([alarm gettimeofday inet_ntoa memset mkdir socket uname])
AC_CHECK_FUNCS([strcasecmp strchr strdup strerror strrchr strspn strstr strtol strtoul])
AC_PATH_PROGS(REBOOT, reboot, /sbin/reboot)
AC_SUBST(REBOOT)
AC_SUBST(REBOOT_OPTIONS)
AC_DEFINE_UNQUOTED(REBOOT, "$REBOOT", path to the reboot command)
AC_DEFINE_UNQUOTED(REBOOT_OPTIONS, "$REBOOT_OPTIONS", reboot options)
AC_PATH_PROGS(POWEROFF_CMD, poweroff, /sbin/poweroff)
AC_SUBST(POWEROFF_CMD)
AC_SUBST(POWEROFF_OPTIONS)
AC_DEFINE_UNQUOTED(POWEROFF_CMD, "$POWEROFF_CMD", path to the poweroff command)
AC_DEFINE_UNQUOTED(POWEROFF_OPTIONS, "$POWEROFF_OPTIONS", poweroff options)
AC_PATH_PROGS(POD2MAN, pod2man)
AM_CONDITIONAL(BUILD_POD_DOC, test "x$POD2MAN" != "x" )
if test "x$POD2MAN" = "x"; then
AC_MSG_WARN([pod2man not installed, unable to (re-)build ldirector manual page])
fi
AC_SUBST(POD2MAN)
dnl ========================================================================
dnl Functions
dnl ========================================================================
AC_CHECK_FUNCS(getopt, AC_DEFINE(HAVE_DECL_GETOPT, 1, [Have getopt function]))
dnl ========================================================================
dnl sfex
dnl ========================================================================
build_sfex=no
case $host_os in
*Linux*|*linux*)
if test "$ac_cv_header_heartbeat_glue_config_h" = "yes"; then
build_sfex=yes
fi
;;
esac
AM_CONDITIONAL(BUILD_SFEX, test "$build_sfex" = "yes" )
dnl ========================================================================
dnl tickle (needs port to BSD platforms)
dnl ========================================================================
AC_CHECK_MEMBERS([struct iphdr.saddr],,,[[#include <netinet/ip.h>]])
AM_CONDITIONAL(BUILD_TICKLE, test "$ac_cv_member_struct_iphdr_saddr" = "yes" )
dnl ========================================================================
dnl libnet
dnl ========================================================================
libnet=""
libnet_version="none"
LIBNETLIBS=""
LIBNETDEFINES=""
AC_MSG_CHECKING(if libnet is required)
libnet_fatal=$enable_libnet
case $enable_libnet in
no) ;;
yes|libnet10|libnet11|10|11) libnet_fatal=yes;;
try)
case $host_os in
*Linux*|*linux*) libnet_fatal=no;;
*) libnet_fatal=yes;; dnl legacy behavior
esac
;;
*) libnet_fatal=yes; enable_libnet=try;;
esac
AC_MSG_RESULT($libnet_fatal)
if test "x$enable_libnet" != "xno"; then
AC_PATH_PROGS(LIBNETCONFIG, libnet-config)
AC_CHECK_LIB(nsl, t_open) dnl -lnsl
AC_CHECK_LIB(socket, socket) dnl -lsocket
AC_CHECK_LIB(net, libnet_get_hwaddr, LIBNETLIBS=" -lnet", [])
fi
AC_MSG_CHECKING(for libnet)
if test "x$LIBNETLIBS" != "x" -o "x$enable_libnet" = "xlibnet11"; then
LIBNETDEFINES=""
if test "$ac_cv_lib_nsl_t_open" = yes; then
LIBNETLIBS="-lnsl $LIBNETLIBS"
fi
if test "$ac_cv_lib_socket_socket" = yes; then
LIBNETLIBS="-lsocket $LIBNETLIBS"
fi
libnet=net
libnet_version="libnet1.1"
fi
if test "x$enable_libnet" = "xtry" -o "x$enable_libnet" = "xlibnet10"; then
if test "x$LIBNETLIBS" = x -a "x${LIBNETCONFIG}" != "x" ; then
LIBNETDEFINES="`$LIBNETCONFIG --defines` `$LIBNETCONFIG --cflags`";
LIBNETLIBS="`$LIBNETCONFIG --libs`";
libnet_version="libnet1.0 (old)"
case $LIBNETLIBS in
*-l*) libnet=`echo $LIBNETLIBS | sed 's%.*-l%%'`;;
*) libnet_version=none;;
esac
CPPFLAGS="$CPPFLAGS $LIBNETDEFINES"
AC_CHECK_HEADERS(libnet.h)
if test "$ac_cv_header_libnet_h" = no; then
libnet_version=none
fi
fi
fi
AC_MSG_RESULT(found $libnet_version)
if test "$libnet_version" = none; then
LIBNETLIBS=""
LIBNETDEFINES=""
if test $libnet_fatal = yes; then
AC_MSG_ERROR(libnet not found)
fi
else
AC_CHECK_LIB($libnet,libnet_init,
[new_libnet=yes; AC_DEFINE(HAVE_LIBNET_1_1_API, 1, Libnet 1.1 API)],
[new_libnet=no; AC_DEFINE(HAVE_LIBNET_1_0_API, 1, Libnet 1.0 API)],$LIBNETLIBS)
AC_SUBST(LIBNETLIBS)
fi
if test "$new_libnet" = yes; then
AC_MSG_CHECKING(for libnet API 1.1.4: )
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fgnu89-inline -Wall -Werror"
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(#include <libnet.h>
int main(){libnet_t *l=NULL; libnet_pblock_record_ip_offset(l, l->total_size); return(0); })],
[AC_MSG_RESULT(no)],
[AC_DEFINE(HAVE_LIBNET_1_1_4_API, 1, Libnet 1.1.4 API) AC_MSG_RESULT(yes)])
CFLAGS="$save_CFLAGS"
fi
sendarp_linux=0
case $host_os in
*Linux*|*linux*) sendarp_linux=1;;
esac
+redhat_based=0
+AC_CHECK_FILE(/etc/redhat-release, [redhat_based=1])
+
AC_SUBST(LIBNETLIBS)
AC_SUBST(LIBNETDEFINES)
AM_CONDITIONAL(SENDARP_LINUX, test $sendarp_linux = 1 )
AM_CONDITIONAL(USE_LIBNET, test "x$libnet_version" != "xnone" )
+AM_CONDITIONAL(NFSCONVERT, test $redhat_based = 1 )
dnl ************************************************************************
dnl * Check for netinet/icmp6.h to enable the IPv6addr resource agent
AC_CHECK_HEADERS(netinet/icmp6.h,[],[],[#include <sys/types.h>])
AM_CONDITIONAL(USE_IPV6ADDR_AGENT, test "$ac_cv_header_netinet_icmp6_h" = yes && test "$ac_cv_header_heartbeat_glue_config_h" = yes)
AM_CONDITIONAL(IPV6ADDR_COMPATIBLE, test "$ac_cv_header_netinet_icmp6_h" = yes)
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 -p | fgrep " CFLAGS=" > /dev/null; then
SAVED_CFLAGS="$CFLAGS"
unset CFLAGS
CFLAGS="$SAVED_CFLAGS"
unset SAVED_CFLAGS
fi
if test "$GCC" != yes; then
CFLAGS="$CFLAGS -g"
enable_fatal_warnings=no
else
CFLAGS="$CFLAGS -ggdb3"
# We had to eliminate -Wnested-externs because of libtool changes
# Also remove -Waggregate-return because we use one libnet
# call which returns a struct
EXTRA_FLAGS="-fgnu89-inline
-fstack-protector-all
-Wall
-Wbad-function-cast
-Wcast-qual
-Wdeclaration-after-statement
-Wendif-labels
-Wfloat-equal
-Wformat=2
-Wformat-security
-Wformat-nonliteral
-Winline
-Wmissing-prototypes
-Wmissing-declarations
-Wmissing-format-attribute
-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(LOCALE)
AC_SUBST(CC)
AC_SUBST(MAKE)
dnl The Makefiles and shell scripts we output
AC_CONFIG_FILES(Makefile \
resource-agents.pc \
include/Makefile \
heartbeat/Makefile \
heartbeat/ocf-binaries \
heartbeat/ocf-directories \
heartbeat/ocf-shellfuncs \
heartbeat/shellfuncs \
systemd/Makefile \
systemd/resource-agents.conf \
tools/Makefile \
+ tools/nfsconvert \
tools/ocf-tester \
tools/ocft/Makefile \
tools/ocft/ocft \
tools/ocft/caselib \
tools/ocft/README \
tools/ocft/README.zh_CN \
ldirectord/Makefile \
ldirectord/ldirectord \
ldirectord/init.d/Makefile \
ldirectord/init.d/ldirectord \
ldirectord/init.d/ldirectord.debian \
ldirectord/init.d/ldirectord.debian.default \
ldirectord/systemd/Makefile \
ldirectord/systemd/ldirectord.service \
ldirectord/logrotate.d/Makefile \
ldirectord/OCF/Makefile \
ldirectord/OCF/ldirectord \
doc/Makefile \
doc/man/Makefile \
rgmanager/Makefile \
rgmanager/src/Makefile \
rgmanager/src/resources/Makefile \
rgmanager/src/resources/ocf-shellfuncs \
rgmanager/src/resources/svclib_nfslock \
rgmanager/src/resources/lvm_by_lv.sh \
rgmanager/src/resources/lvm_by_vg.sh \
rgmanager/src/resources/utils/Makefile \
rgmanager/src/resources/utils/fs-lib.sh \
rgmanager/src/resources/utils/messages.sh \
rgmanager/src/resources/utils/config-utils.sh \
rgmanager/src/resources/utils/member_util.sh \
rgmanager/src/resources/utils/ra-skelet.sh \
)
dnl Files we output that need to be executable
AC_CONFIG_FILES([heartbeat/azure-events], [chmod +x heartbeat/azure-events])
AC_CONFIG_FILES([heartbeat/AoEtarget], [chmod +x heartbeat/AoEtarget])
AC_CONFIG_FILES([heartbeat/ManageRAID], [chmod +x heartbeat/ManageRAID])
AC_CONFIG_FILES([heartbeat/ManageVE], [chmod +x heartbeat/ManageVE])
AC_CONFIG_FILES([heartbeat/Squid], [chmod +x heartbeat/Squid])
AC_CONFIG_FILES([heartbeat/SysInfo], [chmod +x heartbeat/SysInfo])
AC_CONFIG_FILES([heartbeat/aws-vpc-route53], [chmod +x heartbeat/aws-vpc-route53])
AC_CONFIG_FILES([heartbeat/clvm], [chmod +x heartbeat/clvm])
AC_CONFIG_FILES([heartbeat/conntrackd], [chmod +x heartbeat/conntrackd])
AC_CONFIG_FILES([heartbeat/dnsupdate], [chmod +x heartbeat/dnsupdate])
AC_CONFIG_FILES([heartbeat/dummypy], [chmod +x heartbeat/dummypy])
AC_CONFIG_FILES([heartbeat/eDir88], [chmod +x heartbeat/eDir88])
AC_CONFIG_FILES([heartbeat/fio], [chmod +x heartbeat/fio])
AC_CONFIG_FILES([heartbeat/galera], [chmod +x heartbeat/galera])
AC_CONFIG_FILES([heartbeat/gcp-pd-move], [chmod +x heartbeat/gcp-pd-move])
AC_CONFIG_FILES([heartbeat/gcp-vpc-move-ip], [chmod +x heartbeat/gcp-vpc-move-ip])
AC_CONFIG_FILES([heartbeat/gcp-vpc-move-vip], [chmod +x heartbeat/gcp-vpc-move-vip])
AC_CONFIG_FILES([heartbeat/gcp-vpc-move-route], [chmod +x heartbeat/gcp-vpc-move-route])
AC_CONFIG_FILES([heartbeat/iSCSILogicalUnit], [chmod +x heartbeat/iSCSILogicalUnit])
AC_CONFIG_FILES([heartbeat/iSCSITarget], [chmod +x heartbeat/iSCSITarget])
AC_CONFIG_FILES([heartbeat/jira], [chmod +x heartbeat/jira])
AC_CONFIG_FILES([heartbeat/kamailio], [chmod +x heartbeat/kamailio])
AC_CONFIG_FILES([heartbeat/lxc], [chmod +x heartbeat/lxc])
AC_CONFIG_FILES([heartbeat/lxd-info], [chmod +x heartbeat/lxd-info])
AC_CONFIG_FILES([heartbeat/machine-info], [chmod +x heartbeat/machine-info])
AC_CONFIG_FILES([heartbeat/mariadb], [chmod +x heartbeat/mariadb])
AC_CONFIG_FILES([heartbeat/mpathpersist], [chmod +x heartbeat/mpathpersist])
AC_CONFIG_FILES([heartbeat/nfsnotify], [chmod +x heartbeat/nfsnotify])
AC_CONFIG_FILES([heartbeat/openstack-info], [chmod +x heartbeat/openstack-info])
AC_CONFIG_FILES([heartbeat/rabbitmq-cluster], [chmod +x heartbeat/rabbitmq-cluster])
AC_CONFIG_FILES([heartbeat/redis], [chmod +x heartbeat/redis])
AC_CONFIG_FILES([heartbeat/rsyslog], [chmod +x heartbeat/rsyslog])
AC_CONFIG_FILES([heartbeat/smb-share], [chmod +x heartbeat/smb-share])
AC_CONFIG_FILES([heartbeat/sg_persist], [chmod +x heartbeat/sg_persist])
AC_CONFIG_FILES([heartbeat/slapd], [chmod +x heartbeat/slapd])
AC_CONFIG_FILES([heartbeat/storage-mon], [chmod +x heartbeat/storage-mon])
AC_CONFIG_FILES([heartbeat/sybaseASE], [chmod +x heartbeat/sybaseASE])
AC_CONFIG_FILES([heartbeat/syslog-ng], [chmod +x heartbeat/syslog-ng])
AC_CONFIG_FILES([heartbeat/vsftpd], [chmod +x heartbeat/vsftpd])
AC_CONFIG_FILES([heartbeat/CTDB], [chmod +x heartbeat/CTDB])
AC_CONFIG_FILES([rgmanager/src/resources/ASEHAagent.sh], [chmod +x rgmanager/src/resources/ASEHAagent.sh])
AC_CONFIG_FILES([rgmanager/src/resources/apache.sh], [chmod +x rgmanager/src/resources/apache.sh])
AC_CONFIG_FILES([rgmanager/src/resources/bind-mount.sh], [chmod +x rgmanager/src/resources/bind-mount.sh])
AC_CONFIG_FILES([rgmanager/src/resources/clusterfs.sh], [chmod +x rgmanager/src/resources/clusterfs.sh])
AC_CONFIG_FILES([rgmanager/src/resources/db2.sh], [chmod +x rgmanager/src/resources/db2.sh])
AC_CONFIG_FILES([rgmanager/src/resources/drbd.sh], [chmod +x rgmanager/src/resources/drbd.sh])
AC_CONFIG_FILES([rgmanager/src/resources/fs.sh], [chmod +x rgmanager/src/resources/fs.sh])
AC_CONFIG_FILES([rgmanager/src/resources/ip.sh], [chmod +x rgmanager/src/resources/ip.sh])
AC_CONFIG_FILES([rgmanager/src/resources/lvm.sh], [chmod +x rgmanager/src/resources/lvm.sh])
AC_CONFIG_FILES([rgmanager/src/resources/mysql.sh], [chmod +x rgmanager/src/resources/mysql.sh])
AC_CONFIG_FILES([rgmanager/src/resources/named.sh], [chmod +x rgmanager/src/resources/named.sh])
AC_CONFIG_FILES([rgmanager/src/resources/netfs.sh], [chmod +x rgmanager/src/resources/netfs.sh])
AC_CONFIG_FILES([rgmanager/src/resources/nfsclient.sh], [chmod +x rgmanager/src/resources/nfsclient.sh])
AC_CONFIG_FILES([rgmanager/src/resources/nfsexport.sh], [chmod +x rgmanager/src/resources/nfsexport.sh])
AC_CONFIG_FILES([rgmanager/src/resources/nfsserver.sh], [chmod +x rgmanager/src/resources/nfsserver.sh])
AC_CONFIG_FILES([rgmanager/src/resources/openldap.sh], [chmod +x rgmanager/src/resources/openldap.sh])
AC_CONFIG_FILES([rgmanager/src/resources/oracledb.sh], [chmod +x rgmanager/src/resources/oracledb.sh])
AC_CONFIG_FILES([rgmanager/src/resources/oradg.sh], [chmod +x rgmanager/src/resources/oradg.sh])
AC_CONFIG_FILES([rgmanager/src/resources/orainstance.sh], [chmod +x rgmanager/src/resources/orainstance.sh])
AC_CONFIG_FILES([rgmanager/src/resources/oralistener.sh], [chmod +x rgmanager/src/resources/oralistener.sh])
AC_CONFIG_FILES([rgmanager/src/resources/postgres-8.sh], [chmod +x rgmanager/src/resources/postgres-8.sh])
AC_CONFIG_FILES([rgmanager/src/resources/samba.sh], [chmod +x rgmanager/src/resources/samba.sh])
AC_CONFIG_FILES([rgmanager/src/resources/script.sh], [chmod +x rgmanager/src/resources/script.sh])
AC_CONFIG_FILES([rgmanager/src/resources/service.sh], [chmod +x rgmanager/src/resources/service.sh])
AC_CONFIG_FILES([rgmanager/src/resources/smb.sh], [chmod +x rgmanager/src/resources/smb.sh])
AC_CONFIG_FILES([rgmanager/src/resources/tomcat-5.sh], [chmod +x rgmanager/src/resources/tomcat-5.sh])
AC_CONFIG_FILES([rgmanager/src/resources/tomcat-6.sh], [chmod +x rgmanager/src/resources/tomcat-6.sh])
AC_CONFIG_FILES([rgmanager/src/resources/vm.sh], [chmod +x rgmanager/src/resources/vm.sh])
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}])
AC_MSG_RESULT([ Build Version = $Format:%H$])
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([ Documentation = ${docdir}])
AC_MSG_RESULT([ State information = ${localstatedir}])
AC_MSG_RESULT([ System configuration = ${sysconfdir}])
AC_MSG_RESULT([ HA_BIN directory prefix = ${libexecdir}])
AC_MSG_RESULT([ RA state files = ${HA_RSCTMPDIR}])
AC_MSG_RESULT([ AIS Plugins = ${LCRSODIR}])
AC_MSG_RESULT([])
AC_MSG_RESULT([ CPPFLAGS = ${CPPFLAGS}])
AC_MSG_RESULT([ CFLAGS = ${CFLAGS}])
AC_MSG_RESULT([ Libraries = ${LIBS}])
AC_MSG_RESULT([ Stack Libraries = ${CLUSTERLIBS}])
diff --git a/heartbeat/nfsserver-redhat.sh b/heartbeat/nfsserver-redhat.sh
index 73a70c186..aec096605 100644
--- a/heartbeat/nfsserver-redhat.sh
+++ b/heartbeat/nfsserver-redhat.sh
@@ -1,171 +1,177 @@
NFS_SYSCONFIG="/etc/sysconfig/nfs"
NFS_SYSCONFIG_LOCAL_BACKUP="/etc/sysconfig/nfs.ha.bu"
NFS_SYSCONFIG_AUTOGEN_TAG="AUTOGENERATED by $0 high availability resource-agent"
+NFSCONVERT="$HA_BIN/nfsconvert"
nfsserver_redhat_meta_data() {
cat<<EOF
<parameter name="nfsd_args" unique="0" required="0">
<longdesc lang="en">
Specifies what arguments to pass to the nfs daemon on startup. View the rpc.nfsd man page for information on what arguments are available.
Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
</longdesc>
<shortdesc lang="en">
rpc.nfsd options
</shortdesc>
<content type="string" />
</parameter>
<parameter name="lockd_udp_port" unique="0" required="0">
<longdesc lang="en">
The udp port lockd should listen on.
Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
</longdesc>
<shortdesc lang="en">
lockd udp port
</shortdesc>
<content type="integer" />
</parameter>
<parameter name="lockd_tcp_port" unique="0" required="0">
<longdesc lang="en">
The tcp port lockd should listen on.
Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
</longdesc>
<shortdesc lang="en">
lockd tcp port
</shortdesc>
<content type="integer" />
</parameter>
<parameter name="statd_outgoing_port" unique="0" required="0">
<longdesc lang="en">
The source port number sm-notify uses when sending reboot notifications.
Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
</longdesc>
<shortdesc lang="en">
sm-notify source port
</shortdesc>
<content type="integer" />
</parameter>
<parameter name="statd_port" unique="0" required="0">
<longdesc lang="en">
The port number used for RPC listener sockets.
Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
</longdesc>
<shortdesc lang="en">
rpc.statd listener port
</shortdesc>
<content type="integer" />
</parameter>
<parameter name="mountd_port" unique="0" required="0">
<longdesc lang="en">
The port number used for rpc.mountd listener sockets.
Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
</longdesc>
<shortdesc lang="en">
rpc.mountd listener port
</shortdesc>
<content type="integer" />
</parameter>
<parameter name="rquotad_port" unique="0" required="0">
<longdesc lang="en">
The port number used for rpc.rquotad.
Note that setting this value will override all settings placed in the local /etc/sysconfig/nfs file.
</longdesc>
<shortdesc lang="en">
rpc.rquotad port
</shortdesc>
<content type="integer" />
</parameter>
EOF
}
set_arg()
{
local key="$1"
local value="$2"
local file="$3"
local requires_sysconfig="$4"
if [ -z "$value" ]; then
return
fi
# only write to the tmp /etc/sysconfig/nfs if sysconfig exists.
# otherwise this distro does not support setting these options.
if [ -d "/etc/sysconfig" ]; then
# replace if the value exists, append otherwise
if grep "^\s*${key}=" $file ; then
sed -i "s/\s*${key}=.*$/${key}=\"${value}\"/" $file
else
echo "${key}=\"${value}\"" >> $file
fi
elif [ "$requires_sysconfig" = "true" ]; then
ocf_log warn "/etc/sysconfig/nfs not found, unable to set port and nfsd args."
fi
export ${key}="${value}"
}
set_env_args()
{
local tmpconfig=$(mktemp ${HA_RSCTMP}/nfsserver-tmp-XXXXX)
local statd_args
if [ -f "$NFS_SYSCONFIG" ]; then
## Take the $NFS_SYSCONFIG file as our skeleton
cp $NFS_SYSCONFIG $tmpconfig
fi
# nfsd args
set_arg "RPCNFSDARGS" "$OCF_RESKEY_nfsd_args" "$tmpconfig" "true"
# mountd args
if [ -n "$OCF_RESKEY_mountd_port" ]; then
set_arg "RPCMOUNTDOPTS" "-p $OCF_RESKEY_mountd_port" "$tmpconfig" "true"
fi
# statd args. we always want to perform the notify using sm-notify after
# both rpc.statd and the nfsd daemons are initialized
statd_args="--no-notify"
if [ -n "$OCF_RESKEY_statd_outgoing_port" ]; then
statd_args="$statd_args -o $OCF_RESKEY_statd_outgoing_port"
fi
if [ -n "$OCF_RESKEY_statd_port" ]; then
statd_args="$statd_args -p $OCF_RESKEY_statd_port"
fi
set_arg "STATDARG" "$statd_args" "$tmpconfig" "false"
# lockd ports
set_arg "LOCKD_UDPPORT" "$OCF_RESKEY_lockd_udp_port" "$tmpconfig" "true"
set_arg "LOCKD_TCPPORT" "$OCF_RESKEY_lockd_tcp_port" "$tmpconfig" "true"
# rquotad_port
if [ -n "$OCF_RESKEY_rquotad_port" ]; then
set_arg "RPCRQUOTADOPTS" "-p $OCF_RESKEY_rquotad_port" "$tmpconfig" "true"
fi
# override local nfs config. preserve previous local config though.
if [ -s $tmpconfig ]; then
if [ -f "$NFS_SYSCONFIG" ]; then
cat $NFS_SYSCONFIG | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
if [ $? -ne 0 ]; then
# backup local nfs config if it doesn't have our HA autogen tag in it.
mv -f $NFS_SYSCONFIG $NFS_SYSCONFIG_LOCAL_BACKUP
fi
fi
cat $tmpconfig | grep -q -e "$NFS_SYSCONFIG_AUTOGEN_TAG" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "# $NFS_SYSCONFIG_AUTOGEN_TAG" > $NFS_SYSCONFIG
echo "# local config backup stored here, '$NFS_SYSCONFIG_LOCAL_BACKUP'" >> $NFS_SYSCONFIG
cat $tmpconfig >> $NFS_SYSCONFIG
else
cat $tmpconfig > $NFS_SYSCONFIG
fi
fi
rm -f $tmpconfig
+
+ if [ -e "$NFSCONVERT" ]; then
+ ocf_log debug "Running $NFSCONVERT"
+ $NFSCONVERT
+ fi
}
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 83ff43651..1309223b4 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,78 +1,83 @@
#
# heartbeat: Linux-HA heartbeat code
#
# Copyright (C) 2001 Michael Moerz
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = ocft
AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
halibdir = $(libexecdir)/heartbeat
EXTRA_DIST = ocf-tester.8 sfex_init.8
sbin_PROGRAMS =
sbin_SCRIPTS = ocf-tester
halib_PROGRAMS = findif \
storage_mon
+halib_SCRIPTS =
man8_MANS = ocf-tester.8
if BUILD_SFEX
halib_PROGRAMS += sfex_daemon
sbin_PROGRAMS += sfex_init sfex_stat
man8_MANS += sfex_init.8
endif
if USE_LIBNET
halib_PROGRAMS += send_arp
send_arp_SOURCES = send_arp.libnet.c
send_arp_CFLAGS = @LIBNETDEFINES@
send_arp_LDADD = $(GLIBLIB) -lplumb @LIBNETLIBS@
else
if SENDARP_LINUX
halib_PROGRAMS += send_arp
send_arp_SOURCES = send_arp.linux.c
endif
+if NFSCONVERT
+halib_SCRIPTS += nfsconvert
+endif
+
endif
sfex_daemon_SOURCES = sfex_daemon.c sfex.h sfex_lib.c sfex_lib.h
sfex_daemon_CFLAGS = -D_GNU_SOURCE
sfex_daemon_LDADD = $(GLIBLIB) -lplumb -lplumbgpl
sfex_init_SOURCES = sfex_init.c sfex.h sfex_lib.c sfex_lib.h
sfex_init_CFLAGS = -D_GNU_SOURCE
sfex_init_LDADD = $(GLIBLIB) -lplumb -lplumbgpl
sfex_stat_SOURCES = sfex_stat.c sfex.h sfex_lib.c sfex_lib.h
sfex_stat_CFLAGS = -D_GNU_SOURCE
sfex_stat_LDADD = $(GLIBLIB) -lplumb -lplumbgpl
findif_SOURCES = findif.c
storage_mon_SOURCES = storage_mon.c
if BUILD_TICKLE
halib_PROGRAMS += tickle_tcp
tickle_tcp_SOURCES = tickle_tcp.c
endif
.PHONY: install-exec-hook
diff --git a/tools/nfsconvert.in b/tools/nfsconvert.in
new file mode 100644
index 000000000..c58a16a4e
--- /dev/null
+++ b/tools/nfsconvert.in
@@ -0,0 +1,324 @@
+#!@PYTHON@ -tt
+"""
+Read in the deprecated /etc/sysconfig/nfs file and
+set the corresponding values in nfs.conf
+"""
+
+from __future__ import print_function
+import os
+import sys
+import getopt
+import subprocess
+import configparser
+
+CONF_NFS = '/etc/nfs.conf'
+CONF_IDMAP = '/etc/idmapd.conf'
+SYSCONF_NFS = '/etc/sysconfig/nfs'
+SYSCONF_BACKUP = ".rpmsave"
+CONF_TOOL = '/usr/sbin/nfsconf'
+
+# options for nfsd found in RPCNFSDARGS
+OPTS_NFSD = 'dH:p:rR:N:V:stTuUG:L:'
+LONG_NFSD = ['debug', 'host=', 'port=', 'rdma=', 'nfs-version=', 'no-nfs-version=',
+ 'tcp', 'no-tcp', 'udp', 'no-udp', 'grace-time=', 'lease-time=']
+CONV_NFSD = {'-d': (CONF_NFS, 'nfsd', 'debug', 'all'),
+ '-H': (CONF_NFS, 'nfsd', 'host', ','),
+ '-p': (CONF_NFS, 'nfsd', 'port', '$1'),
+ '-r': (CONF_NFS, 'nfsd', 'rdma', 'nfsrdma'),
+ '-R': (CONF_NFS, 'nfsd', 'rdma', '$1'),
+ '-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '-t': (CONF_NFS, 'nfsd', 'tcp', '1'),
+ '-T': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '-u': (CONF_NFS, 'nfsd', 'udp', '1'),
+ '-U': (CONF_NFS, 'nfsd', 'udp', '0'),
+ '-G': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
+ '-L': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
+ '$1': (CONF_NFS, 'nfsd', 'threads', '$1'),
+ '--debug': (CONF_NFS, 'nfsd', 'debug', 'all'),
+ '--host': (CONF_NFS, 'nfsd', 'host', ','),
+ '--port': (CONF_NFS, 'nfsd', 'port', '$1'),
+ '--rdma': (CONF_NFS, 'nfsd', 'rdma', '$1'),
+ '--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '--tcp': (CONF_NFS, 'nfsd', 'tcp', '1'),
+ '--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '--udp': (CONF_NFS, 'nfsd', 'udp', '1'),
+ '--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'),
+ '--grace-time': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
+ '--lease-time': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
+ }
+
+# options for mountd found in RPCMOUNTDOPTS
+OPTS_MOUNTD = 'go:d:H:p:N:nrs:t:V:'
+LONG_MOUNTD = ['descriptors=', 'debug=', 'nfs-version=', 'no-nfs-version=',
+ 'port=', 'no-tcp', 'ha-callout=', 'state-directory-path=',
+ 'num-threads=', 'reverse-lookup', 'manage-gids', 'no-udp']
+
+CONV_MOUNTD = {'-g': (CONF_NFS, 'mountd', 'manage-gids', '1'),
+ '-o': (CONF_NFS, 'mountd', 'descriptors', '$1'),
+ '-d': (CONF_NFS, 'mountd', 'debug', '$1'),
+ '-H': (CONF_NFS, 'mountd', 'ha-callout', '$1'),
+ '-p': (CONF_NFS, 'mountd', 'port', '$1'),
+ '-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '-n': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '-s': (CONF_NFS, 'mountd', 'stat-directory-path', '$1'),
+ '-t': (CONF_NFS, 'mountd', 'threads', '$1'),
+ '-r': (CONF_NFS, 'mountd', 'reverse-lookup', '1'),
+ '-u': (CONF_NFS, 'nfsd', 'udp', '0'),
+ '--manage-gids': (CONF_NFS, 'mountd', 'manage-gids', '1'),
+ '--descriptors': (CONF_NFS, 'mountd', 'descriptors', '$1'),
+ '--debug': (CONF_NFS, 'mountd', 'debug', '$1'),
+ '--ha-callout': (CONF_NFS, 'mountd', 'ha-callout', '$1'),
+ '--port': (CONF_NFS, 'mountd', 'port', '$1'),
+ '--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '--state-directory-path': (CONF_NFS, 'mountd', 'state-directory-path', '$1'),
+ '--num-threads': (CONF_NFS, 'mountd', 'threads', '$1'),
+ '--reverse-lookup': (CONF_NFS, 'mountd', 'reverse-lookup', '1'),
+ '--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'),
+ }
+
+# options for statd found in STATDARG
+OPTS_STATD = 'o:p:T:U:n:P:H:L'
+LONG_STATD = ['outgoing-port=', 'port=', 'name=', 'state-directory-path=',
+ 'ha-callout=', 'nlm-port=', 'nlm-udp-port=', 'no-notify']
+CONV_STATD = {'-o': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
+ '-p': (CONF_NFS, 'statd', 'port', '$1'),
+ '-T': (CONF_NFS, 'lockd', 'port', '$1'),
+ '-U': (CONF_NFS, 'lockd', 'udp-port', '$1'),
+ '-n': (CONF_NFS, 'statd', 'name', '$1'),
+ '-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
+ '-H': (CONF_NFS, 'statd', 'ha-callout', '$1'),
+ '-L': (CONF_NFS, 'statd', 'no-notify', '1'),
+ '--outgoing-port': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
+ '--port': (CONF_NFS, 'statd', 'port', '$1'),
+ '--name': (CONF_NFS, 'statd', 'name', '$1'),
+ '--state-directory-path': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
+ '--ha-callout': (CONF_NFS, 'statd', 'ha-callout', '$1'),
+ '--nlm-port': (CONF_NFS, 'lockd', 'port', '$1'),
+ '--nlm-udp-port': (CONF_NFS, 'lockd', 'udp-port', '$1'),
+ '--no-notify': (CONF_NFS, 'statd', 'no-notify', '1'),
+ }
+
+# options for sm-notify found in SMNOTIFYARGS
+OPTS_SMNOTIFY = 'dm:np:v:P:f'
+CONV_SMNOTIFY = {'-d': (CONF_NFS, 'sm-notify', 'debug', 'all'),
+ '-m': (CONF_NFS, 'sm-notify', 'retry-time', '$1'),
+ '-n': (CONF_NFS, 'sm-notify', 'update-state', '1'),
+ '-p': (CONF_NFS, 'sm-notify', 'outgoing-port', '$1'),
+ '-v': (CONF_NFS, 'sm-notify', 'outgoing-addr', '$1'),
+ '-f': (CONF_NFS, 'sm-notify', 'force', '1'),
+ '-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
+ }
+
+# options for idmapd found in RPCIDMAPDARGS
+OPTS_IDMAPD = 'vp:CS'
+CONV_IDMAPD = {'-v': (CONF_IDMAP, 'general', 'verbosity', '+'),
+ '-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'),
+ '-C': (CONF_IDMAP, 'general', 'client-only', '1'),
+ '-S': (CONF_IDMAP, 'general', 'server-only', '1'),
+ }
+
+# options for gssd found in RPCGSSDARGS
+OPTS_GSSD = 'Mnvrp:k:d:t:T:R:lD'
+CONV_GSSD = {'-M': (CONF_NFS, 'gssd', 'use-memcache', '1'),
+ '-n': (CONF_NFS, 'gssd', 'root_uses_machine_creds', '0'),
+ '-v': (CONF_NFS, 'gssd', 'verbosity', '+'),
+ '-r': (CONF_NFS, 'gssd', 'rpc-verbosity', '+'),
+ '-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'),
+ '-k': (CONF_NFS, 'gssd', 'keytab-file', '$1'),
+ '-d': (CONF_NFS, 'gssd', 'cred-cache-directory', '$1'),
+ '-t': (CONF_NFS, 'gssd', 'context-timeout', '$1'),
+ '-T': (CONF_NFS, 'gssd', 'rpc-timeout', '$1'),
+ '-R': (CONF_NFS, 'gssd', 'preferred-realm', '$1'),
+ '-l': (CONF_NFS, 'gssd', 'limit-to-legacy-enctypes', '0'),
+ '-D': (CONF_NFS, 'gssd', 'avoid-dns', '0'),
+ }
+
+# options for blkmapd found in BLKMAPDARGS
+OPTS_BLKMAPD = ''
+CONV_BLKMAPD = {}
+
+# meta list of all the getopt lists
+GETOPT_MAPS = [('RPCNFSDARGS', OPTS_NFSD, LONG_NFSD, CONV_NFSD),
+ ('RPCMOUNTDOPTS', OPTS_MOUNTD, LONG_MOUNTD, CONV_MOUNTD),
+ ('STATDARG', OPTS_STATD, LONG_STATD, CONV_STATD),
+ ('STATDARGS', OPTS_STATD, LONG_STATD, CONV_STATD),
+ ('SMNOTIFYARGS', OPTS_SMNOTIFY, [], CONV_SMNOTIFY),
+ ('RPCIDMAPDARGS', OPTS_IDMAPD, [], CONV_IDMAPD),
+ ('RPCGSSDARGS', OPTS_GSSD, [], CONV_GSSD),
+ ('BLKMAPDARGS', OPTS_BLKMAPD, [], CONV_BLKMAPD),
+ ]
+
+# any fixups we need to apply first
+GETOPT_FIXUP = {'RPCNFSDARGS': ('--rdma', '--rdma=nfsrdma'),
+ }
+
+# map for all of the single option values
+VALUE_MAPS = {'LOCKD_TCPPORT': (CONF_NFS, 'lockd', 'port', '$1'),
+ 'LOCKD_UDPPORT': (CONF_NFS, 'lockd', 'udp-port', '$1'),
+ 'RPCNFSDCOUNT': (CONF_NFS, 'nfsd', 'threads', '$1'),
+ 'NFSD_V4_GRACE': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
+ 'NFSD_V4_LEASE': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
+ 'MOUNTD_PORT': (CONF_NFS, 'mountd', 'port', '$1'),
+ 'STATD_PORT': (CONF_NFS, 'statd', 'port', '$1'),
+ 'STATD_OUTGOING_PORT': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
+ 'STATD_HA_CALLOUT': (CONF_NFS, 'statd', 'ha-callout', '$1'),
+ 'GSS_USE_PROXY': (CONF_NFS, 'gssd', 'use-gss-proxy', '$1')
+ }
+
+def eprint(*args, **kwargs):
+ """ Print error to stderr """
+ print(*args, file=sys.stderr, **kwargs)
+
+def makesub(param, value):
+ """ Variable substitution """
+ return param.replace('$1', value)
+
+def set_value(value, entry):
+ """ Set a configuration value by running nfsconf tool"""
+ cfile, section, tag, param = entry
+
+ tag = makesub(tag, value)
+ param = makesub(param, value)
+ if param == '+':
+ param = value
+ if param == ',':
+ param = value
+ args = [CONF_TOOL, "--file", cfile, "--set", section, tag, param]
+
+ try:
+ subprocess.check_output(args, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ print("Error running nfs-conf tool:\n %s" % (e.output.decode()))
+ print("Args: %s\n" % args)
+ raise Exception
+
+def convert_getopt(optname, options, optstring, longopts, conversions):
+ """ Parse option string into seperate config items
+
+ Take a getopt string and a table of conversions
+ parse it all and spit out the converted config
+
+ Keyword arguments:
+ options -- the argv string to convert
+ optstring -- getopt format option list
+ conversions -- table of translations
+ """
+ optcount = 0
+ try:
+ args = options.strip('\"').split()
+ if optname in GETOPT_FIXUP:
+ (k, v) = GETOPT_FIXUP[optname]
+ for i, opt in enumerate(args):
+ if opt == k:
+ args[i] = v
+ elif opt == '--':
+ break
+ optlist, optargs = getopt.gnu_getopt(args, optstring, longopts=longopts)
+ except getopt.GetoptError as err:
+ eprint(err)
+ raise Exception
+
+ setlist = {}
+ for (k, v) in optlist:
+ if k in conversions:
+ # it's already been set once
+ param = conversions[k][3]
+ tag = k + makesub(conversions[k][2], v)
+ if tag in setlist:
+ value = setlist[tag][0]
+ # is it a cummulative entry
+ if param == '+':
+ value = str(int(value) + 1)
+ if param == ',':
+ value += "," + v
+ else:
+ if param == '+':
+ value = "1"
+ elif param == ',':
+ value = v
+ else:
+ value = v
+ setlist[tag] = (value, conversions[k])
+ else:
+ if v:
+ eprint("Ignoring unrecognised option %s=%s in %s" % (k, v, optname))
+ else:
+ eprint("Ignoring unrecognised option %s in %s" % (k, optname))
+
+
+ for v, c in setlist.values():
+ try:
+ set_value(v, c)
+ optcount += 1
+ except Exception:
+ raise
+
+ i = 1
+ for o in optargs:
+ opname = '$' + str(i)
+ if opname in conversions:
+ try:
+ set_value(o, conversions[opname])
+ optcount += 1
+ except Exception:
+ raise
+ else:
+ eprint("Unrecognised trailing arguments")
+ raise Exception
+ i += 1
+
+ return optcount
+
+def map_values():
+ """ Main function """
+ mapcount = 0
+
+ # Lets load the old config
+ with open(SYSCONF_NFS) as cfile:
+ file_content = '[sysconf]\n' + cfile.read()
+ sysconfig = configparser.RawConfigParser()
+ sysconfig.read_string(file_content)
+
+ # Map all the getopt option lists
+ for (name, opts, lopts, conv) in GETOPT_MAPS:
+ if name in sysconfig['sysconf']:
+ try:
+ mapcount += convert_getopt(name, sysconfig['sysconf'][name], opts,
+ lopts, conv)
+ except Exception:
+ eprint("Error whilst converting %s to nfsconf options." % (name))
+ raise
+
+ # Map the single value options
+ for name, opts in VALUE_MAPS.items():
+ if name in sysconfig['sysconf']:
+ try:
+ value = sysconfig['sysconf'][name]
+ set_value(value.strip('\"'), opts)
+ mapcount += 1
+ except Exception:
+ raise
+
+ # All went well, move aside the old file
+ # but dont bother if there were no changes and
+ # an old config file already exists
+ backupfile = SYSCONF_NFS + SYSCONF_BACKUP
+ if mapcount > 0 or not os.path.exists(backupfile):
+ try:
+ os.replace(SYSCONF_NFS, backupfile)
+ except OSError as err:
+ eprint("Error moving old config %s: %s" % (SYSCONF_NFS, err))
+ raise
+
+# Main routine
+try:
+ map_values()
+except Exception as e:
+ eprint(e)
+ eprint("Conversion failed. Please correct the error and try again.")
+ exit(1)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Feb 24, 3:55 PM (1 h, 51 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1444150
Default Alt Text
(59 KB)
Attached To
Mode
rR Resource Agents
Attached
Detach File
Event Timeline
Log In to Comment