Merge lp:~rvb/maas/report-fatal-power-failures into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 2977
Proposed branch: lp:~rvb/maas/report-fatal-power-failures
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 34 lines (+12/-4)
1 file modified
etc/maas/templates/power/ipmi.template (+12/-4)
To merge this branch: bzr merge lp:~rvb/maas/report-fatal-power-failures
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+234497@code.launchpad.net

Commit message

Fix the IPMI template so that an "invalid password" error results in the script exiting with a status code of 2 (indicative of a fatal failure).

Description of the change

I've tested that the script still works if the password is right and that this results in a meaningful event to be sent to the error log if not.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Shell is so depressing.

review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

IPMI too.

Revision history for this message
Raphaël Badin (rvb) wrote :

> Shell is so depressing.

Very true. You might take solace in the fact that this code is going away… eventually :).

Thanks for the review!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'etc/maas/templates/power/ipmi.template'
2--- etc/maas/templates/power/ipmi.template 2014-09-12 09:45:27 +0000
3+++ etc/maas/templates/power/ipmi.template 2014-09-12 15:43:50 +0000
4@@ -59,18 +59,26 @@
5
6 if [ "$power_change" != "query" ]
7 then
8- echo workaround |\
9- ${ipmi_chassis_config} ${workarounds} ${driver_option} -h ${power_address} -u ${power_user} -p ${power_pass} --commit --filename ${config}
10+ # Use C locale to force English error messages.
11+ result=$(echo workaround |\
12+ LC_ALL=C ${ipmi_chassis_config} ${workarounds} ${driver_option} -h ${power_address} -u ${power_user} -p ${power_pass} --commit --filename ${config} 2>&
13+1)
14+
15+ if echo $result | grep -q "password invalid"
16+ then
17+ echo "Invalid password" >&2
18+ exit 2
19+ fi
20 fi
21
22 # Use C locale to force English error messages.
23 result=$(echo workaround |\
24 LC_ALL=C ${ipmipower} ${workarounds} ${driver_option} -h ${power_address} -u ${power_user} -p ${power_pass} "$@")
25
26- if [ $(echo $result | grep -q "password invalid") ]
27+ if echo $result | grep -q "password invalid"
28 then
29 echo "Invalid password" >&2
30- exit 1
31+ exit 2
32 fi
33
34 case "$result" in