aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/template/power/ipmitool.tmpl
blob: 5d2630af9213144ca0220a7ac88a07ee992807c6 (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
source \${COMPASS_DIR}/util/log.sh
#set default_ipmiUser=$getVar('ipmiUser', '')
#set default_ipmiPass=$getVar('ipmiPass', '')
#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)
for i in {1..5}; do
    if ipmitool -I lan -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 lan -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