mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-17 06:04:23 +03:00
python: Add bindings for liblvm2app.
Use configure --enable-python_bindings to generate them. Note that the Makefiles do not yet control the owner or permissions of the two new files on installation.
This commit is contained in:
parent
4022fd3e79
commit
ee3cfa4184
17
Makefile.in
17
Makefile.in
@ -32,13 +32,17 @@ ifeq ("@APPLIB@", "yes")
|
||||
SUBDIRS += liblvm
|
||||
endif
|
||||
|
||||
ifeq ("@PYTHON_BINDINGS@", "yes")
|
||||
SUBDIRS += python
|
||||
endif
|
||||
|
||||
SUBDIRS += scripts
|
||||
|
||||
# FIXME Should use intermediate Makefiles here!
|
||||
ifeq ($(MAKECMDGOALS),distclean)
|
||||
SUBDIRS = doc include man test scripts \
|
||||
libdaemon lib tools daemons libdm \
|
||||
udev po liblvm \
|
||||
udev po liblvm python \
|
||||
unit-tests/datastruct unit-tests/mm unit-tests/regex
|
||||
endif
|
||||
DISTCLEAN_DIRS += lcov_reports*
|
||||
@ -69,6 +73,10 @@ po.pofile: tools.pofile daemons.pofile
|
||||
pofile: po.pofile
|
||||
endif
|
||||
|
||||
ifeq ("@PYTHON_BINDINGS@", "yes")
|
||||
python: liblvm
|
||||
endif
|
||||
|
||||
ifneq ("$(CFLOW_CMD)", "")
|
||||
tools.cflow: libdm.cflow lib.cflow
|
||||
daemons.cflow: tools.cflow
|
||||
@ -103,6 +111,11 @@ install_systemd_generators:
|
||||
install_systemd_units:
|
||||
$(MAKE) -C scripts install_systemd_units
|
||||
|
||||
ifeq ("@PYTHON_BINDINGS@", "yes")
|
||||
install_python_bindings:
|
||||
$(MAKE) -C liblvm/python install_python_bindings
|
||||
endif
|
||||
|
||||
install_tmpfiles_configuration:
|
||||
$(MAKE) -C scripts install_tmpfiles_configuration
|
||||
|
||||
@ -148,7 +161,7 @@ ifeq ("$(TESTING)", "yes")
|
||||
# testing and report generation
|
||||
RUBY=ruby1.9 -Ireport-generators/lib -Ireport-generators/test
|
||||
|
||||
.PHONEY: unit-test ruby-test test-programs
|
||||
.PHONY: unit-test ruby-test test-programs
|
||||
|
||||
# FIXME: put dependencies on libdm and liblvm
|
||||
# FIXME: Should be handled by Makefiles in subdirs, not here at top level.
|
||||
|
@ -1,5 +1,6 @@
|
||||
Version 2.02.98 -
|
||||
=================================
|
||||
Add configure --enable-python_bindings for liblvm2app to new python subdir.
|
||||
Add implementation of lvm2api function lvm_percent_to_float.
|
||||
Allow non power of 2 thin chunk sizes if thin pool driver supports that.
|
||||
Allow limited metadata changes when PVs are missing via [vg|lv]change.
|
||||
|
216
configure
vendored
216
configure
vendored
@ -624,6 +624,9 @@ SELINUX_LIBS
|
||||
REPLICATORS
|
||||
READLINE_LIBS
|
||||
RAID
|
||||
PYTHON_LIBDIRS
|
||||
PYTHON_INCDIRS
|
||||
PYTHON_BINDINGS
|
||||
PTHREAD_LIBS
|
||||
POOL
|
||||
PKGCONFIG
|
||||
@ -686,10 +689,15 @@ BUILD_CMIRRORD
|
||||
APPLIB
|
||||
MODPROBE_CMD
|
||||
MSGFMT
|
||||
PYTHON_CONFIG
|
||||
PYTHON
|
||||
LVM2CMD_LIB
|
||||
LVM2APP_LIB
|
||||
UDEV_LIBS
|
||||
UDEV_CFLAGS
|
||||
VALGRIND_POOL
|
||||
VALGRIND_LIBS
|
||||
VALGRIND_CFLAGS
|
||||
CUNIT_LIBS
|
||||
CUNIT_CFLAGS
|
||||
GENPNG
|
||||
@ -842,6 +850,7 @@ enable_ioctl
|
||||
enable_o_direct
|
||||
enable_applib
|
||||
enable_cmdlib
|
||||
enable_python_bindings
|
||||
enable_pkgconfig
|
||||
enable_write_install
|
||||
enable_fsadm
|
||||
@ -901,6 +910,8 @@ SACKPT_CFLAGS
|
||||
SACKPT_LIBS
|
||||
CUNIT_CFLAGS
|
||||
CUNIT_LIBS
|
||||
VALGRIND_CFLAGS
|
||||
VALGRIND_LIBS
|
||||
UDEV_CFLAGS
|
||||
UDEV_LIBS'
|
||||
|
||||
@ -1542,6 +1553,8 @@ Optional Features:
|
||||
--disable-o_direct disable O_DIRECT
|
||||
--enable-applib build application library
|
||||
--enable-cmdlib build shared command library
|
||||
--enable-python_bindings
|
||||
build Python applib bindings
|
||||
--enable-pkgconfig install pkgconfig support
|
||||
--enable-write_install install user writable files
|
||||
--disable-fsadm disable fsadm
|
||||
@ -1678,6 +1691,10 @@ Some influential environment variables:
|
||||
CUNIT_CFLAGS
|
||||
C compiler flags for CUNIT, overriding pkg-config
|
||||
CUNIT_LIBS linker flags for CUNIT, overriding pkg-config
|
||||
VALGRIND_CFLAGS
|
||||
C compiler flags for VALGRIND, overriding pkg-config
|
||||
VALGRIND_LIBS
|
||||
linker flags for VALGRIND, overriding pkg-config
|
||||
UDEV_CFLAGS C compiler flags for UDEV, overriding pkg-config
|
||||
UDEV_LIBS linker flags for UDEV, overriding pkg-config
|
||||
|
||||
@ -8814,23 +8831,80 @@ fi
|
||||
$as_echo "$VALGRIND_POOL" >&6; }
|
||||
|
||||
if test "$VALGRIND_POOL" = yes; then
|
||||
for ac_header in valgrind/memcheck.h
|
||||
do :
|
||||
ac_fn_c_check_header_mongrel "$LINENO" "valgrind/memcheck.h" "ac_cv_header_valgrind_memcheck_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_valgrind_memcheck_h" = x""yes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_VALGRIND_MEMCHECK_H 1
|
||||
_ACEOF
|
||||
|
||||
pkg_failed=no
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for VALGRIND" >&5
|
||||
$as_echo_n "checking for VALGRIND... " >&6; }
|
||||
|
||||
if test -n "$VALGRIND_CFLAGS"; then
|
||||
pkg_cv_VALGRIND_CFLAGS="$VALGRIND_CFLAGS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"valgrind\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "valgrind") 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_VALGRIND_CFLAGS=`$PKG_CONFIG --cflags "valgrind" 2>/dev/null`
|
||||
else
|
||||
as_fn_error $? "bailing out" "$LINENO" 5
|
||||
pkg_failed=yes
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
if test -n "$VALGRIND_LIBS"; then
|
||||
pkg_cv_VALGRIND_LIBS="$VALGRIND_LIBS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"valgrind\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "valgrind") 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_VALGRIND_LIBS=`$PKG_CONFIG --libs "valgrind" 2>/dev/null`
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
||||
_pkg_short_errors_supported=yes
|
||||
else
|
||||
_pkg_short_errors_supported=no
|
||||
fi
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
VALGRIND_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "valgrind" 2>&1`
|
||||
else
|
||||
VALGRIND_PKG_ERRORS=`$PKG_CONFIG --print-errors "valgrind" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$VALGRIND_PKG_ERRORS" >&5
|
||||
|
||||
as_fn_error $? "bailing out" "$LINENO" 5
|
||||
elif test $pkg_failed = untried; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
as_fn_error $? "bailing out" "$LINENO" 5
|
||||
else
|
||||
VALGRIND_CFLAGS=$pkg_cv_VALGRIND_CFLAGS
|
||||
VALGRIND_LIBS=$pkg_cv_VALGRIND_LIBS
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
|
||||
fi
|
||||
|
||||
$as_echo "#define VALGRIND_POOL 1" >>confdefs.h
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
@ -9120,6 +9194,122 @@ test x$CMDLIB = xyes \
|
||||
&& LVM2CMD_LIB=-llvm2cmd \
|
||||
|| LVM2CMD_LIB=
|
||||
|
||||
################################################################################
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build Python wrapper for liblvm2app.so" >&5
|
||||
$as_echo_n "checking whether to build Python wrapper for liblvm2app.so... " >&6; }
|
||||
# Check whether --enable-python_bindings was given.
|
||||
if test "${enable_python_bindings+set}" = set; then :
|
||||
enableval=$enable_python_bindings; PYTHON_BINDINGS=$enableval
|
||||
else
|
||||
PYTHON_BINDINGS=no
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_BINDINGS" >&5
|
||||
$as_echo "$PYTHON_BINDINGS" >&6; }
|
||||
|
||||
if test x$PYTHON_BINDINGS = xyes; then
|
||||
if test x$APPLIB != xyes; then
|
||||
as_fn_error $? "--enable-python_bindings requires --enable-applib
|
||||
" "$LINENO" 5
|
||||
fi
|
||||
|
||||
# Extract the first word of "python", so it can be a program name with args.
|
||||
set dummy python; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if test "${ac_cv_path_PYTHON+set}" = set; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $PYTHON in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
test -z "$ac_cv_path_PYTHON" && ac_cv_path_PYTHON="notfound"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
PYTHON=$ac_cv_path_PYTHON
|
||||
if test -n "$PYTHON"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
|
||||
$as_echo "$PYTHON" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
if test x$PYTHON == xnotfound; then
|
||||
as_fn_error $? "python is required for --enable-python_bindings but cannot be found
|
||||
" "$LINENO" 5
|
||||
fi
|
||||
|
||||
# Extract the first word of "python-config", so it can be a program name with args.
|
||||
set dummy python-config; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if test "${ac_cv_path_PYTHON_CONFIG+set}" = set; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $PYTHON_CONFIG in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_PYTHON_CONFIG="$PYTHON_CONFIG" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_path_PYTHON_CONFIG="$as_dir/$ac_word$ac_exec_ext"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
test -z "$ac_cv_path_PYTHON_CONFIG" && ac_cv_path_PYTHON_CONFIG="notfound"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
PYTHON_CONFIG=$ac_cv_path_PYTHON_CONFIG
|
||||
if test -n "$PYTHON_CONFIG"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CONFIG" >&5
|
||||
$as_echo "$PYTHON_CONFIG" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
if test x$PYTHON_CONFIG == xnotfound; then
|
||||
as_fn_error $? "python headers are required for --enable-python_bindings but cannot be found
|
||||
" "$LINENO" 5
|
||||
fi
|
||||
|
||||
PYTHON_INCDIRS=`$PYTHON_CONFIG --includes`
|
||||
PYTHON_LIBDIRS=`$PYTHON_CONFIG --libs`
|
||||
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# Check whether --enable-pkgconfig was given.
|
||||
if test "${enable_pkgconfig+set}" = set; then :
|
||||
@ -10571,13 +10761,17 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.socket scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
|
||||
ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.socket scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@ -11303,6 +11497,8 @@ do
|
||||
"liblvm/liblvm2app.pc") CONFIG_FILES="$CONFIG_FILES liblvm/liblvm2app.pc" ;;
|
||||
"man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
|
||||
"po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;;
|
||||
"python/Makefile") CONFIG_FILES="$CONFIG_FILES python/Makefile" ;;
|
||||
"python/setup.py") CONFIG_FILES="$CONFIG_FILES python/setup.py" ;;
|
||||
"scripts/clvmd_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/clvmd_init_red_hat" ;;
|
||||
"scripts/cmirrord_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/cmirrord_init_red_hat" ;;
|
||||
"scripts/lvm2_lvmetad_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_init_red_hat" ;;
|
||||
|
40
configure.in
40
configure.in
@ -1026,6 +1026,40 @@ test x$CMDLIB = xyes \
|
||||
&& LVM2CMD_LIB=-llvm2cmd \
|
||||
|| LVM2CMD_LIB=
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable Python liblvm2app bindings
|
||||
AC_MSG_CHECKING(whether to build Python wrapper for liblvm2app.so)
|
||||
AC_ARG_ENABLE(python_bindings,
|
||||
AC_HELP_STRING([--enable-python_bindings], [build Python applib bindings]),
|
||||
PYTHON_BINDINGS=$enableval, PYTHON_BINDINGS=no)
|
||||
AC_MSG_RESULT($PYTHON_BINDINGS)
|
||||
|
||||
if test x$PYTHON_BINDINGS = xyes; then
|
||||
if test x$APPLIB != xyes; then
|
||||
AC_MSG_ERROR(
|
||||
--enable-python_bindings requires --enable-applib
|
||||
)
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(PYTHON, python, notfound)
|
||||
if test x$PYTHON == xnotfound; then
|
||||
AC_MSG_ERROR(
|
||||
[python is required for --enable-python_bindings but cannot be found]
|
||||
)
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(PYTHON_CONFIG, python-config, notfound)
|
||||
if test x$PYTHON_CONFIG == xnotfound; then
|
||||
AC_MSG_ERROR(
|
||||
[python headers are required for --enable-python_bindings but cannot be found]
|
||||
)
|
||||
fi
|
||||
|
||||
PYTHON_INCDIRS=`$PYTHON_CONFIG --includes`
|
||||
PYTHON_LIBDIRS=`$PYTHON_CONFIG --libs`
|
||||
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable pkg-config
|
||||
AC_ARG_ENABLE(pkgconfig,
|
||||
@ -1523,6 +1557,10 @@ AC_SUBST(OCFDIR)
|
||||
AC_SUBST(PKGCONFIG)
|
||||
AC_SUBST(POOL)
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
AC_SUBST(PYTHON)
|
||||
AC_SUBST(PYTHON_BINDINGS)
|
||||
AC_SUBST(PYTHON_INCDIRS)
|
||||
AC_SUBST(PYTHON_LIBDIRS)
|
||||
AC_SUBST(QUORUM_CFLAGS)
|
||||
AC_SUBST(QUORUM_LIBS)
|
||||
AC_SUBST(RAID)
|
||||
@ -1605,6 +1643,8 @@ liblvm/Makefile
|
||||
liblvm/liblvm2app.pc
|
||||
man/Makefile
|
||||
po/Makefile
|
||||
python/Makefile
|
||||
python/setup.py
|
||||
scripts/clvmd_init_red_hat
|
||||
scripts/cmirrord_init_red_hat
|
||||
scripts/lvm2_lvmetad_init_red_hat
|
||||
|
@ -432,9 +432,6 @@
|
||||
/* Define to 1 if you have the <utmpx.h> header file. */
|
||||
#undef HAVE_UTMPX_H
|
||||
|
||||
/* Define to 1 if you have the <valgrind/memcheck.h> header file. */
|
||||
#undef HAVE_VALGRIND_MEMCHECK_H
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
|
@ -28,6 +28,7 @@ LN_S = @LN_S@
|
||||
SED = @SED@
|
||||
CFLOW_CMD = @CFLOW_CMD@
|
||||
AWK = @AWK@
|
||||
PYTHON = @PYTHON@
|
||||
|
||||
LIBS = @LIBS@
|
||||
# Extra libraries always linked with static binaries
|
||||
@ -52,6 +53,7 @@ prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
udev_prefix = @udev_prefix@
|
||||
sysconfdir = @sysconfdir@
|
||||
rootdir = $(DESTDIR)/
|
||||
bindir = $(DESTDIR)@bindir@
|
||||
confdir = $(DESTDIR)@CONFDIR@/lvm
|
||||
includedir = $(DESTDIR)@includedir@
|
||||
@ -196,6 +198,7 @@ POTFILES = $(SOURCES:%.c=%.pot)
|
||||
.PHONY: install install_cluster install_device-mapper install_lvm2
|
||||
.PHONY: install_lib_shared install_dm_plugin install_lvm2_plugin
|
||||
.PHONY: install_ocf help
|
||||
.PHONY: python_bindings install_python_bindings
|
||||
.PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
|
||||
.PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow)
|
||||
.PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper)
|
||||
|
39
python/Makefile.in
Normal file
39
python/Makefile.in
Normal file
@ -0,0 +1,39 @@
|
||||
#
|
||||
# Copyright (C) 2011-2012 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU Lesser General Public License v.2.1.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser 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
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
python_bindings: .liblvm_built
|
||||
|
||||
.liblvm_built: liblvm_python.c
|
||||
$(PYTHON) setup.py build
|
||||
touch $@
|
||||
|
||||
liblvm_python.c:
|
||||
$(LN_S) $(srcdir)/liblvm.c $@
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
install_python_bindings: python_bindings
|
||||
$(PYTHON) setup.py install --skip-build --root $(rootdir)
|
||||
|
||||
install_lvm2: install_python_bindings
|
||||
|
||||
install: install_lvm2
|
||||
|
||||
CLEAN_TARGETS += .liblvm_built liblvm_python.c
|
||||
|
||||
DISTCLEAN_DIRS += build
|
||||
DISTCLEAN_TARGETS += setup.py
|
125
python/example.py
Normal file
125
python/example.py
Normal file
@ -0,0 +1,125 @@
|
||||
#
|
||||
# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This program 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 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------
|
||||
# Python example code:
|
||||
#-----------------------------
|
||||
|
||||
import lvm
|
||||
|
||||
# Note: This example will create a logical unit, tag it and
|
||||
# delete it, don't run this on production box!
|
||||
|
||||
#Dump information about PV
|
||||
def print_pv(pv):
|
||||
print 'PV name: ', pv.getName(), ' ID: ', pv.getUuid(), 'Size: ', pv.getSize()
|
||||
|
||||
|
||||
#Dump some information about a specific volume group
|
||||
def print_vg(h, vg_name):
|
||||
#Open read only
|
||||
vg = h.vgOpen(vg_name, 'r')
|
||||
|
||||
print 'Volume group:', vg_name, 'Size: ', vg.getSize()
|
||||
|
||||
#Retrieve a list of Physical volumes for this volume group
|
||||
pv_list = vg.listPVs()
|
||||
|
||||
#Print out the physical volumes
|
||||
for p in pv_list:
|
||||
print_pv(p)
|
||||
|
||||
#Get a list of logical volumes in this volume group
|
||||
lv_list = vg.listLVs()
|
||||
if len(lv_list):
|
||||
for l in lv_list:
|
||||
print 'LV name: ', l.getName(), ' ID: ', l.getUuid()
|
||||
else:
|
||||
print 'No logical volumes present!'
|
||||
|
||||
vg.close()
|
||||
|
||||
#Returns the name of a vg with space available
|
||||
def find_vg_with_free_space(h):
|
||||
free_space = 0
|
||||
rc = None
|
||||
|
||||
vg_names = l.listVgNames()
|
||||
for v in vg_names:
|
||||
vg = h.vgOpen(v, 'r')
|
||||
c_free = vg.getFreeSize()
|
||||
if c_free > free_space:
|
||||
free_space = c_free
|
||||
rc = v
|
||||
vg.close()
|
||||
|
||||
return rc
|
||||
|
||||
#Walk through the volume groups and fine one with space in which we can
|
||||
#create a new logical volume
|
||||
def create_delete_logical_volume(h):
|
||||
vg_name = find_vg_with_free_space(h)
|
||||
|
||||
print 'Using volume group ', vg_name, ' for example'
|
||||
|
||||
if vg_name:
|
||||
vg = h.vgOpen(vg_name, 'w')
|
||||
lv = vg.createLvLinear('python_lvm_ok_to_delete', vg.getFreeSize())
|
||||
|
||||
if lv:
|
||||
print 'New lv, id= ', lv.getUuid()
|
||||
|
||||
#Create a tag
|
||||
lv.addTag('Demo_tag')
|
||||
|
||||
#Get the tags
|
||||
tags = lv.getTags()
|
||||
for t in tags:
|
||||
#Remove tag
|
||||
lv.removeTag(t)
|
||||
|
||||
#Try to rename
|
||||
lv.rename("python_lvm_ok_to_be_removed_shortly")
|
||||
print 'LV name= ', lv.getName()
|
||||
|
||||
lv.deactivate()
|
||||
lv.remove()
|
||||
|
||||
vg.close()
|
||||
else:
|
||||
print 'No free space available to create demo lv!'
|
||||
|
||||
if __name__ == '__main__':
|
||||
#Create a new LVM instance
|
||||
l = lvm.Liblvm()
|
||||
|
||||
#What version
|
||||
print 'lvm version=', l.getVersion()
|
||||
|
||||
#Get a list of volume group names
|
||||
vg_names = l.listVgNames()
|
||||
|
||||
#For each volume group display some information about each of them
|
||||
for vg_i in vg_names:
|
||||
print_vg(l, vg_i)
|
||||
|
||||
#Demo creating a logical volume
|
||||
create_delete_logical_volume(l)
|
||||
|
||||
#Close
|
||||
l.close()
|
1711
python/liblvm.c
Normal file
1711
python/liblvm.c
Normal file
File diff suppressed because it is too large
Load Diff
35
python/setup.py.in
Normal file
35
python/setup.py.in
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This program 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 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from distutils.core import setup, Extension
|
||||
|
||||
liblvm = Extension('lvm',
|
||||
sources = ['liblvm_python.c'],
|
||||
libraries= ['lvm2app'],
|
||||
library_dirs= ['@top_builddir@/liblvm'],
|
||||
include_dirs= ['@top_builddir@/include'])
|
||||
|
||||
setup (name='lvm',
|
||||
version=@LVM_VERSION@,
|
||||
description='Python bindings for liblvm2',
|
||||
license="LGPLv2+",
|
||||
maintainer='LVM2 maintainers',
|
||||
maintainer_email='linux-lvm@redhat.com',
|
||||
url='http://sourceware.org/lvm2/',
|
||||
ext_modules=[liblvm],
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user