Add unittests for ganeti.errors
[ganeti-local] / Makefile.am
1 # Ganeti makefile
2 # - Indent with tabs only.
3 # - Keep files sorted; one line per file.
4 # - Directories in lib/ must have their own *dir variable (see hypervisor).
5 # - All directories must be listed DIRS.
6 # - Use autogen.sh to generate Makefile.in and configure script.
7
8 # Automake doesn't export these variables before version 1.10.
9 abs_top_builddir = @abs_top_builddir@
10 abs_top_srcdir = @abs_top_srcdir@
11
12 ACLOCAL_AMFLAGS = -I autotools
13 DOCBOOK_WRAPPER = $(top_srcdir)/autotools/docbook-wrapper
14 BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
15 RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
16 CHECK_PYTHON_CODE = $(top_srcdir)/autotools/check-python-code
17 CHECK_MAN = $(top_srcdir)/autotools/check-man
18 REPLACE_VARS_SED = autotools/replace_vars.sed
19
20 hypervisordir = $(pkgpythondir)/hypervisor
21 httpdir = $(pkgpythondir)/http
22 confddir = $(pkgpythondir)/confd
23 rapidir = $(pkgpythondir)/rapi
24 toolsdir = $(pkglibdir)/tools
25 docdir = $(datadir)/doc/$(PACKAGE)
26
27 # Delete output file if an error occurred while building it
28 .DELETE_ON_ERROR:
29
30 DIRS = \
31         autotools \
32         daemons \
33         devel \
34         doc \
35         doc/examples \
36         doc/examples/hooks \
37         lib \
38         lib/build \
39         lib/http \
40         lib/hypervisor \
41         lib/rapi \
42         lib/confd \
43         man \
44         qa \
45         scripts \
46         test \
47         test/data \
48         tools
49
50 MAINTAINERCLEANFILES = \
51         $(docpng) \
52         $(maninput) \
53         doc/install-quick.rst \
54         doc/news.rst
55
56 maintainer-clean-local:
57         rm -rf doc/api doc/html doc/coverage
58
59 CLEANFILES = \
60         autotools/replace_vars.sed \
61         daemons/daemon-util \
62         daemons/ganeti-cleaner \
63         devel/upload \
64         doc/examples/bash_completion \
65         doc/examples/ganeti.initd \
66         doc/examples/ganeti.cron \
67         doc/examples/gnt-config-backup \
68         doc/examples/hooks/ipsec \
69         lib/*.py[co] \
70         lib/build/*.py[co] \
71         lib/http/*.py[co] \
72         lib/hypervisor/*.py[co] \
73         lib/rapi/*.py[co] \
74         $(man_MANS) \
75         $(manhtml) \
76         qa/*.py[co] \
77         test/*.py[co] \
78         stamp-directories \
79         stamp-srclinks \
80         $(nodist_pkgpython_PYTHON)
81
82 BUILT_SOURCES = \
83         ganeti \
84         stamp-srclinks \
85         stamp-directories \
86         lib/_autoconf.py
87
88 nodist_pkgpython_PYTHON = \
89         lib/_autoconf.py
90
91 noinst_PYTHON = \
92         lib/build/__init__.py
93
94 pkgpython_PYTHON = \
95         lib/__init__.py \
96         lib/asyncnotifier.py \
97         lib/backend.py \
98         lib/bdev.py \
99         lib/bootstrap.py \
100         lib/cli.py \
101         lib/cmdlib.py \
102         lib/config.py \
103         lib/constants.py \
104         lib/daemon.py \
105         lib/errors.py \
106         lib/jqueue.py \
107         lib/jstore.py \
108         lib/locking.py \
109         lib/luxi.py \
110         lib/mcpu.py \
111         lib/objects.py \
112         lib/opcodes.py \
113         lib/rpc.py \
114         lib/serializer.py \
115         lib/ssconf.py \
116         lib/ssh.py \
117         lib/storage.py \
118         lib/utils.py \
119         lib/workerpool.py
120
121 hypervisor_PYTHON = \
122         lib/hypervisor/__init__.py \
123         lib/hypervisor/hv_base.py \
124         lib/hypervisor/hv_chroot.py \
125         lib/hypervisor/hv_fake.py \
126         lib/hypervisor/hv_kvm.py \
127         lib/hypervisor/hv_xen.py
128
129 rapi_PYTHON = \
130         lib/rapi/__init__.py \
131         lib/rapi/baserlib.py \
132         lib/rapi/connector.py \
133         lib/rapi/rlib2.py
134
135 http_PYTHON = \
136         lib/http/__init__.py \
137         lib/http/auth.py \
138         lib/http/client.py \
139         lib/http/server.py
140
141 confd_PYTHON = \
142         lib/confd/__init__.py \
143         lib/confd/client.py \
144         lib/confd/server.py \
145         lib/confd/querylib.py
146
147 docrst = \
148         doc/admin.rst \
149         doc/design-2.0.rst \
150         doc/design-2.1.rst \
151         doc/devnotes.rst \
152         doc/glossary.rst \
153         doc/hooks.rst \
154         doc/iallocator.rst \
155         doc/index.rst \
156         doc/install-quick.rst \
157         doc/install.rst \
158         doc/locking.rst \
159         doc/news.rst \
160         doc/rapi.rst \
161         doc/security.rst \
162         doc/walkthrough.rst
163
164 doc/html/.stamp: $(docrst) $(docpng) doc/conf.py configure.ac
165         @test -n "$(SPHINX)" || \
166             { echo 'sphinx-build' not found during configure; exit 1; }
167         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(SPHINX) -q -W -b html \
168             -d . \
169             -D version="$(VERSION_MAJOR).$(VERSION_MINOR)" \
170             -D release="$(PACKAGE_VERSION)" \
171             $(abs_top_srcdir)/doc $(CURDIR)/doc/html
172         rm -f doc/html/.buildinfo doc/html/objects.inv
173         touch $@
174
175 doc/html: doc/html/.stamp
176
177 doc/news.rst: NEWS
178         set -e; \
179         { echo '.. This file is automatically updated at build time from $<.'; \
180           echo '.. Do not edit.'; \
181           echo; \
182           cat $<; \
183         } > $@
184
185 doc/install-quick.rst: INSTALL
186         set -e; \
187         { echo '.. This file is automatically updated at build time from $<.'; \
188           echo '.. Do not edit.'; \
189           echo; \
190           cat $<; \
191         } > $@
192
193 docdot = \
194         doc/arch-2.0.dot \
195         doc/design-2.1-lock-acquire.dot \
196         doc/design-2.1-lock-release.dot
197
198 docpng = $(patsubst %.dot,%.png,$(docdot))
199
200 # Things to build but not to install (add it to EXTRA_DIST if it should be
201 # distributed)
202 noinst_DATA = \
203         devel/upload \
204         doc/html \
205         doc/examples/bash_completion \
206         doc/examples/ganeti.cron \
207         doc/examples/ganeti.initd \
208         doc/examples/gnt-config-backup \
209         doc/examples/hooks/ipsec \
210         $(manhtml)
211
212 gnt_scripts = \
213         scripts/gnt-backup \
214         scripts/gnt-cluster \
215         scripts/gnt-debug \
216         scripts/gnt-instance \
217         scripts/gnt-job \
218         scripts/gnt-node \
219         scripts/gnt-os
220
221 dist_sbin_SCRIPTS = \
222         daemons/ganeti-noded \
223         daemons/ganeti-watcher \
224         daemons/ganeti-masterd \
225         daemons/ganeti-confd \
226         daemons/ganeti-rapi \
227         $(gnt_scripts)
228
229 nodist_sbin_SCRIPTS = \
230         daemons/ganeti-cleaner
231
232 dist_tools_SCRIPTS = \
233         tools/burnin \
234         tools/cfgshell \
235         tools/cfgupgrade \
236         tools/cluster-merge \
237         tools/lvmstrap
238
239 pkglib_SCRIPTS = \
240         daemons/daemon-util
241
242 EXTRA_DIST = \
243         NEWS \
244         pylintrc \
245         autotools/build-bash-completion \
246         autotools/check-python-code \
247         autotools/check-man \
248         autotools/docbook-wrapper \
249         autotools/gen-coverage \
250         $(RUN_IN_TEMPDIR) \
251         daemons/daemon-util.in \
252         daemons/ganeti-cleaner.in \
253         devel/upload.in \
254         $(docdot) \
255         $(docpng) \
256         $(docrst) \
257         doc/conf.py \
258         doc/html \
259         doc/examples/ganeti.initd.in \
260         doc/examples/ganeti.cron.in \
261         doc/examples/gnt-config-backup.in \
262         doc/examples/dumb-allocator \
263         doc/examples/ganeti.default \
264         doc/examples/ganeti.default-debug \
265         doc/examples/hooks/ethers \
266         doc/examples/hooks/ipsec.in \
267         test/testutils.py \
268         test/mocks.py \
269         $(dist_TESTS) \
270         $(TEST_FILES) \
271         man/footer.sgml \
272         $(mansgml) \
273         $(maninput) \
274         qa/ganeti-qa.py \
275         qa/qa-sample.json \
276         qa/qa_cluster.py \
277         qa/qa_config.py \
278         qa/qa_daemon.py \
279         qa/qa_env.py \
280         qa/qa_error.py \
281         qa/qa_instance.py \
282         qa/qa_node.py \
283         qa/qa_os.py \
284         qa/qa_rapi.py \
285         qa/qa_tags.py \
286         qa/qa_utils.py
287
288 man_MANS = \
289         man/ganeti.7 \
290         man/ganeti-cleaner.8 \
291         man/ganeti-confd.8 \
292         man/ganeti-masterd.8 \
293         man/ganeti-noded.8 \
294         man/ganeti-os-interface.7 \
295         man/ganeti-rapi.8 \
296         man/ganeti-watcher.8 \
297         man/gnt-backup.8 \
298         man/gnt-cluster.8 \
299         man/gnt-debug.8 \
300         man/gnt-instance.8 \
301         man/gnt-job.8 \
302         man/gnt-node.8 \
303         man/gnt-os.8
304
305 mansgml = $(patsubst %.7,%.sgml,$(patsubst %.8,%.sgml,$(man_MANS)))
306 manhtml = $(patsubst %.sgml,%.html,$(mansgml))
307 maninput = \
308         $(patsubst %.7,%.7.in,$(patsubst %.8,%.8.in,$(man_MANS))) \
309         $(patsubst %.html,%.html.in,$(manhtml))
310
311 TEST_FILES = \
312         test/data/bdev-both.txt \
313         test/data/bdev-8.3-both.txt \
314         test/data/bdev-disk.txt \
315         test/data/bdev-net.txt \
316         test/data/cert1.pem \
317         test/data/proc_drbd8.txt \
318         test/data/proc_drbd80-emptyline.txt \
319         test/data/proc_drbd83.txt
320
321 dist_TESTS = \
322         test/ganeti.bdev_unittest.py \
323         test/ganeti.cli_unittest.py \
324         test/ganeti.cmdlib_unittest.py \
325         test/ganeti.confd_client_unittest.py \
326         test/ganeti.config_unittest.py \
327         test/ganeti.constants_unittest.py \
328         test/ganeti.errors_unittest.py \
329         test/ganeti.hooks_unittest.py \
330         test/ganeti.http_unittest.py \
331         test/ganeti.locking_unittest.py \
332         test/ganeti.mcpu_unittest.py \
333         test/ganeti.objects_unittest.py \
334         test/ganeti.opcodes_unittest.py \
335         test/ganeti.rapi.resources_unittest.py \
336         test/ganeti.serializer_unittest.py \
337         test/ganeti.ssh_unittest.py \
338         test/ganeti.utils_unittest.py \
339         test/ganeti.workerpool_unittest.py \
340         test/docs_unittest.py \
341         test/tempfile_fork_unittest.py
342
343 nodist_TESTS =
344
345 TESTS = $(dist_TESTS) $(nodist_TESTS)
346
347 # Environment for all tests
348 PLAIN_TESTS_ENVIRONMENT = \
349         PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
350
351 # Environment for tests run by automake
352 TESTS_ENVIRONMENT = $(PLAIN_TESTS_ENVIRONMENT) $(PYTHON)
353
354 all_python_code = \
355         $(dist_sbin_SCRIPTS) \
356         $(dist_tools_SCRIPTS) \
357         $(dist_TESTS) \
358         $(pkgpython_PYTHON) \
359         $(hypervisor_PYTHON) \
360         $(rapi_PYTHON) \
361         $(http_PYTHON) \
362         $(confd_PYTHON) \
363         $(noinst_PYTHON)
364
365 srclink_files = \
366         man/footer.sgml \
367         $(all_python_code)
368
369 check_python_code = \
370         $(BUILD_BASH_COMPLETION) \
371         $(all_python_code)
372
373 lint_python_code = \
374         ganeti \
375         $(dist_sbin_SCRIPTS) \
376         $(dist_tools_SCRIPTS) \
377         $(BUILD_BASH_COMPLETION)
378
379 devel/upload: devel/upload.in $(REPLACE_VARS_SED)
380         sed -f $(REPLACE_VARS_SED) < $< > $@
381         chmod u+x $@
382
383 daemons/%: daemons/%.in \
384                 $(REPLACE_VARS_SED)
385         sed -f $(REPLACE_VARS_SED) < $< > $@
386         chmod +x $@
387
388 doc/examples/%: doc/examples/%.in \
389                 $(REPLACE_VARS_SED)
390         sed -f $(REPLACE_VARS_SED) < $< > $@
391
392 doc/examples/hooks/%: doc/examples/hooks/%.in \
393                 $(REPLACE_VARS_SED)
394         sed -f $(REPLACE_VARS_SED) < $< > $@
395
396 doc/examples/bash_completion: $(BUILD_BASH_COMPLETION) $(RUN_IN_TEMPDIR) \
397         lib/cli.py $(gnt_scripts) tools/burnin
398         PYTHONPATH=. $(RUN_IN_TEMPDIR) $(CURDIR)/$(BUILD_BASH_COMPLETION) > $@
399
400 doc/%.png: doc/%.dot
401         @test -n "$(DOT)" || { echo 'dot' not found during configure; exit 1; }
402         $(DOT) -Tpng -o $@ $<
403
404 man/%.7.in man/%.8.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
405         @test -n "$(DOCBOOK2MAN)" || \
406           { echo 'docbook2man' not found during configure; exit 1; }
407         $(DOCBOOK_WRAPPER) "$(DOCBOOK2MAN)" $< $(notdir $(@:.in=)) $@
408
409 man/%.html.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
410         @test -n "$(DOCBOOK2HTML)" || \
411           { echo 'docbook2html' not found during configure; exit 1; }
412         $(DOCBOOK_WRAPPER) "$(DOCBOOK2HTML) --nochunks" $< $(notdir $(@:.in=)) $@
413
414 man/%.7: man/%.7.in $(REPLACE_VARS_SED)
415         sed -f $(REPLACE_VARS_SED) < $< > $@
416         $(CHECK_MAN) $@
417
418 man/%.8: man/%.8.in $(REPLACE_VARS_SED)
419         sed -f $(REPLACE_VARS_SED) < $< > $@
420         $(CHECK_MAN) $@
421
422 man/%.html: man/%.html.in $(REPLACE_VARS_SED)
423         sed -f $(REPLACE_VARS_SED) < $< > $@
424
425 lib/_autoconf.py: Makefile stamp-directories
426         set -e; \
427         { echo '# This file is automatically generated, do not edit!'; \
428           echo '#'; \
429           echo ''; \
430           echo '"""Build-time configuration for Ganeti.'; \
431           echo '';\
432           echo 'This file is autogenerated by the build process.'; \
433           echo 'For any changes you need to re-run ./configure (and'; \
434           echo 'not edit by hand).'; \
435           echo ''; \
436           echo '"""'; \
437           echo ''; \
438           echo '# pylint: disable-msg=C0301,C0324'; \
439           echo '# because this is autogenerated, we do not want'; \
440           echo '# style warnings' ; \
441           echo ''; \
442           echo "PACKAGE_VERSION = '$(PACKAGE_VERSION)'"; \
443           echo "VERSION_MAJOR = '$(VERSION_MAJOR)'"; \
444           echo "VERSION_MINOR = '$(VERSION_MINOR)'"; \
445           echo "VERSION_REVISION = '$(VERSION_REVISION)'"; \
446           echo "VERSION_SUFFIX = '$(VERSION_SUFFIX)'"; \
447           echo "VERSION_FULL = '$(VERSION_FULL)'"; \
448           echo "LOCALSTATEDIR = '$(localstatedir)'"; \
449           echo "SYSCONFDIR = '$(sysconfdir)'"; \
450           echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
451           echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
452           echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
453           echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
454           echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
455           echo "XEN_INITRD = '$(XEN_INITRD)'"; \
456           echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \
457           echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \
458           echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
459           echo "KVM_PATH = '$(KVM_PATH)'"; \
460           echo "SOCAT_PATH = '$(SOCAT)'"; \
461           echo "SOCAT_USE_ESCAPE = $(SOCAT_USE_ESCAPE)"; \
462           echo "LVM_STRIPECOUNT = $(LVM_STRIPECOUNT)"; \
463           echo "TOOLSDIR = '$(toolsdir)'"; \
464           echo "GNT_SCRIPTS = [$(foreach i,$(notdir $(gnt_scripts)),'$(i)',)]"; \
465           echo "PKGLIBDIR = '$(pkglibdir)'"; \
466           echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
467           echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
468         } > $@
469
470 $(REPLACE_VARS_SED): Makefile
471         set -e; \
472         { echo 's#@PREFIX@#$(prefix)#g'; \
473           echo 's#@SYSCONFDIR@#$(sysconfdir)#g'; \
474           echo 's#@LOCALSTATEDIR@#$(localstatedir)#g'; \
475           echo 's#@BINDIR@#$(bindir)#g'; \
476           echo 's#@SBINDIR@#$(sbindir)#g'; \
477           echo 's#@GANETI_VERSION@#$(PACKAGE_VERSION)#g'; \
478           echo 's#@CUSTOM_XEN_BOOTLOADER@#$(XEN_BOOTLOADER)#g'; \
479           echo 's#@CUSTOM_XEN_KERNEL@#$(XEN_KERNEL)#g'; \
480           echo 's#@CUSTOM_XEN_INITRD@#$(XEN_INITRD)#g'; \
481           echo 's#@RPL_FILE_STORAGE_DIR@#$(FILE_STORAGE_DIR)#g'; \
482           echo 's#@RPL_SSH_INITD_SCRIPT@#$(SSH_INITD_SCRIPT)#g'; \
483           echo 's#@PKGLIBDIR@#$(pkglibdir)#g'; \
484         } > $@
485
486 # We need to create symlinks because "make distcheck" will not install Python
487 # files when building.
488 stamp-srclinks: Makefile stamp-directories
489         set -e; \
490         for i in $(srclink_files); do \
491                 if test ! -f $$i -a -f $(abs_top_srcdir)/$$i; then \
492                         $(LN_S) $(abs_top_srcdir)/$$i $$i; \
493                 fi; \
494         done
495         touch $@
496
497 .PHONY: ganeti
498 ganeti:
499         cd $(top_builddir) && test -h "$@" || { rm -f $@ && $(LN_S) lib $@; }
500
501 check-local:
502         $(CHECK_PYTHON_CODE) $(check_python_code)
503
504 .PHONY: lint
505 lint: ganeti $(BUILT_SOURCES)
506         @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
507         $(PYLINT) $(LINT_OPTS) $(lint_python_code)
508
509 # a dist hook rule for catching revision control directories
510 distcheck-hook:
511         if find $(top_distdir) -name .svn -or -name .git | grep .; then \
512                 echo "Found revision control files in final archive." 1>&2; \
513                 exit 1; \
514         fi
515         if find $(top_distdir) -name '*.py[co]' | grep .; then \
516                 echo "Found Python byte code in final archive." 1>&2; \
517                 exit 1; \
518         fi
519         if find $(top_distdir) -name '*~' | grep .; then \
520                 echo "Found backup files in final archive." 1>&2; \
521                 exit 1; \
522         fi
523
524 install-exec-local:
525         @mkdir_p@ "$(DESTDIR)${localstatedir}/lib/ganeti" \
526           "$(DESTDIR)${localstatedir}/log/ganeti" \
527           "$(DESTDIR)${localstatedir}/run/ganeti"
528
529 stamp-directories: Makefile
530         @mkdir_p@ $(DIRS)
531         touch $@
532
533 .PHONY: apidoc
534 apidoc: epydoc.conf $(RUN_IN_TEMPDIR) $(BUILT_SOURCES)
535         test -e doc/api || mkdir doc/api
536         $(RUN_IN_TEMPDIR) epydoc -v \
537                 --conf $(CURDIR)/epydoc.conf \
538                 --output $(CURDIR)/doc/api
539
540 .PHONY: TAGS
541 TAGS: $(BUILT_SOURCES)
542         rm -f TAGS
543         find . -path './lib/*.py' -o -path 'scripts/gnt-*' -o \
544           -path 'daemons/ganeti-*' -o -path 'tools/*' | \
545           etags -
546
547 .PHONY: coverage
548 coverage: $(BUILT_SOURCES) $(TESTS)
549         set -e; \
550         mkdir -p doc/coverage; \
551         COVERAGE_FILE=$(CURDIR)/doc/coverage/data \
552         TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \
553         HTML_COVERAGE=$(CURDIR)/doc/coverage \
554         $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage $(TESTS)
555
556 # vim: set noet :