update PDUs list
[ktest-util.git] / vzt-pductl
blob6d96c310692e09fcedee55ca7149134061a36f2a
1 #! /bin/sh
2 CONFIG="/etc/vzt/vzt-pductl.cfg"
4 ACTION=$1
5 shift
6 PDU_HOST="$1"
7 shift
9 function show_usage
11 echo "$0: pdu control tool"
12 echo "Usage: $0 <lsall/ls/reboot> <pdu_host> [options]"
13 echo "examples:"
14 echo "list all socket status on pdu00.qa"
15 echo " $0 lsall pdu00.qa"
16 echo "get 15th socket power status on pdu00.qa"
17 echo " $0 ls pdu00.qa 15"
18 echo "reboot 15th socket pdu00.qa"
19 echo " $0 reboot pdu00.qa 15"
24 #######################################################################
25 ################### pdu speciffic functions section ###################
27 ##### PowerNet device
28 function power_net_mib
30 pdu_host=$1
31 action=$2
32 host=$3
34 case "$action" in
35 lsall ) snmptable -c private -v 1 $pdu_host -m +PowerNet-MIB \
36 rPDUOutletStatusTable;;
37 ls ) snmpget -c private -v 1 -m +PowerNet-MIB $pdu_host \
38 rPDUOutletControlOutletCommand.$host;;
39 reboot ) snmpset -c private -v 1 -m +PowerNet-MIB $pdu_host \
40 rPDUOutletControlOutletCommand.$host = immediateReboot;;
41 * ) echo "Unknown action";
42 show_usage;
43 exit 1;;
44 esac
49 CFG_FUNCTION=""
50 while read name cfg_func ;do
51 if [ "$name" == "$PDU_HOST" ];then
52 $cfg_func $PDU_HOST $ACTION $@
53 exit 0
54 break
56 done < $CONFIG
57 echo "Cant find $PDU_HOST in $CONFIG file"
58 show_usage
59 exit 1