Statistics
| Branch: | Tag: | Revision:

root / man / ganeti-os-interface.rst @ 23fe06c2

History | View | Annotate | Download (11.3 kB)

1 4db3647e Iustin Pop
ganeti-os-interface(7) Ganeti | Version @GANETI_VERSION@
2 4db3647e Iustin Pop
========================================================
3 4db3647e Iustin Pop
4 4db3647e Iustin Pop
Name
5 4db3647e Iustin Pop
----
6 4db3647e Iustin Pop
7 4db3647e Iustin Pop
ganeti-os-interface - Specifications for guest OS types
8 4db3647e Iustin Pop
9 4db3647e Iustin Pop
DESCRIPTION
10 4db3647e Iustin Pop
-----------
11 4db3647e Iustin Pop
12 d1b1deb4 Iustin Pop
The method of supporting guest operating systems in Ganeti is to have,
13 d1b1deb4 Iustin Pop
for each guest OS type, a directory containing a number of required
14 d1b1deb4 Iustin Pop
files. This directory must be present across all nodes (Ganeti doesn't
15 d1b1deb4 Iustin Pop
replicate it) in order for the OS to be usable by Ganeti.
16 d1b1deb4 Iustin Pop
17 4db3647e Iustin Pop
18 4db3647e Iustin Pop
REFERENCE
19 4db3647e Iustin Pop
---------
20 4db3647e Iustin Pop
21 dfba45b1 Stephen Shirley
There are eight required files: *create*, *import*, *export*, *rename*,
22 d1b1deb4 Iustin Pop
*verify* (executables), *ganeti_api_version*, *variants.list* and
23 d1b1deb4 Iustin Pop
*parameters.list* (text files).
24 4db3647e Iustin Pop
25 4db3647e Iustin Pop
Common environment
26 4db3647e Iustin Pop
~~~~~~~~~~~~~~~~~~
27 4db3647e Iustin Pop
28 4db3647e Iustin Pop
All commands will get their input via environment variables. A
29 4db3647e Iustin Pop
common set of variables will be exported for all commands, and some
30 4db3647e Iustin Pop
of them might have extra ones. Note that all counts are
31 4db3647e Iustin Pop
zero-based.
32 4db3647e Iustin Pop
33 896a03f6 Iustin Pop
Since Ganeti version 2.5, the environment will be cleaned up before
34 896a03f6 Iustin Pop
being passed to scripts, therefore they will not inherit the environment
35 896a03f6 Iustin Pop
in with which the ganeti node daemon was started. If you depend on any
36 896a03f6 Iustin Pop
environment variables (non-Ganeti), then you will need to define or
37 896a03f6 Iustin Pop
source them appropriately.
38 896a03f6 Iustin Pop
39 4db3647e Iustin Pop
OS_API_VERSION
40 4db3647e Iustin Pop
    The OS API version that the rest of the environment conforms to.
41 4db3647e Iustin Pop
42 4db3647e Iustin Pop
INSTANCE_NAME
43 4db3647e Iustin Pop
    The instance name the script should operate on.
44 4db3647e Iustin Pop
45 4db3647e Iustin Pop
INSTANCE_OS, OS_NAME
46 4db3647e Iustin Pop
    Both names point to the name of the instance's OS as Ganeti knows
47 4db3647e Iustin Pop
    it. This can simplify the OS scripts by providing the same scripts
48 4db3647e Iustin Pop
    under multiple names, and then the scripts can use this name to
49 4db3647e Iustin Pop
    alter their behaviour.
50 4db3647e Iustin Pop
51 4db3647e Iustin Pop
    With OS API 15 changing the script behavior based on this variable
52 4db3647e Iustin Pop
    is deprecated: OS_VARIANT should be used instead (see below).
53 4db3647e Iustin Pop
54 4db3647e Iustin Pop
OS_VARIANT
55 4db3647e Iustin Pop
    The variant of the OS which should be installed. Each OS must
56 4db3647e Iustin Pop
    support all variants listed under its variants.list file, and may
57 4db3647e Iustin Pop
    support more. Any more supported variants should be properly
58 4db3647e Iustin Pop
    documented in the per-OS documentation.
59 4db3647e Iustin Pop
60 4db3647e Iustin Pop
HYPERVISOR
61 4db3647e Iustin Pop
    The hypervisor of this instance.
62 4db3647e Iustin Pop
63 4db3647e Iustin Pop
DISK_COUNT
64 4db3647e Iustin Pop
    The number of disks the instance has. The actual disk defitions are
65 4db3647e Iustin Pop
    in a set of additional variables. The instance's disk will be
66 4db3647e Iustin Pop
    numbered from 0 to this value minus one.
67 4db3647e Iustin Pop
68 4db3647e Iustin Pop
DISK_%N_PATH
69 4db3647e Iustin Pop
    The path to the storage for disk N of the instance. This might be
70 4db3647e Iustin Pop
    either a block device or a regular file, in which case the OS
71 4db3647e Iustin Pop
    scripts should use ``losetup`` (if they need to mount it). E.g. the
72 4db3647e Iustin Pop
    first disk of the instance might be exported as
73 4db3647e Iustin Pop
    ``DISK_0_PATH=/dev/drbd0``.
74 4db3647e Iustin Pop
75 4db3647e Iustin Pop
DISK_%N_ACCESS
76 4db3647e Iustin Pop
    This is how the hypervisor will export the instance disks: either
77 4db3647e Iustin Pop
    read-write (``rw``) or read-only (``ro``).
78 4db3647e Iustin Pop
79 4db3647e Iustin Pop
DISK_%N_FRONTEND_TYPE
80 4db3647e Iustin Pop
    (Optional) If applicable to the current hypervisor type: the type
81 4db3647e Iustin Pop
    of the device exported by the hypervisor. For example, the Xen HVM
82 4db3647e Iustin Pop
    hypervisor can export disks as either ``paravirtual`` or
83 4db3647e Iustin Pop
    ``ioemu``.
84 4db3647e Iustin Pop
85 4db3647e Iustin Pop
DISK_%N_BACKEND_TYPE
86 4db3647e Iustin Pop
    How files are visible on the node side. This can be either
87 4db3647e Iustin Pop
    ``block`` (when using block devices) or ``file:type``, where
88 4db3647e Iustin Pop
    ``type`` is either ``loop`` or ``blktap`` depending on how the
89 4db3647e Iustin Pop
    hypervisor will be configured.  Note that not all backend types
90 4db3647e Iustin Pop
    apply to all hypervisors.
91 4db3647e Iustin Pop
92 4db3647e Iustin Pop
NIC_COUNT
93 4db3647e Iustin Pop
    Similar to the ``DISK_COUNT``, this represents the number of NICs
94 4db3647e Iustin Pop
    of the instance.
95 4db3647e Iustin Pop
96 4db3647e Iustin Pop
NIC_%N_MAC
97 4db3647e Iustin Pop
    The MAC address associated with this interface.
98 4db3647e Iustin Pop
99 4db3647e Iustin Pop
NIC_%N_IP
100 4db3647e Iustin Pop
    The IP address, if any, associated with the N-th NIC of the
101 4db3647e Iustin Pop
    instance.
102 4db3647e Iustin Pop
103 4db3647e Iustin Pop
NIC_%N_MODE
104 4db3647e Iustin Pop
    The NIC mode, either routed or bridged
105 4db3647e Iustin Pop
106 4db3647e Iustin Pop
NIC_%N_BRIDGE
107 4db3647e Iustin Pop
    The bridge to which this NIC will be attached. This variable is
108 4db3647e Iustin Pop
    defined only when the NIC is in bridged mode.
109 4db3647e Iustin Pop
110 4db3647e Iustin Pop
NIC_%N_LINK
111 4db3647e Iustin Pop
    If the NIC is in bridged mode, this is the same as
112 4db3647e Iustin Pop
    ``NIC_%N_BRIDGE``.  If it is in routed mode, the routing table
113 4db3647e Iustin Pop
    which will be used by the hypervisor to insert the appropriate
114 4db3647e Iustin Pop
    routes.
115 4db3647e Iustin Pop
116 4db3647e Iustin Pop
NIC_%N_FRONTEND_TYPE
117 4db3647e Iustin Pop
    (Optional) If applicable, the type of the exported NIC to the
118 4db3647e Iustin Pop
    instance, this can be one of: ``rtl8139``, ``ne2k_pci``,
119 4db3647e Iustin Pop
    ``ne2k_isa``, ``paravirtual``.
120 4db3647e Iustin Pop
121 d1b1deb4 Iustin Pop
OSP_*name*
122 d1b1deb4 Iustin Pop
    Each OS parameter (see below) will be exported in its own
123 dfba45b1 Stephen Shirley
    variable, prefixed with ``OSP_``, and upper-cased. For example, a
124 d1b1deb4 Iustin Pop
    ``dhcp`` parameter will be exported as ``OSP_DHCP``.
125 d1b1deb4 Iustin Pop
126 4db3647e Iustin Pop
DEBUG_LEVEL
127 4db3647e Iustin Pop
    If non-zero, this should cause the OS script to generate verbose
128 4db3647e Iustin Pop
    logs of its execution, for troubleshooting purposes. Currently
129 4db3647e Iustin Pop
    only ``0`` and ``1`` are valid values.
130 4db3647e Iustin Pop
131 4db3647e Iustin Pop
132 d1b1deb4 Iustin Pop
EXECUTABLE SCRIPTS
133 d1b1deb4 Iustin Pop
------------------
134 d1b1deb4 Iustin Pop
135 d1b1deb4 Iustin Pop
136 4db3647e Iustin Pop
create
137 4db3647e Iustin Pop
~~~~~~
138 4db3647e Iustin Pop
139 4db3647e Iustin Pop
The **create** command is used for creating a new instance from
140 4db3647e Iustin Pop
scratch. It has no additional environment variables bside the
141 4db3647e Iustin Pop
common ones.
142 4db3647e Iustin Pop
143 4db3647e Iustin Pop
The ``INSTANCE_NAME`` variable denotes the name of the instance,
144 4db3647e Iustin Pop
which is guaranteed to resolve to an IP address. The create script
145 4db3647e Iustin Pop
should configure the instance according to this name. It can
146 4db3647e Iustin Pop
configure the IP statically or not, depending on the deployment
147 4db3647e Iustin Pop
environment.
148 4db3647e Iustin Pop
149 4db3647e Iustin Pop
The ``INSTANCE_REINSTALL`` variable is set to ``1`` when this create
150 dfba45b1 Stephen Shirley
request is reinstalling an existing instance, rather than creating
151 4db3647e Iustin Pop
one anew. This can be used, for example, to preserve some data in the
152 4db3647e Iustin Pop
old instance in an OS-specific way.
153 4db3647e Iustin Pop
154 4db3647e Iustin Pop
export
155 4db3647e Iustin Pop
~~~~~~
156 4db3647e Iustin Pop
157 4db3647e Iustin Pop
This command is used in order to make a backup of a given disk of
158 4db3647e Iustin Pop
the instance. The command should write to stdout a dump of the
159 4db3647e Iustin Pop
given block device. The output of this program will be passed
160 4db3647e Iustin Pop
during restore to the **import** command.
161 4db3647e Iustin Pop
162 4db3647e Iustin Pop
The specific disk to backup is denoted by two additional environment
163 4db3647e Iustin Pop
variables: ``EXPORT_INDEX`` which denotes the index in the instance
164 4db3647e Iustin Pop
disks structure (and could be used for example to skip the second disk
165 dfba45b1 Stephen Shirley
if not needed for backup) and ``EXPORT_DEVICE`` which has the same value
166 dfba45b1 Stephen Shirley
as ``DISK_N_PATH`` but is duplicated here for easier usage by shell
167 4db3647e Iustin Pop
scripts (rather than parse the ``DISK_...`` variables).
168 4db3647e Iustin Pop
169 4db3647e Iustin Pop
To provide the user with an estimate on how long the export will take,
170 4db3647e Iustin Pop
a predicted size can be written to the file descriptor passed in the
171 4db3647e Iustin Pop
variable ``EXP_SIZE_FD``. The value is in bytes and must be terminated
172 4db3647e Iustin Pop
by a newline character (``\n``). Older versions of Ganeti don't
173 4db3647e Iustin Pop
support this feature, hence the variable should be checked before
174 4db3647e Iustin Pop
use. Example::
175 4db3647e Iustin Pop
176 4db3647e Iustin Pop
    if test -n "$EXP_SIZE_FD"; then
