# 
# $Id: ipmipower.dev 1127 2009-04-17 23:51:18Z garlick $
#
# This device configuration supports power control via the 
# 'ipmipower' utility.
#
# See powerman-devices(7) for more info on running ipmipower under
# powerman.
#
# some IPMI devices require some time for the firmware to
# reload/re-settle itself after a power-off.  A delay of 5 seconds
# seems to work fine pretty well.
#
# off,delay,on used in place of IPMI cycle to ensure full command
# completion before returning to the user.
#
specification "ipmipower" {
	timeout  	60

	script login {
		expect "ipmipower> "
	}
	script logout {
		send "quit\n"
	}
	script status_all {
		send "stat\n"
		foreachnode {
			expect "([^\n:]+): ([^\n]+)\n"
			setplugstate $1 $2 on="on" off="off"
		}
		expect "ipmipower> "
	}
	script on_ranged {
		send "on %s\n"
		expect "ipmipower> "
	}
	script off_ranged {
		send "off %s\n"
		expect "ipmipower> "
	}
	script cycle_ranged {
		send "off %s\n"
		expect "ipmipower> "
		delay 5
		send "on %s\n"
		expect "ipmipower> "
	}
}
