Skip to content
Snippets Groups Projects
Commit 2d48a3a2 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Allow programs to be part of the Ganeti library


Eventually this will help ensuring that clients and servers are of the
same version, as long as they're imported from the same path. Currently
it's relatively easy for gnt-* and ganeti-* to be from a different
version.

Scripts will be at ganeti.client.gnt_* and a small bootstrap script
calls a “Main” function from the module.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent f91e255a
Loading
...@@ -17,6 +17,7 @@ CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code ...@@ -17,6 +17,7 @@ CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
CHECK_MAN = $(top_srcdir)/autotools/check-man CHECK_MAN = $(top_srcdir)/autotools/check-man
REPLACE_VARS_SED = autotools/replace_vars.sed REPLACE_VARS_SED = autotools/replace_vars.sed
clientdir = $(pkgpythondir)/client
hypervisordir = $(pkgpythondir)/hypervisor hypervisordir = $(pkgpythondir)/hypervisor
httpdir = $(pkgpythondir)/http httpdir = $(pkgpythondir)/http
masterddir = $(pkgpythondir)/masterd masterddir = $(pkgpythondir)/masterd
...@@ -38,6 +39,7 @@ DIRS = \ ...@@ -38,6 +39,7 @@ DIRS = \
doc/examples/hooks \ doc/examples/hooks \
doc/examples/gnt-debug \ doc/examples/gnt-debug \
lib \ lib \
lib/client \
lib/build \ lib/build \
lib/confd \ lib/confd \
lib/http \ lib/http \
...@@ -74,6 +76,7 @@ maintainer-clean-local: ...@@ -74,6 +76,7 @@ maintainer-clean-local:
CLEANFILES = \ CLEANFILES = \
$(addsuffix /*.py[co],$(DIRS)) \ $(addsuffix /*.py[co],$(DIRS)) \
$(PYTHON_BOOTSTRAP) \
autotools/replace_vars.sed \ autotools/replace_vars.sed \
daemons/daemon-util \ daemons/daemon-util \
daemons/ensure-dirs \ daemons/ensure-dirs \
...@@ -134,6 +137,9 @@ pkgpython_PYTHON = \ ...@@ -134,6 +137,9 @@ pkgpython_PYTHON = \
lib/uidpool.py \ lib/uidpool.py \
lib/workerpool.py lib/workerpool.py
client_PYTHON = \
lib/client/__init__.py
hypervisor_PYTHON = \ hypervisor_PYTHON = \
lib/hypervisor/__init__.py \ lib/hypervisor/__init__.py \
lib/hypervisor/hv_base.py \ lib/hypervisor/hv_base.py \
...@@ -248,6 +254,8 @@ gnt_scripts = \ ...@@ -248,6 +254,8 @@ gnt_scripts = \
scripts/gnt-node \ scripts/gnt-node \
scripts/gnt-os scripts/gnt-os
PYTHON_BOOTSTRAP =
dist_sbin_SCRIPTS = \ dist_sbin_SCRIPTS = \
daemons/ganeti-noded \ daemons/ganeti-noded \
daemons/ganeti-watcher \ daemons/ganeti-watcher \
...@@ -257,6 +265,7 @@ dist_sbin_SCRIPTS = \ ...@@ -257,6 +265,7 @@ dist_sbin_SCRIPTS = \
$(gnt_scripts) $(gnt_scripts)
nodist_sbin_SCRIPTS = \ nodist_sbin_SCRIPTS = \
$(PYTHON_BOOTSTRAP) \
daemons/ganeti-cleaner daemons/ganeti-cleaner
dist_tools_SCRIPTS = \ dist_tools_SCRIPTS = \
...@@ -431,6 +440,7 @@ all_python_code = \ ...@@ -431,6 +440,7 @@ all_python_code = \
$(pkglib_python_scripts) \ $(pkglib_python_scripts) \
$(python_tests) \ $(python_tests) \
$(pkgpython_PYTHON) \ $(pkgpython_PYTHON) \
$(client_PYTHON) \
$(hypervisor_PYTHON) \ $(hypervisor_PYTHON) \
$(rapi_PYTHON) \ $(rapi_PYTHON) \
$(http_PYTHON) \ $(http_PYTHON) \
...@@ -605,6 +615,31 @@ $(REPLACE_VARS_SED): Makefile ...@@ -605,6 +615,31 @@ $(REPLACE_VARS_SED): Makefile
echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \ 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 # We need to create symlinks because "make distcheck" will not install Python
# files when building. # files when building.
stamp-srclinks: Makefile stamp-directories stamp-srclinks: Makefile stamp-directories
......
#
#
# Copyright (C) 2010 Google Inc.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Empty file for package definition.
"""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment