summaryrefslogtreecommitdiffstats
path: root/lib/plugins/stonith/external/xen0-ha.in
blob: cb42cbc52c7293c1ef2ead0ca9eb4adf190981c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
#
# This STONITH script integrates a cluster running within DomUs
# with the CRM/Pacemaker cluster running in Dom0.
#
# Author:	Lars Marowsky-Bree
# Copyright:	2008 Lars Marowsky-Bree
# License:      GNU General Public License (GPL)
#

SSH_COMMAND="@SSH@ -q -x -n"
HVM_HELPER="@stonith_plugindir@/xen0-ha-dom0-stonith-helper"

# Rewrite the hostlist to accept "," as a delimeter for hostnames too.
hostlist=`echo $hostlist | tr ',' ' '`

# Runs a command on the host, waiting for it to return
RunHVMCommand() {
    $SSH_COMMAND $dom0_cluster_ip "$HVM_HELPER $1 $2 $stop_timeout"
}

# Main code
case $1 in
gethosts)
    echo $hostlist
    exit 0
    ;;
on|off|reset|status)
    RunHVMCommand $1 $2
    exit $?
    ;;
getconfignames)
    echo "hostlist dom0_cluster_ip timeout"
    exit 0
    ;;
getinfo-devid)
    echo "xen0-ha DomU/Dom0 device"
    exit 0
    ;;
getinfo-devname)
    echo "xen0-ha DomU/Dom0 external device"
    exit 0
    ;;
getinfo-devdescr)
    echo "Allows STONITH to control DomUs managed by a CRM/Pacemaker Dom0."
    echo "Requires Xen + CRM/Pacemaker at both layers."
    echo "Proof-of-concept code!"
    exit 0
    ;;
getinfo-devurl)
    echo "http://linux-ha.org/wiki/DomUClusters"
    exit 0
    ;;
getinfo-xml)
    cat << SSHXML
<parameters>
<parameter name="hostlist" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">
Hostlist
</shortdesc>
<longdesc lang="en">
The list of controlled DomUs, separated by whitespace.
These must be configured as Xen RA resources with a name with a matching
id.
For example: "xen-1 xen-2 xen-3"
</longdesc>
</parameter>
<parameter name="dom0_cluster_ip" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">
Dom0 cluster ip
</shortdesc>
<longdesc lang="en">
The cluster IP address associated with Dom0. 
Root user must be able to ssh to that node.
</longdesc>
</parameter>
<parameter name="stop_timeout">
<content type="integer" />
<shortdesc lang="en">
Stop timeout
</shortdesc>
<longdesc lang="en">
The timeout, in seconds, for which to wait for Dom0 to report that the
DomU has been stopped, before aborting with a failure.
</longdesc>
</parameter>
</parameters>
SSHXML
    exit 0
    ;;
*)
    exit 1
    ;;
esac