Move hooks PATH environment variable to constants
[ganeti-local] / doc / hooks.rst
index 282ed93..3cf8bc7 100644 (file)
@@ -1,7 +1,7 @@
 Ganeti customisation using hooks
 ================================
 
-Documents ganeti version 2.0
+Documents Ganeti version 2.5
 
 .. contents::
 
@@ -64,7 +64,7 @@ have been run.
 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.
@@ -98,7 +98,7 @@ The scripts will be run as follows:
 
 - 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
@@ -114,18 +114,18 @@ Operation list
 Node operations
 ~~~~~~~~~~~~~~~
 
-OP_ADD_NODE
+OP_NODE_ADD
 +++++++++++
 
 Adds a node to the cluster.
 
 :directory: node-add
-:env. vars: NODE_NAME, NODE_PIP, NODE_SIP
+:env. vars: NODE_NAME, NODE_PIP, NODE_SIP, MASTER_CAPABLE, VM_CAPABLE
 :pre-execution: all existing nodes
 :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
@@ -143,7 +143,7 @@ OP_NODE_SET_PARAMS
 Changes a node's parameters.
 
 :directory: node-modify
-:env. vars: MASTER_CANDIDATE, OFFLINE, DRAINED
+:env. vars: MASTER_CANDIDATE, OFFLINE, DRAINED, MASTER_CAPABLE, VM_CAPABLE
 :pre-execution: master node, the target node
 :post-execution: master node, the target node
 
@@ -171,7 +171,7 @@ Relocate secondary instances from a node.
 Node group operations
 ~~~~~~~~~~~~~~~~~~~~~
 
-OP_ADD_GROUP
+OP_GROUP_ADD
 ++++++++++++
 
 Adds a node group to the cluster.
@@ -181,7 +181,17 @@ Adds a node group to the cluster.
 :pre-execution: master node
 :post-execution: master node
 
-OP_REMOVE_GROUP
+OP_GROUP_SET_PARAMS
++++++++++++++++++++
+
+Changes a node group's parameters.
+
+:directory: group-modify
+:env. vars: GROUP_NAME, NEW_ALLOC_POLICY
+:pre-execution: master node
+:post-execution: master node
+
+OP_GROUP_REMOVE
 +++++++++++++++
 
 Removes a node group from the cluster. Since the node group must be
@@ -193,7 +203,7 @@ not exist, and the hook is only executed in the master node.
 :pre-execution: master node
 :post-execution: master node
 
-OP_RENAME_GROUP
+OP_GROUP_RENAME
 +++++++++++++++
 
 Renames a node group.
@@ -203,12 +213,22 @@ 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
 ~~~~~~~~~~~~~~~~~~~
 
 All instance operations take at least the following variables:
-INSTANCE_NAME, INSTANCE_PRIMARY, INSTANCE_SECONDARIES,
+INSTANCE_NAME, INSTANCE_PRIMARY, INSTANCE_SECONDARY,
 INSTANCE_OS_TYPE, INSTANCE_DISK_TEMPLATE, INSTANCE_MEMORY,
 INSTANCE_DISK_SIZES, INSTANCE_VCPUS, INSTANCE_NIC_COUNT,
 INSTANCE_NICn_IP, INSTANCE_NICn_BRIDGE, INSTANCE_NICn_MAC,
@@ -218,8 +238,8 @@ The INSTANCE_NICn_* and INSTANCE_DISKn_* variables represent the
 properties of the *n* -th NIC and disk, and are zero-indexed.
 
 
-OP_INSTANCE_ADD
-+++++++++++++++
+OP_INSTANCE_CREATE
+++++++++++++++++++
 
 Creates a new instance.
 
@@ -244,12 +264,12 @@ OP_BACKUP_EXPORT
 Exports the instance.
 
 :directory: instance-export
-:env. vars: EXPORT_NODE, EXPORT_DO_SHUTDOWN
+:env. vars: EXPORT_MODE, EXPORT_NODE, EXPORT_DO_SHUTDOWN, REMOVE_INSTANCE
 :pre-execution: master node, primary and secondary nodes
 :post-execution: master node, primary and secondary nodes
 
-OP_INSTANCE_START
-+++++++++++++++++
+OP_INSTANCE_STARTUP
++++++++++++++++++++
 
 Starts an instance.
 
@@ -264,7 +284,7 @@ OP_INSTANCE_SHUTDOWN
 Stops an instance.
 
 :directory: instance-stop
-:env. vars: only the standard instance vars
+:env. vars: TIMEOUT
 :pre-execution: master node, primary and secondary nodes
 :post-execution: master node, primary and secondary nodes
 
@@ -274,17 +294,17 @@ OP_INSTANCE_REBOOT
 Reboots an instance.
 
 :directory: instance-reboot
-:env. vars: IGNORE_SECONDARIES, REBOOT_TYPE
+:env. vars: IGNORE_SECONDARIES, REBOOT_TYPE, SHUTDOWN_TIMEOUT
 :pre-execution: master node, primary and secondary nodes
 :post-execution: master node, primary and secondary nodes
 
-OP_INSTANCE_MODIFY
-++++++++++++++++++
+OP_INSTANCE_SET_PARAMS
+++++++++++++++++++++++
 
 Modifies the instance parameters.
 
 :directory: instance-modify
-:env. vars: only the standard instance vars
+:env. vars: NEW_DISK_TEMPLATE
 :pre-execution: master node, primary and secondary nodes
 :post-execution: master node, primary and secondary nodes
 
@@ -292,11 +312,11 @@ OP_INSTANCE_FAILOVER
 ++++++++++++++++++++
 
 Failovers an instance. In the post phase INSTANCE_PRIMARY and
-INSTANCE_SECONDARIES refer to the nodes that were repectively primary
+INSTANCE_SECONDARY refer to the nodes that were repectively primary
 and secondary before failover.
 
 :directory: instance-failover
-:env. vars: IGNORE_CONSISTENCY, OLD_SECONDARY, OLD_PRIMARY, NEW_SECONDARY, NEW_PRIMARY
+:env. vars: IGNORE_CONSISTENCY, SHUTDOWN_TIMEOUT, OLD_PRIMARY, OLD_SECONDARY, NEW_PRIMARY, NEW_SECONDARY
 :pre-execution: master node, secondary node
 :post-execution: master node, primary and secondary nodes
 
@@ -304,11 +324,11 @@ OP_INSTANCE_MIGRATE
 ++++++++++++++++++++
 
 Migrates an instance. In the post phase INSTANCE_PRIMARY and
-INSTANCE_SECONDARIES refer to the nodes that were repectively primary
+INSTANCE_SECONDARY refer to the nodes that were repectively primary
 and secondary before migration.
 
 :directory: instance-migrate
-:env. vars: MIGRATE_LIVE, MIGRATE_CLEANUP, OLD_SECONDARY, OLD_PRIMARY, NEW_SECONDARY, NEW_PRIMARY
+:env. vars: MIGRATE_LIVE, MIGRATE_CLEANUP, OLD_PRIMARY, OLD_SECONDARY, NEW_PRIMARY, NEW_SECONDARY
 :pre-execution: master node, secondary node
 :post-execution: master node, primary and secondary nodes
 
@@ -319,7 +339,7 @@ OP_INSTANCE_REMOVE
 Remove an instance.
 
 :directory: instance-remove
-:env. vars: only the standard instance vars
+:env. vars: SHUTDOWN_TIMEOUT
 :pre-execution: master node
 :post-execution: master node, primary and secondary nodes
 
@@ -359,7 +379,7 @@ OP_INSTANCE_MOVE
 Move an instance by data-copying.
 
 :directory: instance-move
-:env. vars: TARGET_NODE
+:env. vars: TARGET_NODE, SHUTDOWN_TIMEOUT
 :pre-execution: master node, primary and target nodes
 :post-execution: master node, primary and target nodes
 
@@ -383,11 +403,21 @@ Replace the disks of an instance.
 :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
@@ -398,7 +428,7 @@ initialization.
 :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
@@ -409,10 +439,10 @@ operation and not after its completion.
 :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.
@@ -420,7 +450,7 @@ 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
 +++++++++++++++++
@@ -458,8 +488,10 @@ anymore in Ganeti 2.0:
 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
 ~~~~~~~~~~~~~~~~
@@ -500,9 +532,15 @@ operations.
 INSTANCE_NAME
   The name of the instance which is the target of the operation.
 
+INSTANCE_BE_x,y,z,...
+  Instance BE params. There is one variable per BE param. For instance, GANETI_INSTANCE_BE_auto_balance
+
 INSTANCE_DISK_TEMPLATE
   The disk type for the instance.
 
+NEW_DISK_TEMPLATE
+  The new disk type for the instance.
+
 INSTANCE_DISK_COUNT
   The number of disks for the instance.
 
@@ -512,6 +550,12 @@ INSTANCE_DISKn_SIZE
 INSTANCE_DISKn_MODE
   Either *rw* for a read-write disk or *ro* for a read-only one.
 
+INSTANCE_HV_x,y,z,...
+  Instance hypervisor options. There is one variable per option. For instance, GANETI_INSTANCE_HV_use_bootloader
+
+INSTANCE_HYPERVISOR
+  The instance hypervisor.
+
 INSTANCE_NIC_COUNT
   The number of NICs for the instance.
 
@@ -524,6 +568,9 @@ INSTANCE_NICn_IP
 INSTANCE_NICn_MAC
   The MAC address of the *n* -th NIC of the instance.
 
+INSTANCE_NICn_MODE
+  The mode of the *n* -th NIC of the instance.
+
 INSTANCE_OS_TYPE
   The name of the instance OS.
 
@@ -533,7 +580,7 @@ INSTANCE_PRIMARY
   the nodes change during the exectution, but on the
   OLD_PRIMARY/NEW_PRIMARY values.
 
-INSTANCE_SECONDARIES
+INSTANCE_SECONDARY
   Space-separated list of secondary nodes for the instance. Note that
   for migrations/failovers, you shouldn't rely on this variable since
   the nodes change during the exectution, but on the
@@ -548,6 +595,15 @@ INSTANCE_VCPUS
 INSTANCE_STATUS
   The run status of the instance.
 
+MASTER_CAPABLE
+  Whether a node is capable of being promoted to master.
+
+VM_CAPABLE
+  Whether the node can host instances.
+
+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).
@@ -594,6 +650,9 @@ OLD_PRIMARY, NEW_PRIMARY
   For migrations/failovers, the old and respectively new primary
   nodes. These two mirror the NEW_SECONDARY/OLD_SECONDARY variables
 
+EXPORT_MODE
+  The instance export mode. Either "remote" or "local".
+
 EXPORT_NODE
   The node on which the exported image of the instance was done.
 
@@ -604,6 +663,24 @@ EXPORT_DO_SHUTDOWN
   the filesystem would need a check (journal replay or full fsck) in
   order to guarantee consistency.
 
+REMOVE_INSTANCE
+  Whether the instance was removed from the node.
+
+SHUTDOWN_TIMEOUT
+  Amount of time to wait for the instance to shutdown.
+
+TIMEOUT
+  Amount of time to wait before aborting the op.
+
+OLD_NAME, NEW_NAME
+  Old/new name of the node group.
+
+GROUP_NAME
+  The name of the node group.
+
+NEW_ALLOC_POLICY
+  The new allocation policy for the node group.
+
 CLUSTER_TAGS
   The list of cluster tags, space separated.
 
@@ -634,7 +711,7 @@ script::
   GANETI_INSTANCE_NIC_COUNT=1
   GANETI_INSTANCE_OS_TYPE=debootstrap
   GANETI_INSTANCE_PRIMARY=node3.example.com
-  GANETI_INSTANCE_SECONDARIES=node5.example.com
+  GANETI_INSTANCE_SECONDARY=node5.example.com
   GANETI_INSTANCE_STATUS=down
   GANETI_INSTANCE_VCPUS=1
   GANETI_MASTER=node1.example.com