~smoser/ubuntu/wily/maas/lp1474417

« back to all changes in this revision

Viewing changes to .pc/99-fix-ipmi-stat-lp1086160.patch/src/provisioningserver/power/templates/ipmi.template

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-04-23 14:02:33 UTC
  • Revision ID: package-import@ubuntu.com-20130423140233-358whmd81xc0xms0
Tags: 1.3+bzr1461+dfsg-0ubuntu3
* debian/patches:
  - 99-fix-ipmi-stat-lp1086160.patch: Drop. The following patch removes
    the need for this fix. (LP: #1171988)
  - 99-fix-ipmi-lp1171418.patch: Do not check current node state when
    executing an ipmi command, which ensures that nodes are always
    turned on/off regardless of their power state. This fixes corner
    cases found when running automated tests. (LP: #1171418)
  - 99-fix-comissioning-lp1131418.patch: Fixes the commissioning process,
    allowing nodes to successfully commission, when tag's with no
    definition have been created. This issue will only appear when these
    special tags are created. (LP: #1131418)
  - 99-import-raring-images-lp1182642.patch: Enables the import of raring
    images by default (LP: #1182642)
  - 99-fix-new-image-install-lp1182646.patch: Fixes the installation of
    new ephemeral images, that fail due to not being able to overwrite
    a symlink. (LP: #1182646)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- mode: shell-script -*-
2
 
#
3
 
# Control a system via ipmipower
4
 
#
5
 
 
6
 
# Parameters.
7
 
power_change={{power_change}}
8
 
power_address={{power_address}}
9
 
power_user={{power_user}}
10
 
power_pass={{power_pass}}
11
 
power_driver={{power_driver}}
12
 
ipmipower={{ipmipower}}
13
 
ipmi_chassis_config={{ipmi_chassis_config}}
14
 
config={{config_dir}}/{{ipmi_config}}
15
 
 
16
 
# Determines the power command needed to execute the desired
17
 
# action. This function receives ${power_change} as argument.
18
 
formulate_power_command() {
19
 
    case $1 in
20
 
    'on') echo '--cycle --on-if-off' ;;
21
 
    'off') echo '--off' ;;
22
 
    *)
23
 
        echo "Got unknown power state from ipmipower: '$1'" >&2
24
 
        exit 1
25
 
    esac
26
 
}
27
 
 
28
 
# Determines the current state on which the machine finds itself.
29
 
# The argument passed comes from IPMI's stat command in the form:
30
 
# <ipmi-ip-address>: <on/off>
31
 
# This function evaluates whether it was <on/off>.
32
 
formulate_power_state() {
33
 
    case $2 in
34
 
    'on') echo 'on' ;;
35
 
    'off') echo 'off' ;;
36
 
    *)
37
 
        echo "Got unknown power state from ipmipower: '$2'" >&2
38
 
        exit 1
39
 
    esac
40
 
}
41
 
 
42
 
# Issue command to ipmipower, for the given system.
43
 
issue_ipmi_command() {
44
 
    # See https://launchpad.net/bugs/1053391 for details of this workaround
45
 
    driver_option=""
46
 
    if [ -n "$power_driver" ]
47
 
        then
48
 
          driver_option="--driver-type=$power_driver"
49
 
    fi
50
 
 
51
 
    echo workaround |\
52
 
    ${ipmi_chassis_config} ${driver_option} -h ${power_address} -u ${power_user} -p ${power_pass} --commit --filename ${config}
53
 
    echo workaround |\
54
 
    ${ipmipower} ${driver_option} -h ${power_address} -u ${power_user} -p ${power_pass} "$@"
55
 
}
56
 
 
57
 
 
58
 
# Get the given system's power state: 'on' or 'off'.
59
 
get_power_state() {
60
 
    ipmi_state=$(issue_ipmi_command stat)
61
 
    formulate_power_state ${ipmi_state}
62
 
}
63
 
 
64
 
 
65
 
if [ "$(get_power_state)" != "${power_change}" ]
66
 
then
67
 
    power_command=$(formulate_power_command ${power_change})
68
 
    issue_ipmi_command ${power_command}
69
 
fi