2 # ganeti master role OCF resource
3 # See http://linux-ha.org/wiki/OCF_Resource_Agents
9 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
11 SCRIPTNAME="@LIBDIR@/ocf/resource.d/ganeti/ganeti-master-role"
13 # Master candidates list file
14 MCFILE="$DATA_DIR/ssconf_master_candidates"
16 # We'll need the hostname in a few places, so we'll get it once, now.
17 MYHOSTNAME=$(hostname --fqdn)
20 local -r master=$(gnt-cluster getmaster)
21 [[ "$MYHOSTNAME" == "$master" ]]
25 grep -Fx $MYHOSTNAME $MCFILE
31 elif is_candidate; then
32 gnt-cluster master-failover || exit 1 # OCF_ERR_GENERIC
34 exit 5 # OCF_ERR_INSTALLED (vital component missing)
39 # We can't really "stop" being a master.
40 # TODO: investigate whether a fake approach will do.
41 exit 1 # OCF_ERR_GENERIC
46 gnt-cluster redist-conf || exit 1 # OCF_ERR_GENERIC
47 elif is_candidate; then
48 gnt-cluster master-failover || exit 1 # OCF_ERR_GENERIC
50 exit 5 # OCF_ERR_INSTALLED (vital component missing)
55 # monitor should exit:
56 # 7 if the resource is not running
61 elif is_candidate; then
62 exit 7 # OCF_NOT_RUNNING
64 exit 5 # OCF_ERR_INSTALLED (vital component missing)
71 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
72 <resource-agent name="ganeti-master-role" version="0.1">
73 <version>0.1</version>
75 OCF script to manage the ganeti master role in a cluster.
77 Can be used to failover the ganeti master between master candidate nodes.
79 <shortdesc lang="en">Manages the ganeti cluster master</shortdesc>
83 <action name="start" timeout="300s" />
84 <action name="stop" timeout="50s" />
85 <action name="monitor" depth="0" timeout="10s" interval="30s" />
86 <action name="meta-data" timeout="5s" />
87 <action name="recover" timeout="20s" />
88 <action name="reload" timeout="5s" />
96 # Mandatory OCF commands
109 # Optional OCF commands
114 # The ganeti master role has no "configuration" that is reloadable on
115 # the pacemaker side. We declare the operation anyway to make sure
116 # pacemaker doesn't decide to stop and start the service needlessly.
119 promote|demote|migrate_to|migrate_from|validate-all)
120 # Not implemented (nor declared by meta-data)
121 exit 3 # OCF_ERR_UNIMPLEMENTED
124 log_success_msg "Usage: $SCRIPTNAME {start|stop|monitor|meta-data|recover|reload}"