summaryrefslogtreecommitdiffstats
path: root/lib/plugins/stonith/external/ibmrsa
blob: 740846505f3445d8dbd5bcb7c15f151bdae5c3ed (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/sh
#
# Copyright (c) 2006 Dejan Muhamedagic <dmuhamedagic@at.ibm.com>, IBM Austria
#
# External STONITH module for IBM RSA adapters.
# External STONITH module for IBM BMC.
# This STONITH module depends on IBMmpcli.
#

trap 'rm -f "$outf"' 0
outf=`mktemp` || {
	ha_log.sh err 'mktemp failed'
	exit 1
}

chkmpcli() {
	test -x /opt/IBMmpcli/bin/MPCLI.sh
}
mpcli() {
	chkmpcli || {
		ha_log.sh err "IBM mpcli not installed"
		return 1
	}
	if [ x = "x$ipaddr" -o x = "x$userid" -o x = "x$passwd" ]
	then
		ha_log.sh err "ipaddr, userid, or passwd missing; check configuration"
		return 1
	fi
	type=${type:-"ibm"}

	goodstg="SUCCESS"
	failstg="FAILURE"
	(
	echo "logonip -h $ipaddr -u $userid -p $passwd -t $type"
	echo "outputfile $outf"
	cat
	) | /opt/IBMmpcli/bin/MPCLI.sh | grep -w $goodstg >/dev/null 2>&1
	rc=$?
	grep -w $failstg $outf >/dev/null
	if [ $rc -eq 0 -a $? -eq 1 ]; then
		return 0
	else
		ha_log.sh err "MPCLI.sh failed: `cat $outf`"
		return 1
	fi
}
ibmrsa_reboot() {
	echo restart -now | mpcli
}
ibmrsa_poweron() {
	echo poweron | mpcli
}
ibmrsa_poweroff() {
	echo poweroff | mpcli
}
ibmrsa_status() {
	echo | mpcli
}

hostname=`echo ${hostname} | tr ',' ' '`

case $1 in
gethosts)
	echo $hostname
	;;
on)
	ibmrsa_poweron
	;;
off)
	ibmrsa_poweroff
	;;
reset)
	ibmrsa_reboot
	;;
status)
	ibmrsa_status
	;;
getconfignames)
	for i in hostname ipaddr userid passwd type; do
		echo $i
	done
	;;
getinfo-devid)
	echo "IBM MP STONITH device"
	;;
getinfo-devname)
	echo "IBM MP STONITH device"
	;;
getinfo-devdescr)
	echo "IBM MP host reboot/poweron/poweroff"
	;;
getinfo-devurl)
	echo "http://www.ibm.com"
	;;
getinfo-xml)
	cat <<EOF
<parameters>

<parameter name="hostname" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">
Hostname
</shortdesc>
<longdesc lang="en">
The hostname of the host to be managed by this STONITH device
</longdesc>
</parameter>

<parameter name="ipaddr" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">
IP Address
</shortdesc>
<longdesc lang="en">
The IP address of the STONITH device
</longdesc>
</parameter>

<parameter name="userid" unique="0" required="1">
<content type="string" />
<shortdesc lang="en">
Login
</shortdesc>
<longdesc lang="en">
The username used to login into the STONITH device
</longdesc>
</parameter>

<parameter name="passwd" unique="0" required="1">
<content type="string" />
<shortdesc lang="en">
Password
</shortdesc>
<longdesc lang="en">
The password used to login into the STONITH device
</longdesc>
</parameter>

<parameter name="type" unique="0" required="1">
<content type="string" />
<shortdesc lang="en">
Management processor type
</shortdesc>
<longdesc lang="en">
The type of the management processor. Possible values are
"ibm" (default, typically used for RSA) and "ipmi"
(for IPMI compliant processors such as BMC).
</longdesc>
</parameter>

</parameters>
EOF
	;;
*)
	exit 1
	;;
esac