Ganeti customisation using hooks
================================
-Documents ganeti version 2.0
+Documents Ganeti version 2.5
.. contents::
Naming
~~~~~~
-The allowed names for the scripts consist of (similar to *run-parts* )
+The allowed names for the scripts consist of (similar to *run-parts*)
upper and lower case, digits, underscores and hyphens. In other words,
the regexp ``^[a-zA-Z0-9_-]+$``. Also, non-executable scripts will be
ignored.
- stdout and stderr are directed to files
-- PATH is reset to ``/sbin:/bin:/usr/sbin:/usr/bin``
+- PATH is reset to :pyeval:`constants.HOOKS_PATH`
- the environment is cleared, and only ganeti-specific variables will
be left
Node operations
~~~~~~~~~~~~~~~
-OP_ADD_NODE
+OP_NODE_ADD
+++++++++++
Adds a node to the cluster.
:post-execution: all nodes plus the new node
-OP_REMOVE_NODE
+OP_NODE_REMOVE
++++++++++++++
Removes a node from the cluster. On the removed node the hooks are
Node group operations
~~~~~~~~~~~~~~~~~~~~~
-OP_ADD_GROUP
+OP_GROUP_ADD
++++++++++++
Adds a node group to the cluster.
:pre-execution: master node
:post-execution: master node
-OP_REMOVE_GROUP
+OP_GROUP_REMOVE
+++++++++++++++
Removes a node group from the cluster. Since the node group must be
:pre-execution: master node
:post-execution: master node
-OP_RENAME_GROUP
+OP_GROUP_RENAME
+++++++++++++++
Renames a node group.
:pre-execution: master node and all nodes in the group
:post-execution: master node and all nodes in the group
+OP_GROUP_EVACUATE
++++++++++++++++++
+
+Evacuates a node group.
+
+:directory: group-evacuate
+:env. vars: GROUP_NAME, TARGET_GROUPS
+:pre-execution: master node and all nodes in the group
+:post-execution: master node and all nodes in the group
+
Instance operations
~~~~~~~~~~~~~~~~~~~
properties of the *n* -th NIC and disk, and are zero-indexed.
-OP_INSTANCE_ADD
-+++++++++++++++
+OP_INSTANCE_CREATE
+++++++++++++++++++
Creates a new instance.
:post-execution: master node, primary and secondary nodes
OP_INSTANCE_STARTUP
-+++++++++++++++++
++++++++++++++++++++
Starts an instance.
:post-execution: master node, primary and secondary nodes
OP_INSTANCE_SET_PARAMS
-++++++++++++++++++
+++++++++++++++++++++++
Modifies the instance parameters.
:directory: instance-modify
-:env. vars: NEW_DISK_TEMPLATE
+:env. vars: NEW_DISK_TEMPLATE, RUNTIME_MEMORY
:pre-execution: master node, primary and secondary nodes
:post-execution: master node, primary and secondary nodes
:pre-execution: master node, primary and new secondary nodes
:post-execution: master node, primary and new secondary nodes
+OP_INSTANCE_CHANGE_GROUP
+++++++++++++++++++++++++
+
+Moves an instance to another group.
+
+:directory: instance-change-group
+:env. vars: TARGET_GROUPS
+:pre-execution: master node
+:post-execution: master node
+
Cluster operations
~~~~~~~~~~~~~~~~~~
-OP_POST_INIT_CLUSTER
+OP_CLUSTER_POST_INIT
++++++++++++++++++++
This hook is called via a special "empty" LU right after cluster
:pre-execution: none
:post-execution: master node
-OP_DESTROY_CLUSTER
+OP_CLUSTER_DESTROY
++++++++++++++++++
The post phase of this hook is called during the execution of destroy
:pre-execution: none
:post-execution: master node
-OP_CLUSTER_VERIFY
-+++++++++++++++++
+OP_CLUSTER_VERIFY_GROUP
++++++++++++++++++++++++
-Verifies the cluster status. This is a special LU with regard to
+Verifies all nodes in a group. This is a special LU with regard to
hooks, as the result of the opcode will be combined with the result of
post-execution hooks, in order to allow administrators to enhance the
cluster verification procedure.
:directory: cluster-verify
:env. vars: CLUSTER, MASTER, CLUSTER_TAGS, NODE_TAGS_<name>
:pre-execution: none
-:post-execution: all nodes
+:post-execution: all nodes in a group
OP_CLUSTER_RENAME
+++++++++++++++++
:pre-execution: master node
:post-execution: master node
+:pyeval:`constants.FAKE_OP_MASTER_TURNUP`
++++++++++++++++++++++++++++++++++++++++++
+
+Called when the master IP is activated.
+
+:directory: master-ip-turnup
+:env. vars: MASTER_NETDEV, MASTER_IP, MASTER_NETMASK, CLUSTER_IP_VERSION
+:pre-execution: master node
+:post-execution: master node
+
+:pyeval:`constants.FAKE_OP_MASTER_TURNDOWN`
++++++++++++++++++++++++++++++++++++++++++++
+
+Called when the master IP is deactivated.
+
+:directory: master-ip-turndown
+:env. vars: MASTER_NETDEV, MASTER_IP, MASTER_NETMASK, CLUSTER_IP_VERSION
+:pre-execution: master node
+:post-execution: master node
+
Obsolete operations
~~~~~~~~~~~~~~~~~~~
Environment variables
---------------------
-Note that all variables listed here are actually prefixed with
-*GANETI_* in order to provide a clear namespace.
+Note that all variables listed here are actually prefixed with *GANETI_*
+in order to provide a clear namespace. In addition, post-execution
+scripts receive another set of variables, prefixed with *GANETI_POST_*,
+representing the status after the opcode executed.
Common variables
~~~~~~~~~~~~~~~~
This is the list of variables which are specific to one or more
operations.
+CLUSTER_IP_VERSION
+ IP version of the master IP (4 or 6)
+
INSTANCE_NAME
The name of the instance which is the target of the operation.
VM_CAPABLE
Whether the node can host instances.
+MASTER_NETDEV
+ Network device of the master IP
+
+MASTER_IP
+ The master IP
+
+MASTER_NETMASK
+ Netmask of the master IP
+
+INSTANCE_TAGS
+ A space-delimited list of the instance's tags.
+
NODE_NAME
The target node of this operation (not the node on which the hook
runs).