| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright (c) 2006 Dejan Muhamedagic <[email protected]>, IBM Austria |
| 4 |
# |
| 5 |
# External STONITH module for IBM RSA adapters. |
| 6 |
# External STONITH module for IBM BMC. |
| 7 |
# This STONITH module depends on IBMmpcli. |
| 8 |
# |
| 9 |
|
| 10 |
trap 'rm -f "$outf"' 0 |
| 11 |
outf=`mktemp` || { |
| 12 |
ha_log.sh err 'mktemp failed' |
| 13 |
exit 1 |
| 14 |
} |
| 15 |
|
| 16 |
chkmpcli() { |
| 17 |
test -x /opt/IBMmpcli/bin/MPCLI.sh |
| 18 |
} |
| 19 |
mpcli() { |
| 20 |
chkmpcli || { |
| 21 |
ha_log.sh err "IBM mpcli not installed" |
| 22 |
return 1 |
| 23 |
} |
| 24 |
if [ x = "x$ipaddr" -o x = "x$userid" -o x = "x$passwd" ] |
| 25 |
then |
| 26 |
ha_log.sh err "ipaddr, userid, or passwd missing; check configuration" |
| 27 |
return 1 |
| 28 |
fi |
| 29 |
type=${type:-"ibm"} |
| 30 |
|
| 31 |
goodstg="SUCCESS" |
| 32 |
failstg="FAILURE" |
| 33 |
( |
| 34 |
echo "logonip -h $ipaddr -u $userid -p $passwd -t $type" |
| 35 |
echo "outputfile $outf" |
| 36 |
cat |
| 37 |
) | /opt/IBMmpcli/bin/MPCLI.sh | grep -w $goodstg >/dev/null 2>&1 |
| 38 |
rc=$? |
| 39 |
grep -w $failstg $outf >/dev/null |
| 40 |
if [ $rc -eq 0 -a $? -eq 1 ]; then |
| 41 |
return 0 |
| 42 |
else |
| 43 |
ha_log.sh err "MPCLI.sh failed: `cat $outf`" |
| 44 |
return 1 |
| 45 |
fi |
| 46 |
} |
| 47 |
ibmrsa_reboot() { |
| 48 |
echo restart -now | mpcli |
| 49 |
} |
| 50 |
ibmrsa_poweron() { |
| 51 |
echo poweron | mpcli |
| 52 |
} |
| 53 |
ibmrsa_poweroff() { |
| 54 |
echo poweroff | mpcli |
| 55 |
} |
| 56 |
ibmrsa_status() { |
| 57 |
echo | mpcli |
| 58 |
} |
| 59 |
|
| 60 |
hostname=`echo ${hostname} | tr ',' ' '` |
| 61 |
|
| 62 |
case $1 in |
| 63 |
gethosts) |
| 64 |
echo $hostname |
| 65 |
;; |
| 66 |
on) |
| 67 |
ibmrsa_poweron |
| 68 |
;; |
| 69 |
off) |
| 70 |
ibmrsa_poweroff |
| 71 |
;; |
| 72 |
reset) |
| 73 |
ibmrsa_reboot |
| 74 |
;; |
| 75 |
status) |
| 76 |
ibmrsa_status |
| 77 |
;; |
| 78 |
getconfignames) |
| 79 |
for i in hostname ipaddr userid passwd type; do |
| 80 |
echo $i |
| 81 |
done |
| 82 |
;; |
| 83 |
getinfo-devid) |
| 84 |
echo "IBM MP STONITH device" |
| 85 |
;; |
| 86 |
getinfo-devname) |
| 87 |
echo "IBM MP STONITH device" |
| 88 |
;; |
| 89 |
getinfo-devdescr) |
| 90 |
echo "IBM MP host reboot/poweron/poweroff" |
| 91 |
;; |
| 92 |
getinfo-devurl) |
| 93 |
echo "http://www.ibm.com" |
| 94 |
;; |
| 95 |
getinfo-xml) |
| 96 |
cat <<EOF |
| 97 |
<parameters> |
| 98 |
|
| 99 |
<parameter name="hostname" unique="1" required="1"> |
| 100 |
<content type="string" /> |
| 101 |
<shortdesc lang="en"> |
| 102 |
Hostname |
| 103 |
</shortdesc> |
| 104 |
<longdesc lang="en"> |
| 105 |
The hostname of the host to be managed by this STONITH device |
| 106 |
</longdesc> |
| 107 |
</parameter> |
| 108 |
|
| 109 |
<parameter name="ipaddr" unique="1" required="1"> |
| 110 |
<content type="string" /> |
| 111 |
<shortdesc lang="en"> |
| 112 |
IP Address |
| 113 |
</shortdesc> |
| 114 |
<longdesc lang="en"> |
| 115 |
The IP address of the STONITH device |
| 116 |
</longdesc> |
| 117 |
</parameter> |
| 118 |
|
| 119 |
<parameter name="userid" unique="0" required="1"> |
| 120 |
<content type="string" /> |
| 121 |
<shortdesc lang="en"> |
| 122 |
Login |
| 123 |
</shortdesc> |
| 124 |
<longdesc lang="en"> |
| 125 |
The username used to login into the STONITH device |
| 126 |
</longdesc> |
| 127 |
</parameter> |
| 128 |
|
| 129 |
<parameter name="passwd" unique="0" required="1"> |
| 130 |
<content type="string" /> |
| 131 |
<shortdesc lang="en"> |
| 132 |
Password |
| 133 |
</shortdesc> |
| 134 |
<longdesc lang="en"> |
| 135 |
The password used to login into the STONITH device |
| 136 |
</longdesc> |
| 137 |
</parameter> |
| 138 |
|
| 139 |
<parameter name="type" unique="0" required="1"> |
| 140 |
<content type="string" /> |
| 141 |
<shortdesc lang="en"> |
| 142 |
Management processor type |
| 143 |
</shortdesc> |
| 144 |
<longdesc lang="en"> |
| 145 |
The type of the management processor. Possible values are |
| 146 |
"ibm" (default, typically used for RSA) and "ipmi" |
| 147 |
(for IPMI compliant processors such as BMC). |
| 148 |
</longdesc> |
| 149 |
</parameter> |
| 150 |
|
| 151 |
</parameters> |
| 152 |
EOF |
| 153 |
;; |
| 154 |
*) |
| 155 |
exit 1 |
| 156 |
;; |
| 157 |
esac |