Allow programs to be part of the Ganeti library
[ganeti-local] / Makefile.am
index 9b7b4a9..15b6966 100644 (file)
@@ -17,6 +17,7 @@ CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
 CHECK_MAN = $(top_srcdir)/autotools/check-man
 REPLACE_VARS_SED = autotools/replace_vars.sed
 
+clientdir = $(pkgpythondir)/client
 hypervisordir = $(pkgpythondir)/hypervisor
 httpdir = $(pkgpythondir)/http
 masterddir = $(pkgpythondir)/masterd
@@ -38,6 +39,7 @@ DIRS = \
        doc/examples/hooks \
        doc/examples/gnt-debug \
        lib \
+       lib/client \
        lib/build \
        lib/confd \
        lib/http \
@@ -74,6 +76,7 @@ maintainer-clean-local:
 
 CLEANFILES = \
        $(addsuffix /*.py[co],$(DIRS)) \
+       $(PYTHON_BOOTSTRAP) \
        autotools/replace_vars.sed \
        daemons/daemon-util \
        daemons/ensure-dirs \
@@ -134,6 +137,9 @@ pkgpython_PYTHON = \
        lib/uidpool.py \
        lib/workerpool.py
 
+client_PYTHON = \
+       lib/client/__init__.py
+
 hypervisor_PYTHON = \
        lib/hypervisor/__init__.py \
        lib/hypervisor/hv_base.py \
@@ -248,6 +254,8 @@ gnt_scripts = \
        scripts/gnt-node \
        scripts/gnt-os
 
+PYTHON_BOOTSTRAP =
+
 dist_sbin_SCRIPTS = \
        daemons/ganeti-noded \
        daemons/ganeti-watcher \
@@ -257,6 +265,7 @@ dist_sbin_SCRIPTS = \
        $(gnt_scripts)
 
 nodist_sbin_SCRIPTS = \
+       $(PYTHON_BOOTSTRAP) \
        daemons/ganeti-cleaner
 
 dist_tools_SCRIPTS = \
@@ -431,6 +440,7 @@ all_python_code = \
        $(pkglib_python_scripts) \
        $(python_tests) \
        $(pkgpython_PYTHON) \
+       $(client_PYTHON) \
        $(hypervisor_PYTHON) \
        $(rapi_PYTHON) \
        $(http_PYTHON) \
@@ -605,6 +615,31 @@ $(REPLACE_VARS_SED): Makefile
          echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
        } > $@
 
+$(PYTHON_BOOTSTRAP): Makefile
+       set -e; \
+       module='$(subst -,_,$(notdir $@))'; \
+       { echo "#!$(PYTHON)"; \
+         echo '# This file is automatically generated, do not edit!'; \
+         echo "# Edit ganeti.client.$$module instead."; \
+         echo; \
+         echo '"""Bootstrap script for L{ganeti.client.'"$$module"'}"""'; \
+         echo; \
+         echo '# pylint: disable-msg=C0103'; \
+         echo '# C0103: Invalid name'; \
+         echo; \
+         echo 'import sys'; \
+         echo "from ganeti.client import $$module"; \
+         echo; \
+         echo '# Temporarily alias commands until bash completion'; \
+         echo '# generator is changed'; \
+         echo "if hasattr($$module, \"commands\"):"; \
+         echo "  commands = $$module.commands"; \
+         echo; \
+         echo 'if __name__ == "__main__":'; \
+         echo "  sys.exit($$module.Main())"; \
+       } > $@
+       chmod u+x $@
+
 # We need to create symlinks because "make distcheck" will not install Python
 # files when building.
 stamp-srclinks: Makefile stamp-directories