Statistics
| Branch: | Tag: | Revision:

root / doc / devnotes.rst @ 33c730a2

History | View | Annotate | Download (7.6 kB)

1 832aef24 Michael Hanselmann
Developer notes
2 832aef24 Michael Hanselmann
===============
3 832aef24 Michael Hanselmann
4 727ee1ec Iustin Pop
.. highlight:: shell-example
5 727ee1ec Iustin Pop
6 b2fc7ea1 Michael Hanselmann
Build dependencies
7 b2fc7ea1 Michael Hanselmann
------------------
8 b2fc7ea1 Michael Hanselmann
9 fc6075dd Agata Murawska
Most dependencies from :doc:`install-quick`, including ``qemu-img``
10 fc6075dd Agata Murawska
(marked there as optional) plus (for Python):
11 cbf3d64b Michael Hanselmann
12 c27ba1cc Michael Hanselmann
- `GNU make <http://www.gnu.org/software/make/>`_
13 c27ba1cc Michael Hanselmann
- `GNU tar <http://www.gnu.org/software/tar/>`_
14 c27ba1cc Michael Hanselmann
- `Gzip <http://www.gnu.org/software/gzip/>`_
15 18e2b6e4 Iustin Pop
- `pandoc <http://johnmacfarlane.net/pandoc/>`_
16 fc6075dd Agata Murawska
- `python-epydoc <http://epydoc.sourceforge.net/>`_
17 c27ba1cc Michael Hanselmann
- `python-sphinx <http://sphinx.pocoo.org/>`_
18 fc6075dd Agata Murawska
  (tested with version 1.1.3)
19 c27ba1cc Michael Hanselmann
- `graphviz <http://www.graphviz.org/>`_
20 1de45c78 Guido Trotter
- the `en_US.UTF-8` locale must be enabled on the system
21 77a180f6 Iustin Pop
- `pylint <http://www.logilab.org/857>`_ and its associated
22 77a180f6 Iustin Pop
  dependencies
23 08366664 Michael Hanselmann
- `pep8 <https://github.com/jcrocholl/pep8/>`_
24 77a180f6 Iustin Pop
25 fc6075dd Agata Murawska
For older developement (Ganeti < 2.4) ``docbook`` was used instead
26 fc6075dd Agata Murawska
``pandoc``.
27 fc6075dd Agata Murawska
28 77a180f6 Iustin Pop
Note that for pylint, at the current moment the following versions
29 727ee1ec Iustin Pop
must be used::
30 77a180f6 Iustin Pop
31 77a180f6 Iustin Pop
    $ pylint --version
32 099e9213 Iustin Pop
    pylint 0.25.1,
33 099e9213 Iustin Pop
    astng 0.23.1, common 0.58.0
34 b2fc7ea1 Michael Hanselmann
35 fc6075dd Agata Murawska
The same with pep8, other versions may give you errors::
36 fc6075dd Agata Murawska
37 fc6075dd Agata Murawska
     $ pep8 --version
38 5ae4945a Iustin Pop
     1.2
39 fc6075dd Agata Murawska
40 099e9213 Iustin Pop
Both these versions are the ones shipped with Debian Wheezy.
41 099e9213 Iustin Pop
42 27e336af Michael Hanselmann
To generate unittest coverage reports (``make coverage``), `coverage
43 27e336af Michael Hanselmann
<http://pypi.python.org/pypi/coverage>`_ needs to be installed.
44 27e336af Michael Hanselmann
45 fc6075dd Agata Murawska
Installation of all dependencies listed here::
46 fc6075dd Agata Murawska
47 fc6075dd Agata Murawska
     $ apt-get install python-setuptools
48 fc6075dd Agata Murawska
     $ apt-get install pandoc python-epydoc graphviz
49 fc6075dd Agata Murawska
     $ cd / && sudo easy_install \
50 fc6075dd Agata Murawska
               sphinx \
51 099e9213 Iustin Pop
               logilab-astng==0.25.1 \
52 099e9213 Iustin Pop
               logilab-common==0.58.0 \
53 099e9213 Iustin Pop
               pylint==0.23.1 \
54 5ae4945a Iustin Pop
               pep8==1.2 \
55 fc6075dd Agata Murawska
               coverage
56 fc6075dd Agata Murawska
57 77a180f6 Iustin Pop
For Haskell development, again all things from the quick install
58 77a180f6 Iustin Pop
document, plus:
59 77a180f6 Iustin Pop
60 77a180f6 Iustin Pop
- `haddock <http://www.haskell.org/haddock/>`_, documentation
61 77a180f6 Iustin Pop
  generator (equivalent to epydoc for Python)
62 77a180f6 Iustin Pop
- `HsColour <http://hackage.haskell.org/package/hscolour>`_, again
63 77a180f6 Iustin Pop
  used for documentation (it's source-code pretty-printing)
64 77a180f6 Iustin Pop
- `hlint <http://community.haskell.org/~ndm/hlint/>`_, a source code
65 3603605a Iustin Pop
  linter (equivalent to pylint for Python), recommended version 1.8 or
66 3603605a Iustin Pop
  above (tested with 1.8.15)
67 77a180f6 Iustin Pop
- the `QuickCheck <http://hackage.haskell.org/package/QuickCheck>`_
68 8e4f6d56 Iustin Pop
  library, version 2.x
69 95f6c931 Iustin Pop
- the `HUnit <http://hunit.sourceforge.net/>`_ library (tested with
70 95f6c931 Iustin Pop
  1.2.x)
71 95f6c931 Iustin Pop
- the `test-framework
72 95f6c931 Iustin Pop
  <http://batterseapower.github.com/test-framework/>`_ libraries,
73 95f6c931 Iustin Pop
  tested versions: ``test-framework``: 0.6, ``test-framework-hunit``:
74 fe7ad9c8 Iustin Pop
  0.2.7, ``test-framework-quickcheck2``: 0.2.12.1
75 fd0bc853 Iustin Pop
- ``hpc``, which comes with the compiler, so you should already have
76 fd0bc853 Iustin Pop
  it
77 727ee1ec Iustin Pop
- `shelltestrunner <http://joyful.com/shelltestrunner>`_, used for
78 95f6c931 Iustin Pop
  running shell-based unit-tests
79 4355b2de Iustin Pop
- `temporary <https://github.com/batterseapower/temporary/>`_ library,
80 4355b2de Iustin Pop
  tested with version 1.1.2.3
81 727ee1ec Iustin Pop
82 727ee1ec Iustin Pop
Under Debian Wheezy or later, these can be installed (on top of the
83 727ee1ec Iustin Pop
required ones from the quick install document) via::
84 fd0bc853 Iustin Pop
85 95f6c931 Iustin Pop
  $ apt-get install libghc-quickcheck2-dev libghc-hunit-dev \
86 95f6c931 Iustin Pop
        libghc-test-framework-dev \
87 95f6c931 Iustin Pop
        libghc-test-framework-quickcheck2-dev \
88 95f6c931 Iustin Pop
        libghc-test-framework-hunit-dev \
89 4355b2de Iustin Pop
        libghc-temporary-dev \
90 95f6c931 Iustin Pop
        hscolour hlint
91 fd0bc853 Iustin Pop
92 727ee1ec Iustin Pop
Or alternatively via ``cabal``::
93 727ee1ec Iustin Pop
94 21a5e56c Iustin Pop
  $ cabal install QuickCheck HUnit \
95 21a5e56c Iustin Pop
          test-framework test-framework-quickcheck2 test-framework-hunit \
96 4355b2de Iustin Pop
          temporary hscolour hlint shelltestrunner
97 77a180f6 Iustin Pop
98 b2fc7ea1 Michael Hanselmann
99 832aef24 Michael Hanselmann
Configuring for development
100 832aef24 Michael Hanselmann
---------------------------
101 832aef24 Michael Hanselmann
102 d17e74b4 Iustin Pop
Run the following command (only use ``PYTHON=...`` if you need to use a
103 d17e74b4 Iustin Pop
different python version)::
104 d17e74b4 Iustin Pop
105 727ee1ec Iustin Pop
  $ ./autogen.sh && \
106 727ee1ec Iustin Pop
    ./configure --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var
107 558fd122 Michael Hanselmann
108 cfa2b7a0 Iustin Pop
Note that doing development on a machine which already has Ganeti
109 cfa2b7a0 Iustin Pop
installed is problematic, as ``PYTHONPATH`` behaviour can be confusing
110 cfa2b7a0 Iustin Pop
(see Issue 170 for a bit of history/details; in general it works if
111 cfa2b7a0 Iustin Pop
the installed and developed versions are very similar, and/or if
112 cfa2b7a0 Iustin Pop
PYTHONPATH is customised correctly). As such, in general it's
113 cfa2b7a0 Iustin Pop
recommended to use a "clean" machine for ganeti development.
114 cfa2b7a0 Iustin Pop
115 ef958f2a Iustin Pop
Haskell development notes
116 ef958f2a Iustin Pop
-------------------------
117 ef958f2a Iustin Pop
118 ef958f2a Iustin Pop
There are a few things which can help writing or debugging the Haskell
119 ef958f2a Iustin Pop
code.
120 ef958f2a Iustin Pop
121 ef958f2a Iustin Pop
You can run the Haskell linter :command:`hlint` via::
122 ef958f2a Iustin Pop
123 727ee1ec Iustin Pop
  $ make hlint
124 ef958f2a Iustin Pop
125 3603605a Iustin Pop
This is not enabled by default (as the htools component is
126 3603605a Iustin Pop
optional). The above command will generate both output on the terminal
127 3603605a Iustin Pop
and, if any warnings are found, also an HTML report at
128 ef958f2a Iustin Pop
``doc/hs-lint.html``.
129 ef958f2a Iustin Pop
130 ef958f2a Iustin Pop
When writing or debugging TemplateHaskell code, it's useful to see
131 ef958f2a Iustin Pop
what the splices are converted to. This can be done via::
132 ef958f2a Iustin Pop
133 727ee1ec Iustin Pop
  $ make HEXTRA="-ddump-splices"
134 ef958f2a Iustin Pop
135 c96887cf Iustin Pop
Or, more interactively::
136 c96887cf Iustin Pop
137 c96887cf Iustin Pop
  $ ghci
138 c96887cf Iustin Pop
  λ> :set -ddump-splices
139 3add7574 Iustin Pop
  λ> :l src/Ganeti/Objects.hs
140 c96887cf Iustin Pop
141 c96887cf Iustin Pop
And you will get the spliced code as the module is loaded.
142 c96887cf Iustin Pop
143 d6b5da24 Guido Trotter
To build profiling code you must install the ``ghc-prof`` (or
144 d6b5da24 Guido Trotter
``gch6-prof``) package, and all the relevant libraries with their
145 d6b5da24 Guido Trotter
``-prof`` counterparts. If installing libraries through cabal the config
146 d6b5da24 Guido Trotter
file should include ``library-profiling: True`` or the ``-p`` flag
147 d6b5da24 Guido Trotter
should be used. Any library already installed can be updated by passing
148 d6b5da24 Guido Trotter
``--reinstall`` as well.
149 d6b5da24 Guido Trotter
150 ef958f2a Iustin Pop
Due to the way TemplateHaskell works, it's not straightforward to
151 c7ec3025 Iustin Pop
build profiling code. The recommended way is to run ``make hs-prof``,
152 c7ec3025 Iustin Pop
or alternatively the manual sequence is::
153 ef958f2a Iustin Pop
154 727ee1ec Iustin Pop
  $ make clean
155 3add7574 Iustin Pop
  $ make src/htools HEXTRA="-osuf .o"
156 3add7574 Iustin Pop
  $ rm src/htools
157 3add7574 Iustin Pop
  $ make src/htools HEXTRA="-osuf .prof_o -prof -auto-all"
158 ef958f2a Iustin Pop
159 ef958f2a Iustin Pop
This will build the binary twice, per the TemplateHaskell
160 ef958f2a Iustin Pop
documentation, the second one with profiling enabled.
161 ef958f2a Iustin Pop
162 ded769c1 Iustin Pop
The binary files generated by compilation and the profiling/coverage
163 ded769c1 Iustin Pop
files can "break" tab-completion in the sources; they can be ignored,
164 ded769c1 Iustin Pop
for example, in bash via ``.bashrc``::
165 ded769c1 Iustin Pop
166 ded769c1 Iustin Pop
  FIGNORE='.o:.hi:.prof_o:.tix'
167 ded769c1 Iustin Pop
168 ded769c1 Iustin Pop
or in emacs via ``completion-ignored-extensions`` (run ``M-x
169 ded769c1 Iustin Pop
customize-var completion-ignored-extensions``).
170 94338f0a Michael Hanselmann
171 06c9a9d6 Iustin Pop
Running individual tests
172 06c9a9d6 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~
173 06c9a9d6 Iustin Pop
174 06c9a9d6 Iustin Pop
When developing code, running the entire test suite can be
175 06c9a9d6 Iustin Pop
slow. Running individual tests is possible easily for unit-tests, less
176 06c9a9d6 Iustin Pop
so for shell-tests (but these are faster, so it shouldn't be needed).
177 06c9a9d6 Iustin Pop
178 06c9a9d6 Iustin Pop
For Python tests::
179 06c9a9d6 Iustin Pop
180 06c9a9d6 Iustin Pop
  $ export PYTHONPATH=$PWD
181 90066780 Iustin Pop
  $ python ./test/py/ganeti.%mytest%
182 06c9a9d6 Iustin Pop
183 06c9a9d6 Iustin Pop
For Haskell tests::
184 06c9a9d6 Iustin Pop
185 3784c431 Yiannis Tsiouris
  $ make test/hs/htest && ./test/hs/htest -t %pattern%
186 06c9a9d6 Iustin Pop
187 06c9a9d6 Iustin Pop
Where ``pattern`` can be a simple test pattern (e.g. ``comma``,
188 06c9a9d6 Iustin Pop
matching any test whose name contains ``comma``), a test pattern
189 06c9a9d6 Iustin Pop
denoting a group (ending with a slash, e.g. ``Utils/``), or more
190 06c9a9d6 Iustin Pop
complex glob pattern. For more details, see the documentation (on the
191 06c9a9d6 Iustin Pop
`test-framework homepage
192 06c9a9d6 Iustin Pop
<http://batterseapower.github.com/test-framework/>`_).
193 06c9a9d6 Iustin Pop
194 94338f0a Michael Hanselmann
Packaging notes
195 94338f0a Michael Hanselmann
===============
196 94338f0a Michael Hanselmann
197 77865fb4 Gintautas Miliauskas
Ganeti is mostly developed and tested on `Debian
198 94338f0a Michael Hanselmann
<http://www.debian.org/>`_-based distributions, while still keeping
199 77865fb4 Gintautas Miliauskas
adaptability to other Linux distributions in mind.
200 94338f0a Michael Hanselmann
201 94338f0a Michael Hanselmann
The ``doc/examples/`` directory contains a number of potentially useful
202 94338f0a Michael Hanselmann
scripts and configuration files. Some of them might need adjustment
203 94338f0a Michael Hanselmann
before use.
204 94338f0a Michael Hanselmann
205 94338f0a Michael Hanselmann
``daemon-util``
206 94338f0a Michael Hanselmann
---------------
207 94338f0a Michael Hanselmann
208 94338f0a Michael Hanselmann
This script, in the source code as ``daemons/daemon-util.in``, is used
209 94338f0a Michael Hanselmann
to start/stop Ganeti and do a few other things related to system
210 77a180f6 Iustin Pop
daemons. It is recommended to use ``daemon-util`` also from the system's
211 94338f0a Michael Hanselmann
init scripts. That way the code starting and stopping daemons is shared
212 94338f0a Michael Hanselmann
and future changes have to be made in only one place.
213 94338f0a Michael Hanselmann
214 94338f0a Michael Hanselmann
``daemon-util`` reads extra arguments from variables (``*_ARGS``) in
215 94338f0a Michael Hanselmann
``/etc/default/ganeti``. When modifying ``daemon-util``, keep in mind to
216 94338f0a Michael Hanselmann
not remove support for the ``EXTRA_*_ARGS`` variables for starting
217 94338f0a Michael Hanselmann
daemons. Some parts of Ganeti use them to pass additional arguments when
218 94338f0a Michael Hanselmann
starting a daemon.
219 94338f0a Michael Hanselmann
220 94338f0a Michael Hanselmann
The ``reload_ssh_keys`` function can be adjusted to use another command
221 94338f0a Michael Hanselmann
for reloading the OpenSSH daemon's host keys.
222 94338f0a Michael Hanselmann
223 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :