Statistics
| Branch: | Tag: | Revision:

root / doc / hooks.rst @ 558fd122

History | View | Annotate | Download (15 kB)

1 4d6443f4 Iustin Pop
Ganeti customisation using hooks
2 4d6443f4 Iustin Pop
================================
3 4d6443f4 Iustin Pop
4 4d6443f4 Iustin Pop
Documents ganeti version 2.0
5 4d6443f4 Iustin Pop
6 4d6443f4 Iustin Pop
.. contents::
7 4d6443f4 Iustin Pop
8 4d6443f4 Iustin Pop
Introduction
9 4d6443f4 Iustin Pop
------------
10 4d6443f4 Iustin Pop
11 4d6443f4 Iustin Pop
12 4d6443f4 Iustin Pop
In order to allow customisation of operations, ganeti runs scripts
13 4d6443f4 Iustin Pop
under ``/etc/ganeti/hooks`` based on certain rules.
14 4d6443f4 Iustin Pop
15 4d6443f4 Iustin Pop
16 4d6443f4 Iustin Pop
This is similar to the ``/etc/network/`` structure present in Debian
17 4d6443f4 Iustin Pop
for network interface handling.
18 4d6443f4 Iustin Pop
19 4d6443f4 Iustin Pop
Organisation
20 4d6443f4 Iustin Pop
------------
21 4d6443f4 Iustin Pop
22 4d6443f4 Iustin Pop
For every operation, two sets of scripts are run:
23 4d6443f4 Iustin Pop
24 4d6443f4 Iustin Pop
- pre phase (for authorization/checking)
25 4d6443f4 Iustin Pop
- post phase (for logging)
26 4d6443f4 Iustin Pop
27 4d6443f4 Iustin Pop
Also, for each operation, the scripts are run on one or more nodes,
28 4d6443f4 Iustin Pop
depending on the operation type.
29 4d6443f4 Iustin Pop
30 4d6443f4 Iustin Pop
Note that, even though we call them scripts, we are actually talking
31 4d6443f4 Iustin Pop
about any executable.
32 4d6443f4 Iustin Pop
33 4d6443f4 Iustin Pop
*pre* scripts
34 4d6443f4 Iustin Pop
~~~~~~~~~~~~~
35 4d6443f4 Iustin Pop
36 4d6443f4 Iustin Pop
The *pre* scripts have a definite target: to check that the operation
37 4d6443f4 Iustin Pop
is allowed given the site-specific constraints. You could have, for
38 4d6443f4 Iustin Pop
example, a rule that says every new instance is required to exists in
39 4d6443f4 Iustin Pop
a database; to implement this, you could write a script that checks
40 4d6443f4 Iustin Pop
the new instance parameters against your database.
41 4d6443f4 Iustin Pop
42 4d6443f4 Iustin Pop
The objective of these scripts should be their return code (zero or
43 4d6443f4 Iustin Pop
non-zero for success and failure). However, if they modify the
44 4d6443f4 Iustin Pop
environment in any way, they should be idempotent, as failed
45 4d6443f4 Iustin Pop
executions could be restarted and thus the script(s) run again with
46 4d6443f4 Iustin Pop
exactly the same parameters.
47 4d6443f4 Iustin Pop
48 4d6443f4 Iustin Pop
Note that if a node is unreachable at the time a hooks is run, this
49 4d6443f4 Iustin Pop
will not be interpreted as a deny for the execution. In other words,
50 4d6443f4 Iustin Pop
only an actual error returned from a script will cause abort, and not
51 4d6443f4 Iustin Pop
an unreachable node.
52 4d6443f4 Iustin Pop
53 4d6443f4 Iustin Pop
Therefore, if you want to guarantee that a hook script is run and
54 4d6443f4 Iustin Pop
denies an action, it's best to put it on the master node.
55 4d6443f4 Iustin Pop
56 4d6443f4 Iustin Pop
*post* scripts
57 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~
58 4d6443f4 Iustin Pop
59 4d6443f4 Iustin Pop
These scripts should do whatever you need as a reaction to the
60 4d6443f4 Iustin Pop
completion of an operation. Their return code is not checked (but
61 4d6443f4 Iustin Pop
logged), and they should not depend on the fact that the *pre* scripts
62 4d6443f4 Iustin Pop
have been run.
63 4d6443f4 Iustin Pop
64 4d6443f4 Iustin Pop
Naming
65 4d6443f4 Iustin Pop
~~~~~~
66 4d6443f4 Iustin Pop
67 4d6443f4 Iustin Pop
The allowed names for the scripts consist of (similar to *run-parts* )
68 4d6443f4 Iustin Pop
upper and lower case, digits, underscores and hyphens. In other words,
69 4d6443f4 Iustin Pop
the regexp ``^[a-zA-Z0-9_-]+$``. Also, non-executable scripts will be
70 4d6443f4 Iustin Pop
ignored.
71 4d6443f4 Iustin Pop
72 4d6443f4 Iustin Pop
73 4d6443f4 Iustin Pop
Order of execution
74 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~~~~
75 4d6443f4 Iustin Pop
76 4d6443f4 Iustin Pop
On a single node, the scripts in a directory are run in lexicographic
77 4d6443f4 Iustin Pop
order (more exactly, the python string comparison order). It is
78 4d6443f4 Iustin Pop
advisable to implement the usual *NN-name* convention where *NN* is a
79 4d6443f4 Iustin Pop
two digit number.
80 4d6443f4 Iustin Pop
81 4d6443f4 Iustin Pop
For an operation whose hooks are run on multiple nodes, there is no
82 4d6443f4 Iustin Pop
specific ordering of nodes with regard to hooks execution; you should
83 4d6443f4 Iustin Pop
assume that the scripts are run in parallel on the target nodes
84 4d6443f4 Iustin Pop
(keeping on each node the above specified ordering).  If you need any
85 4d6443f4 Iustin Pop
kind of inter-node synchronisation, you have to implement it yourself
86 4d6443f4 Iustin Pop
in the scripts.
87 4d6443f4 Iustin Pop
88 4d6443f4 Iustin Pop
Execution environment
89 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~
90 4d6443f4 Iustin Pop
91 4d6443f4 Iustin Pop
The scripts will be run as follows:
92 4d6443f4 Iustin Pop
93 4d6443f4 Iustin Pop
- no command line arguments
94 4d6443f4 Iustin Pop
95 4d6443f4 Iustin Pop
- no controlling *tty*
96 4d6443f4 Iustin Pop
97 4d6443f4 Iustin Pop
- stdin is actually */dev/null*
98 4d6443f4 Iustin Pop
99 4d6443f4 Iustin Pop
- stdout and stderr are directed to files
100 4d6443f4 Iustin Pop
101 4d6443f4 Iustin Pop
- PATH is reset to ``/sbin:/bin:/usr/sbin:/usr/bin``
102 4d6443f4 Iustin Pop
103 4d6443f4 Iustin Pop
- the environment is cleared, and only ganeti-specific variables will
104 4d6443f4 Iustin Pop
  be left
105 4d6443f4 Iustin Pop
106 4d6443f4 Iustin Pop
107 5bbd3f7f Michael Hanselmann
All information about the cluster is passed using environment
108 4d6443f4 Iustin Pop
variables. Different operations will have sligthly different
109 4d6443f4 Iustin Pop
environments, but most of the variables are common.
110 4d6443f4 Iustin Pop
111 4d6443f4 Iustin Pop
Operation list
112 4d6443f4 Iustin Pop
--------------
113 4d6443f4 Iustin Pop
114 4d6443f4 Iustin Pop
Node operations
115 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~
116 4d6443f4 Iustin Pop
117 4d6443f4 Iustin Pop
OP_ADD_NODE
118 4d6443f4 Iustin Pop
+++++++++++
119 4d6443f4 Iustin Pop
120 4d6443f4 Iustin Pop
Adds a node to the cluster.
121 4d6443f4 Iustin Pop
122 4d6443f4 Iustin Pop
:directory: node-add
123 4d6443f4 Iustin Pop
:env. vars: NODE_NAME, NODE_PIP, NODE_SIP
124 4d6443f4 Iustin Pop
:pre-execution: all existing nodes
125 4d6443f4 Iustin Pop
:post-execution: all nodes plus the new node
126 4d6443f4 Iustin Pop
127 4d6443f4 Iustin Pop
128 4d6443f4 Iustin Pop
OP_REMOVE_NODE
129 4d6443f4 Iustin Pop
++++++++++++++
130 4d6443f4 Iustin Pop
131 cd46f3b4 Luca Bigliardi
Removes a node from the cluster. On the removed node the hooks are called
132 cd46f3b4 Luca Bigliardi
during the execution of the operation and not after its completion.
133 4d6443f4 Iustin Pop
134 4d6443f4 Iustin Pop
:directory: node-remove
135 4d6443f4 Iustin Pop
:env. vars: NODE_NAME
136 4d6443f4 Iustin Pop
:pre-execution: all existing nodes except the removed node
137 cd46f3b4 Luca Bigliardi
:post-execution: all existing nodes
138 4d6443f4 Iustin Pop
139 4d6443f4 Iustin Pop
OP_NODE_SET_PARAMS
140 4d6443f4 Iustin Pop
++++++++++++++++++
141 4d6443f4 Iustin Pop
142 4d6443f4 Iustin Pop
Changes a node's parameters.
143 4d6443f4 Iustin Pop
144 4d6443f4 Iustin Pop
:directory: node-modify
145 4d6443f4 Iustin Pop
:env. vars: MASTER_CANDIDATE, OFFLINE, DRAINED
146 4d6443f4 Iustin Pop
:pre-execution: master node, the target node
147 4d6443f4 Iustin Pop
:post-execution: master node, the target node
148 4d6443f4 Iustin Pop
149 7ffc5a86 Michael Hanselmann
OP_NODE_EVACUATE
150 7ffc5a86 Michael Hanselmann
++++++++++++++++
151 7ffc5a86 Michael Hanselmann
152 7ffc5a86 Michael Hanselmann
Relocate secondary instances from a node.
153 7ffc5a86 Michael Hanselmann
154 7ffc5a86 Michael Hanselmann
:directory: node-evacuate
155 7ffc5a86 Michael Hanselmann
:env. vars: NEW_SECONDARY, NODE_NAME
156 7ffc5a86 Michael Hanselmann
:pre-execution: master node, target node
157 7ffc5a86 Michael Hanselmann
:post-execution: master node, target node
158 7ffc5a86 Michael Hanselmann
159 6c6b7f8a Michael Hanselmann
OP_NODE_MIGRATE
160 6c6b7f8a Michael Hanselmann
++++++++++++++++
161 6c6b7f8a Michael Hanselmann
162 6c6b7f8a Michael Hanselmann
Relocate secondary instances from a node.
163 6c6b7f8a Michael Hanselmann
164 6c6b7f8a Michael Hanselmann
:directory: node-migrate
165 6c6b7f8a Michael Hanselmann
:env. vars: NODE_NAME
166 6c6b7f8a Michael Hanselmann
:pre-execution: master node
167 6c6b7f8a Michael Hanselmann
:post-execution: master node
168 6c6b7f8a Michael Hanselmann
169 4d6443f4 Iustin Pop
170 4d6443f4 Iustin Pop
Instance operations
171 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~~~~~
172 4d6443f4 Iustin Pop
173 4d6443f4 Iustin Pop
All instance operations take at least the following variables:
174 4d6443f4 Iustin Pop
INSTANCE_NAME, INSTANCE_PRIMARY, INSTANCE_SECONDARIES,
175 4d6443f4 Iustin Pop
INSTANCE_OS_TYPE, INSTANCE_DISK_TEMPLATE, INSTANCE_MEMORY,
176 4d6443f4 Iustin Pop
INSTANCE_DISK_SIZES, INSTANCE_VCPUS, INSTANCE_NIC_COUNT,
177 4d6443f4 Iustin Pop
INSTANCE_NICn_IP, INSTANCE_NICn_BRIDGE, INSTANCE_NICn_MAC,
178 4d6443f4 Iustin Pop
INSTANCE_DISK_COUNT, INSTANCE_DISKn_SIZE, INSTANCE_DISKn_MODE.
179 4d6443f4 Iustin Pop
180 4d6443f4 Iustin Pop
The INSTANCE_NICn_* and INSTANCE_DISKn_* variables represent the
181 4d6443f4 Iustin Pop
properties of the *n* -th NIC and disk, and are zero-indexed.
182 4d6443f4 Iustin Pop
183 4d6443f4 Iustin Pop
184 4d6443f4 Iustin Pop
OP_INSTANCE_ADD
185 4d6443f4 Iustin Pop
+++++++++++++++
186 4d6443f4 Iustin Pop
187 4d6443f4 Iustin Pop
Creates a new instance.
188 4d6443f4 Iustin Pop
189 4d6443f4 Iustin Pop
:directory: instance-add
190 4d6443f4 Iustin Pop
:env. vars: ADD_MODE, SRC_NODE, SRC_PATH, SRC_IMAGES
191 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
192 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
193 4d6443f4 Iustin Pop
194 4d6443f4 Iustin Pop
OP_INSTANCE_REINSTALL
195 4d6443f4 Iustin Pop
+++++++++++++++++++++
196 4d6443f4 Iustin Pop
197 4d6443f4 Iustin Pop
Reinstalls an instance.
198 4d6443f4 Iustin Pop
199 4d6443f4 Iustin Pop
:directory: instance-reinstall
200 4d6443f4 Iustin Pop
:env. vars: only the standard instance vars
201 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
202 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
203 4d6443f4 Iustin Pop
204 4d6443f4 Iustin Pop
OP_BACKUP_EXPORT
205 4d6443f4 Iustin Pop
++++++++++++++++
206 4d6443f4 Iustin Pop
207 4d6443f4 Iustin Pop
Exports the instance.
208 4d6443f4 Iustin Pop
209 4d6443f4 Iustin Pop
210 4d6443f4 Iustin Pop
:directory: instance-export
211 4d6443f4 Iustin Pop
:env. vars: EXPORT_NODE, EXPORT_DO_SHUTDOWN
212 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
213 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
214 4d6443f4 Iustin Pop
215 4d6443f4 Iustin Pop
OP_INSTANCE_START
216 4d6443f4 Iustin Pop
+++++++++++++++++
217 4d6443f4 Iustin Pop
218 4d6443f4 Iustin Pop
Starts an instance.
219 4d6443f4 Iustin Pop
220 4d6443f4 Iustin Pop
:directory: instance-start
221 4d6443f4 Iustin Pop
:env. vars: INSTANCE_NAME, INSTANCE_PRIMARY, INSTANCE_SECONDARIES, FORCE
222 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
223 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
224 4d6443f4 Iustin Pop
225 4d6443f4 Iustin Pop
OP_INSTANCE_SHUTDOWN
226 4d6443f4 Iustin Pop
++++++++++++++++++++
227 4d6443f4 Iustin Pop
228 4d6443f4 Iustin Pop
Stops an instance.
229 4d6443f4 Iustin Pop
230 6c6b7f8a Michael Hanselmann
:directory: instance-stop
231 4d6443f4 Iustin Pop
:env. vars: INSTANCE_NAME, INSTANCE_PRIMARY, INSTANCE_SECONDARIES
232 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
233 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
234 4d6443f4 Iustin Pop
235 4d6443f4 Iustin Pop
OP_INSTANCE_REBOOT
236 4d6443f4 Iustin Pop
++++++++++++++++++
237 4d6443f4 Iustin Pop
238 4d6443f4 Iustin Pop
Reboots an instance.
239 4d6443f4 Iustin Pop
240 4d6443f4 Iustin Pop
:directory: instance-reboot
241 4d6443f4 Iustin Pop
:env. vars: IGNORE_SECONDARIES, REBOOT_TYPE
242 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
243 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
244 4d6443f4 Iustin Pop
245 4d6443f4 Iustin Pop
OP_INSTANCE_MODIFY
246 4d6443f4 Iustin Pop
++++++++++++++++++
247 4d6443f4 Iustin Pop
248 4d6443f4 Iustin Pop
Modifies the instance parameters.
249 4d6443f4 Iustin Pop
250 4d6443f4 Iustin Pop
:directory: instance-modify
251 4d6443f4 Iustin Pop
:env. vars: INSTANCE_NAME, MEM_SIZE, VCPUS, INSTANCE_IP
252 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
253 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
254 4d6443f4 Iustin Pop
255 4d6443f4 Iustin Pop
OP_INSTANCE_FAILOVER
256 4d6443f4 Iustin Pop
++++++++++++++++++++
257 4d6443f4 Iustin Pop
258 4d6443f4 Iustin Pop
Failovers an instance.
259 4d6443f4 Iustin Pop
260 4d6443f4 Iustin Pop
:directory: instance-failover
261 4d6443f4 Iustin Pop
:env. vars: IGNORE_CONSISTENCY
262 4d6443f4 Iustin Pop
:pre-execution: master node, secondary node
263 4d6443f4 Iustin Pop
:post-execution: master node, secondary node
264 4d6443f4 Iustin Pop
265 4d6443f4 Iustin Pop
OP_INSTANCE_MIGRATE
266 4d6443f4 Iustin Pop
++++++++++++++++++++
267 4d6443f4 Iustin Pop
268 4d6443f4 Iustin Pop
Migrates an instance.
269 4d6443f4 Iustin Pop
270 6c6b7f8a Michael Hanselmann
:directory: instance-migrate
271 4d6443f4 Iustin Pop
:env. vars: INSTANCE_MIGRATE_LIVE, INSTANCE_MIGRATE_CLEANUP
272 4d6443f4 Iustin Pop
:pre-execution: master node, secondary node
273 4d6443f4 Iustin Pop
:post-execution: master node, secondary node
274 4d6443f4 Iustin Pop
275 4d6443f4 Iustin Pop
276 4d6443f4 Iustin Pop
OP_INSTANCE_REMOVE
277 4d6443f4 Iustin Pop
++++++++++++++++++
278 4d6443f4 Iustin Pop
279 4d6443f4 Iustin Pop
Remove an instance.
280 4d6443f4 Iustin Pop
281 4d6443f4 Iustin Pop
:directory: instance-remove
282 4d6443f4 Iustin Pop
:env. vars: INSTANCE_NAME, INSTANCE_PRIMARY, INSTANCE_SECONDARIES
283 4d6443f4 Iustin Pop
:pre-execution: master node
284 4d6443f4 Iustin Pop
:post-execution: master node
285 4d6443f4 Iustin Pop
286 4d6443f4 Iustin Pop
OP_INSTANCE_REPLACE_DISKS
287 4d6443f4 Iustin Pop
+++++++++++++++++++++++++
288 4d6443f4 Iustin Pop
289 4d6443f4 Iustin Pop
Replace an instance's disks.
290 4d6443f4 Iustin Pop
291 4d6443f4 Iustin Pop
:directory: mirror-replace
292 4d6443f4 Iustin Pop
:env. vars: MODE, NEW_SECONDARY, OLD_SECONDARY
293 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
294 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
295 4d6443f4 Iustin Pop
296 4d6443f4 Iustin Pop
OP_INSTANCE_GROW_DISK
297 4d6443f4 Iustin Pop
+++++++++++++++++++++
298 4d6443f4 Iustin Pop
299 4d6443f4 Iustin Pop
Grows the disk of an instance.
300 4d6443f4 Iustin Pop
301 4d6443f4 Iustin Pop
:directory: disk-grow
302 4d6443f4 Iustin Pop
:env. vars: DISK, AMOUNT
303 4d6443f4 Iustin Pop
:pre-execution: master node, primary node
304 4d6443f4 Iustin Pop
:post-execution: master node, primary node
305 4d6443f4 Iustin Pop
306 4d6443f4 Iustin Pop
OP_INSTANCE_RENAME
307 4d6443f4 Iustin Pop
++++++++++++++++++
308 4d6443f4 Iustin Pop
309 4d6443f4 Iustin Pop
Renames an instance.
310 4d6443f4 Iustin Pop
311 4d6443f4 Iustin Pop
:directory: instance-rename
312 4d6443f4 Iustin Pop
:env. vars: INSTANCE_NEW_NAME
313 4d6443f4 Iustin Pop
:pre-execution: master node, primary and secondary nodes
314 4d6443f4 Iustin Pop
:post-execution: master node, primary and secondary nodes
315 4d6443f4 Iustin Pop
316 6c6b7f8a Michael Hanselmann
OP_INSTANCE_MOVE
317 6c6b7f8a Michael Hanselmann
++++++++++++++++
318 6c6b7f8a Michael Hanselmann
319 6c6b7f8a Michael Hanselmann
Move an instance by data-copying.
320 6c6b7f8a Michael Hanselmann
321 6c6b7f8a Michael Hanselmann
:directory: instance-move
322 6c6b7f8a Michael Hanselmann
:env. vars: TARGET_NODE
323 6c6b7f8a Michael Hanselmann
:pre-execution: master node, primary and target nodes
324 6c6b7f8a Michael Hanselmann
:post-execution: master node, primary and target nodes
325 6c6b7f8a Michael Hanselmann
326 6c6b7f8a Michael Hanselmann
OP_INSTANCE_RECREATE_DISKS
327 6c6b7f8a Michael Hanselmann
++++++++++++++++++++++++++
328 6c6b7f8a Michael Hanselmann
329 6c6b7f8a Michael Hanselmann
Recreate an instance's missing disks.
330 6c6b7f8a Michael Hanselmann
331 6c6b7f8a Michael Hanselmann
:directory: instance-recreate-disks
332 6c6b7f8a Michael Hanselmann
:env. vars: only the standard instance vars
333 6c6b7f8a Michael Hanselmann
:pre-execution: master node, primary and secondary nodes
334 6c6b7f8a Michael Hanselmann
:post-execution: master node, primary and secondary nodes
335 6c6b7f8a Michael Hanselmann
336 6c6b7f8a Michael Hanselmann
OP_INSTANCE_REPLACE_DISKS
337 6c6b7f8a Michael Hanselmann
+++++++++++++++++++++++++
338 6c6b7f8a Michael Hanselmann
339 6c6b7f8a Michael Hanselmann
Replace the disks of an instance.
340 6c6b7f8a Michael Hanselmann
341 6c6b7f8a Michael Hanselmann
:directory: mirrors-replace
342 6c6b7f8a Michael Hanselmann
:env. vars: MODE, NEW_SECONDARY, OLD_SECONDARY
343 6c6b7f8a Michael Hanselmann
:pre-execution: master node, primary and new secondary nodes
344 6c6b7f8a Michael Hanselmann
:post-execution: master node, primary and new secondary nodes
345 6c6b7f8a Michael Hanselmann
346 6c6b7f8a Michael Hanselmann
347 4d6443f4 Iustin Pop
Cluster operations
348 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~~~~
349 4d6443f4 Iustin Pop
350 035a7783 Luca Bigliardi
OP_POST_INIT_CLUSTER
351 035a7783 Luca Bigliardi
++++++++++++++++++++
352 035a7783 Luca Bigliardi
353 035a7783 Luca Bigliardi
This hook is called via a special "empty" LU right after cluster initialization.
354 035a7783 Luca Bigliardi
355 035a7783 Luca Bigliardi
:directory: cluster-init
356 035a7783 Luca Bigliardi
:env. vars: none
357 035a7783 Luca Bigliardi
:pre-execution: none
358 035a7783 Luca Bigliardi
:post-execution: master node
359 035a7783 Luca Bigliardi
360 d87e1814 Luca Bigliardi
OP_DESTROY_CLUSTER
361 d87e1814 Luca Bigliardi
++++++++++++++++++
362 d87e1814 Luca Bigliardi
363 d87e1814 Luca Bigliardi
The post phase of this hook is called during the execution of destroy operation
364 d87e1814 Luca Bigliardi
and not after its completion.
365 d87e1814 Luca Bigliardi
366 d87e1814 Luca Bigliardi
:directory: cluster-destroy
367 d87e1814 Luca Bigliardi
:env. vars: none
368 d87e1814 Luca Bigliardi
:pre-execution: none
369 d87e1814 Luca Bigliardi
:post-execution: master node
370 d87e1814 Luca Bigliardi
371 4d6443f4 Iustin Pop
OP_CLUSTER_VERIFY
372 4d6443f4 Iustin Pop
+++++++++++++++++
373 4d6443f4 Iustin Pop
374 4d6443f4 Iustin Pop
Verifies the cluster status. This is a special LU with regard to
375 4d6443f4 Iustin Pop
hooks, as the result of the opcode will be combined with the result of
376 4d6443f4 Iustin Pop
post-execution hooks, in order to allow administrators to enhance the
377 4d6443f4 Iustin Pop
cluster verification procedure.
378 4d6443f4 Iustin Pop
379 4d6443f4 Iustin Pop
:directory: cluster-verify
380 35e994e9 Iustin Pop
:env. vars: CLUSTER, MASTER, CLUSTER_TAGS, NODE_TAGS_<name>
381 4d6443f4 Iustin Pop
:pre-execution: none
382 4d6443f4 Iustin Pop
:post-execution: all nodes
383 4d6443f4 Iustin Pop
384 4d6443f4 Iustin Pop
OP_CLUSTER_RENAME
385 4d6443f4 Iustin Pop
+++++++++++++++++
386 4d6443f4 Iustin Pop
387 4d6443f4 Iustin Pop
Renames the cluster.
388 4d6443f4 Iustin Pop
389 4d6443f4 Iustin Pop
:directory: cluster-rename
390 4d6443f4 Iustin Pop
:env. vars: NEW_NAME
391 4d6443f4 Iustin Pop
:pre-execution: master-node
392 4d6443f4 Iustin Pop
:post-execution: master-node
393 4d6443f4 Iustin Pop
394 4d6443f4 Iustin Pop
OP_CLUSTER_SET_PARAMS
395 4d6443f4 Iustin Pop
+++++++++++++++++++++
396 4d6443f4 Iustin Pop
397 4d6443f4 Iustin Pop
Modifies the cluster parameters.
398 4d6443f4 Iustin Pop
399 4d6443f4 Iustin Pop
:directory: cluster-modify
400 4d6443f4 Iustin Pop
:env. vars: NEW_VG_NAME
401 4d6443f4 Iustin Pop
:pre-execution: master node
402 4d6443f4 Iustin Pop
:post-execution: master node
403 4d6443f4 Iustin Pop
404 4d6443f4 Iustin Pop
405 4d6443f4 Iustin Pop
Obsolete operations
406 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~~~~~
407 4d6443f4 Iustin Pop
408 4d6443f4 Iustin Pop
The following operations are no longer present or don't execute hooks
409 4d6443f4 Iustin Pop
anymore in Ganeti 2.0:
410 4d6443f4 Iustin Pop
411 4d6443f4 Iustin Pop
- OP_INIT_CLUSTER
412 4d6443f4 Iustin Pop
- OP_MASTER_FAILOVER
413 4d6443f4 Iustin Pop
- OP_INSTANCE_ADD_MDDRBD
414 4d6443f4 Iustin Pop
- OP_INSTANCE_REMOVE_MDDRBD
415 4d6443f4 Iustin Pop
416 4d6443f4 Iustin Pop
417 4d6443f4 Iustin Pop
Environment variables
418 4d6443f4 Iustin Pop
---------------------
419 4d6443f4 Iustin Pop
420 4d6443f4 Iustin Pop
Note that all variables listed here are actually prefixed with
421 4d6443f4 Iustin Pop
*GANETI_* in order to provide a clear namespace.
422 4d6443f4 Iustin Pop
423 4d6443f4 Iustin Pop
Common variables
424 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~~
425 4d6443f4 Iustin Pop
426 4d6443f4 Iustin Pop
This is the list of environment variables supported by all operations:
427 4d6443f4 Iustin Pop
428 4d6443f4 Iustin Pop
HOOKS_VERSION
429 4d6443f4 Iustin Pop
  Documents the hooks interface version. In case this doesnt match
430 4d6443f4 Iustin Pop
  what the script expects, it should not run. The documents conforms
431 4d6443f4 Iustin Pop
  to the version 2.
432 4d6443f4 Iustin Pop
433 4d6443f4 Iustin Pop
HOOKS_PHASE
434 4d6443f4 Iustin Pop
  One of *PRE* or *POST* denoting which phase are we in.
435 4d6443f4 Iustin Pop
436 4d6443f4 Iustin Pop
CLUSTER
437 4d6443f4 Iustin Pop
  The cluster name.
438 4d6443f4 Iustin Pop
439 4d6443f4 Iustin Pop
MASTER
440 4d6443f4 Iustin Pop
  The master node.
441 4d6443f4 Iustin Pop
442 4d6443f4 Iustin Pop
OP_CODE
443 4d6443f4 Iustin Pop
  One of the *OP_* values from the list of operations.
444 4d6443f4 Iustin Pop
445 4d6443f4 Iustin Pop
OBJECT_TYPE
446 4d6443f4 Iustin Pop
  One of ``INSTANCE``, ``NODE``, ``CLUSTER``.
447 4d6443f4 Iustin Pop
448 4d6443f4 Iustin Pop
DATA_DIR
449 4d6443f4 Iustin Pop
  The path to the Ganeti configuration directory (to read, for
450 4d6443f4 Iustin Pop
  example, the *ssconf* files).