177 4db3647e Iustin Pop
      blockdev --getsize64 $blockdev >&$EXP_SIZE_FD
178 4db3647e Iustin Pop
    fi
179 4db3647e Iustin Pop
180 4db3647e Iustin Pop
import
181 4db3647e Iustin Pop
~~~~~~
182 4db3647e Iustin Pop
183 4db3647e Iustin Pop
The **import** command is used for restoring an instance from a
184 4db3647e Iustin Pop
backup as done by **export**. The arguments are the similar to
185 4db3647e Iustin Pop
those passed to **export**, whose output will be provided on
186 4db3647e Iustin Pop
stdin.
187 4db3647e Iustin Pop
188 dfba45b1 Stephen Shirley
The difference in variables is that the current disk is denoted by
189 4db3647e Iustin Pop
``IMPORT_DEVICE`` and ``IMPORT_INDEX`` (instead of ``EXPORT_...``).
190 4db3647e Iustin Pop
191 4db3647e Iustin Pop
rename
192 4db3647e Iustin Pop
~~~~~~
193 4db3647e Iustin Pop
194 4db3647e Iustin Pop
This command is used in order to perform a rename at the instance
195 4db3647e Iustin Pop
OS level, after the instance has been renamed in Ganeti. The
196 4db3647e Iustin Pop
command should do whatever steps are required to ensure that the
197 4db3647e Iustin Pop
instance is updated to use the new name, if the operating system
198 4db3647e Iustin Pop
supports it.
199 4db3647e Iustin Pop
200 4db3647e Iustin Pop
Note that it is acceptable for the rename script to do nothing at
201 4db3647e Iustin Pop
all, however be warned that in this case, there will be a
202 4db3647e Iustin Pop
desynchronization between what gnt-instance list shows you and the
203 4db3647e Iustin Pop
actual hostname of the instance.
204 4db3647e Iustin Pop
205 4db3647e Iustin Pop
The script will be passed one additional environment variable
206 4db3647e Iustin Pop
called ``OLD_INSTANCE_NAME`` which holds the old instance name. The
207 4db3647e Iustin Pop
``INSTANCE_NAME`` variable holds the new instance name.
208 4db3647e Iustin Pop
209 4db3647e Iustin Pop
A very simple rename script should at least change the hostname and
210 4db3647e Iustin Pop
IP address of the instance, leaving the administrator to update the
211 4db3647e Iustin Pop
other services.
212 4db3647e Iustin Pop
213 d1b1deb4 Iustin Pop
verify
214 d1b1deb4 Iustin Pop
~~~~~~
215 d1b1deb4 Iustin Pop
216 d1b1deb4 Iustin Pop
The *verify* script is used to verify consistency of the OS parameters
217 d1b1deb4 Iustin Pop
(see below). The command should take one or more arguments denoting
218 d1b1deb4 Iustin Pop
what checks should be performed, and return a proper exit code
219 d1b1deb4 Iustin Pop
depending on whether the validation failed or succeeded.
220 d1b1deb4 Iustin Pop
221 d1b1deb4 Iustin Pop
Currently (API version 20), only one parameter is supported:
222 d1b1deb4 Iustin Pop
``parameters``. This should validate the ``OSP_`` variables from the
223 dfba45b1 Stephen Shirley
environment, and output diagnostic messages in case the validation
224 d1b1deb4 Iustin Pop
fails.
225 d1b1deb4 Iustin Pop
226 d1b1deb4 Iustin Pop
.. highlight:: sh
227 d1b1deb4 Iustin Pop
228 d1b1deb4 Iustin Pop
For the ``dhcp`` parameter given as example above, a verification
229 d1b1deb4 Iustin Pop
script could be::
230 d1b1deb4 Iustin Pop
231 d1b1deb4 Iustin Pop
    #!/bin/sh
232 d1b1deb4 Iustin Pop
233 d1b1deb4 Iustin Pop
    case $OSP_DHCP in
234 56a1d5cc Iustin Pop
      ""|yes|no)
235 56a1d5cc Iustin Pop
          ;;
236 56a1d5cc Iustin Pop
      *)
237 56a1d5cc Iustin Pop
        echo "Invalid value '$OSP_DHCP' for the dhcp parameter" 1>&2
238 56a1d5cc Iustin Pop
        exit 1;
239 56a1d5cc Iustin Pop
        ;;
240 d1b1deb4 Iustin Pop
    esac
241 d1b1deb4 Iustin Pop
242 d1b1deb4 Iustin Pop
    exit 0
243 d1b1deb4 Iustin Pop
244 d1b1deb4 Iustin Pop
245 d1b1deb4 Iustin Pop
TEXT FILES
246 d1b1deb4 Iustin Pop
----------
247 d1b1deb4 Iustin Pop
248 d1b1deb4 Iustin Pop
249 4db3647e Iustin Pop
ganeti_api_version
250 4db3647e Iustin Pop
~~~~~~~~~~~~~~~~~~
251 4db3647e Iustin Pop
252 4db3647e Iustin Pop
The ganeti_api_version file is a plain text file containing the
253 4db3647e Iustin Pop
version(s) of the guest OS API that this OS definition complies
254 dfba45b1 Stephen Shirley
with, one per line. The version documented by this man page is 20,
255 dfba45b1 Stephen Shirley
so this file must contain the number 20 followed by a newline if
256 4db3647e Iustin Pop
only this version is supported. A script compatible with more than
257 4db3647e Iustin Pop
one Ganeti version should contain the most recent version first
258 dfba45b1 Stephen Shirley
(i.e. 20), followed by the old version(s) (in this case 15 and/or
259 dfba45b1 Stephen Shirley
10).
260 4db3647e Iustin Pop
261 4db3647e Iustin Pop
variants.list
262 4db3647e Iustin Pop
~~~~~~~~~~~~~
263 4db3647e Iustin Pop
264 35007011 Iustin Pop
variants.list is a plain text file containing all the declared supported
265 35007011 Iustin Pop
variants for this OS, one per line. If this file is missing or empty,
266 35007011 Iustin Pop
then the OS won't be considered to support variants.
267 4db3647e Iustin Pop
268 d1b1deb4 Iustin Pop
parameters.list
269 d1b1deb4 Iustin Pop
~~~~~~~~~~~~~~~
270 d1b1deb4 Iustin Pop
271 d1b1deb4 Iustin Pop
This file declares the parameters supported by the OS, one parameter
272 d1b1deb4 Iustin Pop
per line, with name and description (space and/or tab separated). For
273 d1b1deb4 Iustin Pop
example::
274 d1b1deb4 Iustin Pop
275 d1b1deb4 Iustin Pop
    dhcp Whether to enable (yes) or disable (no) dhcp
276 d1b1deb4 Iustin Pop
    root_size The size of the root partition, in GiB
277 d1b1deb4 Iustin Pop
278 d1b1deb4 Iustin Pop
The parameters can then be used in instance add or modification, as
279 d1b1deb4 Iustin Pop
follows::
280 d1b1deb4 Iustin Pop
281 a53cd1f4 Iustin Pop
    # gnt-instance add -O dhcp=no,root_size=8 ...
282 d1b1deb4 Iustin Pop
283 d1b1deb4 Iustin Pop
284 4db3647e Iustin Pop
NOTES
285 4db3647e Iustin Pop
-----
286 4db3647e Iustin Pop
287 4db3647e Iustin Pop
Backwards compatibility
288 4db3647e Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~
289 4db3647e Iustin Pop
290 dfba45b1 Stephen Shirley
Ganeti 2.3 and up is compatible with API versions 10, 15 and 20. The OS
291 d1b1deb4 Iustin Pop
parameters and related scripts (verify) are only supported in
292 d1b1deb4 Iustin Pop
version 20. The variants functionality (variants.list, and OS_VARIANT
293 d1b1deb4 Iustin Pop
env. var) are supported/present only in version 15 and up.
294 4db3647e Iustin Pop
295 4db3647e Iustin Pop
Common behaviour
296 4db3647e Iustin Pop
~~~~~~~~~~~~~~~~
297 4db3647e Iustin Pop
298 4db3647e Iustin Pop
All the scripts should display an usage message when called with a
299 4db3647e Iustin Pop
wrong number of arguments or when the first argument is ``-h`` or
300 4db3647e Iustin Pop
``--help``.
301 4db3647e Iustin Pop
302 4db3647e Iustin Pop
Upgrading from old versions
303 4db3647e Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~
304 4db3647e Iustin Pop
305 d1b1deb4 Iustin Pop
Version 15 to 20
306 d1b1deb4 Iustin Pop
^^^^^^^^^^^^^^^^
307 d1b1deb4 Iustin Pop
308 d1b1deb4 Iustin Pop
The ``parameters.list`` file and ``verify`` script have been
309 d1b1deb4 Iustin Pop
added. For no parameters, an empty parameters file and an empty verify
310 d1b1deb4 Iustin Pop
script which returns success can be used.
311 d1b1deb4 Iustin Pop
312 4db3647e Iustin Pop
Version 10 to 15
313 4db3647e Iustin Pop
^^^^^^^^^^^^^^^^
314 4db3647e Iustin Pop
315 4db3647e Iustin Pop
The ``variants.list`` file has been added, so OSes should support at
316 4db3647e Iustin Pop
least one variant, declaring it in that file and must be prepared to
317 35007011 Iustin Pop
parse the OS_VARIANT environment variable. OSes are free to support more
318 35007011 Iustin Pop
variants than just the declared ones. Note that this file is optional;
319 35007011 Iustin Pop
without it, the variants functionality is disabled.
320 4db3647e Iustin Pop
321 4db3647e Iustin Pop
Version 5 to 10
322 4db3647e Iustin Pop
^^^^^^^^^^^^^^^
323 4db3647e Iustin Pop
324 4db3647e Iustin Pop
The method for passing data has changed from command line options
325 4db3647e Iustin Pop
to environment variables, so scripts should be modified to use
326 4db3647e Iustin Pop
these. For an example of how this can be done in a way compatible
327 4db3647e Iustin Pop
with both versions, feel free to look at the debootstrap instance's
328 4db3647e Iustin Pop
common.sh auxiliary script.
329 4db3647e Iustin Pop
330 4db3647e Iustin Pop
Also, instances can have now a variable number of disks, not only
331 4db3647e Iustin Pop
two, and a variable number of NICs (instead of fixed one), so the
332 4db3647e Iustin Pop
scripts should deal with this. The biggest change is in the
333 4db3647e Iustin Pop
import/export, which are called once per disk, instead of once per
334 4db3647e Iustin Pop
instance.
335 4db3647e Iustin Pop
336 4db3647e Iustin Pop
Version 4 to 5
337 4db3647e Iustin Pop
^^^^^^^^^^^^^^
338 4db3647e Iustin Pop
339 4db3647e Iustin Pop
The rename script has been added. If you don't want to do any
340 4db3647e Iustin Pop
changes on the instances after a rename, you can migrate the OS
341 4db3647e Iustin Pop
definition to version 5 by creating the rename script simply as::
342 4db3647e Iustin Pop
343 4db3647e Iustin Pop
    #!/bin/sh
344 4db3647e Iustin Pop
345 4db3647e Iustin Pop
    exit 0
346 4db3647e Iustin Pop
347 4db3647e Iustin Pop
Note that the script must be executable.
348 9ff4f2c0 Michael Hanselmann
349 9ff4f2c0 Michael Hanselmann
.. vim: set textwidth=72 :
350 9ff4f2c0 Michael Hanselmann
.. Local Variables:
351 9ff4f2c0 Michael Hanselmann
.. mode: rst
352 9ff4f2c0 Michael Hanselmann
.. fill-column: 72
353 9ff4f2c0 Michael Hanselmann
.. End: