1#!/bin/sh
2#
3# External STONITH module for DRAC5 adapters.
4#
5# Author:  Jun Wang
6# License:      GNU General Public License (GPL)
7#
8
9trap 'if [ -n "$outf" ]; then ha_log.sh err "`cat $outf`"; rm -f "$outf"; fi' 0
10outf=`mktemp` || {
11	ha_log.sh err "mktemp failed"
12	exit 1
13}
14
15sshlogin() {
16	if [ x = "x$ipaddr" -o x = "x$userid" ]
17	then
18		ha_log.sh err "ipaddr or userid missing; check configuration"
19		return 1
20	fi
21	@SSH@ -q -x -n $userid@$ipaddr racadm serveraction "$1" >$outf 2>&1
22}
23
24drac_reset() {
25	sshlogin hardreset
26}
27
28drac_on() {
29	sshlogin poweron
30}
31
32drac_off() {
33	sshlogin poweroff
34}
35
36drac_status() {
37	sshlogin powerstatus
38}
39
40case $1 in
41gethosts)
42	echo $hostname
43	;;
44on)
45	drac_poweron
46	;;
47off)
48	drac_poweroff
49	;;
50reset)
51	drac_reset
52	;;
53status)
54	drac_status
55	;;
56getconfignames)
57	for i in hostname ipaddr userid; do
58		echo $i
59	done
60	;;
61getinfo-devid)
62	echo "DRAC5 STONITH device"
63	;;
64getinfo-devname)
65	echo "DRAC5 STONITH device"
66	;;
67getinfo-devdescr)
68	echo "DRAC5 host reset/poweron/poweroff"
69	;;
70getinfo-devurl)
71	echo "http://www.dell.com"
72	;;
73getinfo-xml)
74	cat <<EOF
75<parameters>
76
77<parameter name="hostname" unique="1">
78<content type="string" />
79<shortdesc lang="en">
80Hostname
81</shortdesc>
82<longdesc lang="en">
83The hostname of the host to be managed by this STONITH device
84</longdesc>
85</parameter>
86
87<parameter name="ipaddr" unique="1">
88<content type="string" />
89<shortdesc lang="en">
90IP Address
91</shortdesc>
92<longdesc lang="en">
93The IP address of the STONITH device
94</longdesc>
95</parameter>
96
97<parameter name="userid" unique="1">
98<content type="string" />
99<shortdesc lang="en">
100Login
101</shortdesc>
102<longdesc lang="en">
103The username used for logging in to the STONITH device
104</longdesc>
105</parameter>
106
107</parameters>
108EOF
109	;;
110*)
111	exit 1
112	;;
113esac
114