451 4d6443f4 Iustin Pop
452 4d6443f4 Iustin Pop
453 4d6443f4 Iustin Pop
Specialised variables
454 4d6443f4 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~
455 4d6443f4 Iustin Pop
456 4d6443f4 Iustin Pop
This is the list of variables which are specific to one or more
457 4d6443f4 Iustin Pop
operations.
458 4d6443f4 Iustin Pop
459 4d6443f4 Iustin Pop
INSTANCE_NAME
460 4d6443f4 Iustin Pop
  The name of the instance which is the target of the operation.
461 4d6443f4 Iustin Pop
462 4d6443f4 Iustin Pop
INSTANCE_DISK_TEMPLATE
463 4d6443f4 Iustin Pop
  The disk type for the instance.
464 4d6443f4 Iustin Pop
465 4d6443f4 Iustin Pop
INSTANCE_DISK_COUNT
466 4d6443f4 Iustin Pop
  The number of disks for the instance.
467 4d6443f4 Iustin Pop
468 4d6443f4 Iustin Pop
INSTANCE_DISKn_SIZE
469 4d6443f4 Iustin Pop
  The size of disk *n* for the instance.
470 4d6443f4 Iustin Pop
471 4d6443f4 Iustin Pop
INSTANCE_DISKn_MODE
472 4d6443f4 Iustin Pop
  Either *rw* for a read-write disk or *ro* for a read-only one.
473 4d6443f4 Iustin Pop
474 4d6443f4 Iustin Pop
INSTANCE_NIC_COUNT
475 4d6443f4 Iustin Pop
  The number of NICs for the instance.
476 4d6443f4 Iustin Pop
477 4d6443f4 Iustin Pop
INSTANCE_NICn_BRIDGE
478 4d6443f4 Iustin Pop
  The bridge to which the *n* -th NIC of the instance is attached.
479 4d6443f4 Iustin Pop
480 4d6443f4 Iustin Pop
INSTANCE_NICn_IP
481 4d6443f4 Iustin Pop
  The IP (if any) of the *n* -th NIC of the instance.
482 4d6443f4 Iustin Pop
483 4d6443f4 Iustin Pop
INSTANCE_NICn_MAC
484 4d6443f4 Iustin Pop
  The MAC address of the *n* -th NIC of the instance.
485 4d6443f4 Iustin Pop
486 4d6443f4 Iustin Pop
INSTANCE_OS_TYPE
487 4d6443f4 Iustin Pop
  The name of the instance OS.
488 4d6443f4 Iustin Pop
489 4d6443f4 Iustin Pop
INSTANCE_PRIMARY
490 4d6443f4 Iustin Pop
  The name of the node which is the primary for the instance.
491 4d6443f4 Iustin Pop
492 4d6443f4 Iustin Pop
INSTANCE_SECONDARIES
493 4d6443f4 Iustin Pop
  Space-separated list of secondary nodes for the instance.
494 4d6443f4 Iustin Pop
495 4d6443f4 Iustin Pop
INSTANCE_MEMORY
496 4d6443f4 Iustin Pop
  The memory size (in MiBs) of the instance.
497 4d6443f4 Iustin Pop
498 4d6443f4 Iustin Pop
INSTANCE_VCPUS
499 4d6443f4 Iustin Pop
  The number of virtual CPUs for the instance.
500 4d6443f4 Iustin Pop
501 4d6443f4 Iustin Pop
INSTANCE_STATUS
502 4d6443f4 Iustin Pop
  The run status of the instance.
503 4d6443f4 Iustin Pop
504 4d6443f4 Iustin Pop
NODE_NAME
505 4d6443f4 Iustin Pop
  The target node of this operation (not the node on which the hook
506 4d6443f4 Iustin Pop
  runs).
507 4d6443f4 Iustin Pop
508 4d6443f4 Iustin Pop
NODE_PIP
509 4d6443f4 Iustin Pop
  The primary IP of the target node (the one over which inter-node
510 4d6443f4 Iustin Pop
  communication is done).
511 4d6443f4 Iustin Pop
512 4d6443f4 Iustin Pop
NODE_SIP
513 4d6443f4 Iustin Pop
  The secondary IP of the target node (the one over which drbd
514 4d6443f4 Iustin Pop
  replication is done). This can be equal to the primary ip, in case
515 4d6443f4 Iustin Pop
  the cluster is not dual-homed.
516 4d6443f4 Iustin Pop
517 4d6443f4 Iustin Pop
FORCE
518 4d6443f4 Iustin Pop
  This is provided by some operations when the user gave this flag.
519 4d6443f4 Iustin Pop
520 4d6443f4 Iustin Pop
IGNORE_CONSISTENCY
521 4d6443f4 Iustin Pop
  The user has specified this flag. It is used when failing over
522 4d6443f4 Iustin Pop
  instances in case the primary node is down.
523 4d6443f4 Iustin Pop
524 4d6443f4 Iustin Pop
ADD_MODE
525 4d6443f4 Iustin Pop
  The mode of the instance create: either *create* for create from
526 4d6443f4 Iustin Pop
  scratch or *import* for restoring from an exported image.
527 4d6443f4 Iustin Pop
528 4d6443f4 Iustin Pop
SRC_NODE, SRC_PATH, SRC_IMAGE
529 4d6443f4 Iustin Pop
  In case the instance has been added by import, these variables are
530 4d6443f4 Iustin Pop
  defined and point to the source node, source path (the directory
531 4d6443f4 Iustin Pop
  containing the image and the config file) and the source disk image
532 4d6443f4 Iustin Pop
  file.
