aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/template/power/ipmitool.tmpl
blob: 73278e4569b84c6adbac909a38dd84a1fc8bd1fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
source \${COMPASS_DIR}/util/log.sh
#set default_ipmiUser=$getVar('ipmiUser', '')
#set default_ipmiPass=$getVar('ipmiPass', '')
#set default_ipmiVer=$getVar('ipmiVer', '2.0')
#set hosts=$getVar('hosts', [])
#set fail_list=""
#for host in $hosts
#set host_name=$host.get('name', '')
#set ipmiIp=$host.get('ipmiIp', '')
#set ipmiUser=$host.get('ipmiUser', $default_ipmiUser)
#set ipmiPass=$host.get('ipmiPass', $default_ipmiPass)
#if not ($ipmiIp and $ipmiUser and $ipmiPass)
#set fail_list=$fail_list + $host_name + " "
#end if
#end for
#if  fail_list
echo $fail_list.strip() ipmi config is not right
exit 1
#else
#for host in $hosts
#set ipmiIp=$host.get('ipmiIp', '')
#set ipmiUser=$host.get('ipmiUser', $default_ipmiUser)
#set ipmiPass=$host.get('ipmiPass', $default_ipmiPass)
#set ipmiVer=$host.get('ipmiVer', $default_ipmiVer)
#if $ipmiVer == '2.0'
    #set interface='lanplus'
#else
    #set interface='lan'
#end if

for i in {1..5}; do
    if ipmitool -I $interface -H $ipmiIp -U $ipmiUser -P $ipmiPass chassis bootdev pxe >/dev/null 2>&1
    then
        break
    elif [[ i -lt 5 ]]
    then
        sleep 1
    else
        log_error "set $ipmiIp pxe fail"
        exit 1
    fi
done
sleep 1
for i in {1..5}; do
    if ipmitool -I $interface -H $ipmiIp -U $ipmiUser -P $ipmiPass chassis power reset >/dev/null 2>&1
    then
        break
    elif [[ i -lt 5 ]]
    then
        sleep 1
    else
        log_error "reset $ipmiIp fail"
        exit 1
    fi
done
log_info "set pxe and reset $ipmiIp successsully"
sleep 1
#end for
#end if