#
# $Id: powerman.dev 1110 2009-01-30 20:04:22Z garlick $
#
# PowerMan script for controlling another PowerMan daemon, e.g.
#
#  device "cartman" "powerman" "cartman.llnl.gov:10101"
#  node "b[1-4]" "cartman" "b[1-4]"
#
# N.B. master powerman.conf must contain the union of all slave 
# powerman.conf plugs, or status_all script will not work.
# 
specification "powerman" {
	timeout 	100.0

	script login {
		expect "powerman> "
		send "exprange\r\n"
		expect "105 Hostrange expansion ON\r\npowerman> "
	}
	script logout {
		send "quit\r\n"
	}
        script status_all {
                send "status\r\n"
                foreachplug {
                        expect "303 ([^:]+): (off|on|unknown)\r\n"
                        setplugstate $1 $2 off="off" on="on"
                }
                expect "powerman> "
        }
	script on_ranged {
		send "on %s\r\n"
		expect "powerman> "
	}
	script off_ranged {
		send "off %s\r\n"
		expect "powerman> "
	}
	script cycle_ranged {
		send "cycle %s\r\n"
		expect "powerman> "
	}
	script reset_ranged {
		send "reset %s\r\n"
		expect "powerman> "
	}
}