533 4d6443f4 Iustin Pop
534 4d6443f4 Iustin Pop
NEW_SECONDARY
535 4d6443f4 Iustin Pop
  The name of the node on which the new mirror component is being
536 4d6443f4 Iustin Pop
  added. This can be the name of the current secondary, if the new
537 4d6443f4 Iustin Pop
  mirror is on the same secondary.
538 4d6443f4 Iustin Pop
539 4d6443f4 Iustin Pop
OLD_SECONDARY
540 4d6443f4 Iustin Pop
  The name of the old secondary in the replace-disks command Note that
541 4d6443f4 Iustin Pop
  this can be equal to the new secondary if the secondary node hasn't
542 4d6443f4 Iustin Pop
  actually changed.
543 4d6443f4 Iustin Pop
544 4d6443f4 Iustin Pop
EXPORT_NODE
545 4d6443f4 Iustin Pop
  The node on which the exported image of the instance was done.
546 4d6443f4 Iustin Pop
547 4d6443f4 Iustin Pop
EXPORT_DO_SHUTDOWN
548 4d6443f4 Iustin Pop
  This variable tells if the instance has been shutdown or not while
549 4d6443f4 Iustin Pop
  doing the export. In the "was shutdown" case, it's likely that the
550 4d6443f4 Iustin Pop
  filesystem is consistent, whereas in the "did not shutdown" case,
551 4d6443f4 Iustin Pop
  the filesystem would need a check (journal replay or full fsck) in
552 4d6443f4 Iustin Pop
  order to guarantee consistency.
553 4d6443f4 Iustin Pop
554 35e994e9 Iustin Pop
CLUSTER_TAGS
555 35e994e9 Iustin Pop
  The list of cluster tags, space separated.
556 35e994e9 Iustin Pop
557 35e994e9 Iustin Pop
NODE_TAGS_<name>
558 35e994e9 Iustin Pop
  The list of tags for node *<name>*, space separated.
559 35e994e9 Iustin Pop
560 4d6443f4 Iustin Pop
Examples
561 4d6443f4 Iustin Pop
--------
562 4d6443f4 Iustin Pop
563 4d6443f4 Iustin Pop
The startup of an instance will pass this environment to the hook
564 4d6443f4 Iustin Pop
script::
565 4d6443f4 Iustin Pop
566 4d6443f4 Iustin Pop
  GANETI_CLUSTER=cluster1.example.com
567 4d6443f4 Iustin Pop
  GANETI_DATA_DIR=/var/lib/ganeti
568 4d6443f4 Iustin Pop
  GANETI_FORCE=False
569 4d6443f4 Iustin Pop
  GANETI_HOOKS_PATH=instance-start
570 4d6443f4 Iustin Pop
  GANETI_HOOKS_PHASE=post
571 4d6443f4 Iustin Pop
  GANETI_HOOKS_VERSION=2
572 4d6443f4 Iustin Pop
  GANETI_INSTANCE_DISK0_MODE=rw
573 4d6443f4 Iustin Pop
  GANETI_INSTANCE_DISK0_SIZE=128
574 4d6443f4 Iustin Pop
  GANETI_INSTANCE_DISK_COUNT=1
575 4d6443f4 Iustin Pop
  GANETI_INSTANCE_DISK_TEMPLATE=drbd
576 4d6443f4 Iustin Pop
  GANETI_INSTANCE_MEMORY=128
577 4d6443f4 Iustin Pop
  GANETI_INSTANCE_NAME=instance2.example.com
578 4d6443f4 Iustin Pop
  GANETI_INSTANCE_NIC0_BRIDGE=xen-br0
579 4d6443f4 Iustin Pop
  GANETI_INSTANCE_NIC0_IP=
580 4d6443f4 Iustin Pop
  GANETI_INSTANCE_NIC0_MAC=aa:00:00:a5:91:58
581 4d6443f4 Iustin Pop
  GANETI_INSTANCE_NIC_COUNT=1
582 4d6443f4 Iustin Pop
  GANETI_INSTANCE_OS_TYPE=debootstrap
583 4d6443f4 Iustin Pop
  GANETI_INSTANCE_PRIMARY=node3.example.com
584 4d6443f4 Iustin Pop
  GANETI_INSTANCE_SECONDARIES=node5.example.com
585 4d6443f4 Iustin Pop
  GANETI_INSTANCE_STATUS=down
586 4d6443f4 Iustin Pop
  GANETI_INSTANCE_VCPUS=1
587 4d6443f4 Iustin Pop
  GANETI_MASTER=node1.example.com
588 4d6443f4 Iustin Pop
  GANETI_OBJECT_TYPE=INSTANCE
589 4d6443f4 Iustin Pop
  GANETI_OP_CODE=OP_INSTANCE_STARTUP
590 4d6443f4 Iustin Pop
  GANETI_OP_TARGET=instance2.example.com
591 558fd122 Michael Hanselmann
592 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :