This file is indexed.

/etc/maas/templates/power/ipmi.template is in maas-cluster-controller 1.5.4+bzr2294-0ubuntu1.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- mode: shell-script -*-
#
# Control a system via ipmipower
#

# Parameters.
power_change={{power_change}}
power_address={{power_address}}
power_user={{power_user}}
power_pass={{power_pass}}
power_driver={{power_driver}}
ipmipower={{ipmipower}}
ipmi_chassis_config={{ipmi_chassis_config}}
config={{config_dir}}/{{ipmi_config}}

# If ip_address was supplied and power_address is not explicitly set then
# use ip_address because it gets discovered on-the-fly based on mac_address.
# We don't want to use it unilaterally because mac_address may be the host's
# MAC, so only fall back if someone deliberately left power_address empty.
{{if ip_address and not power_address}}
power_address={{ip_address}}
{{endif}}

# This workaround is required on many BMCs, and should have no impact
# on BMCs that don't require it.
# See https://bugs.launchpad.net/maas/+bug/1287964
workarounds="-W opensesspriv"

# Determines the power command needed to execute the desired
# action. This function receives ${power_change} as argument.
formulate_power_command() {
    case $1 in
    'on') echo '--cycle --on-if-off' ;;
    'off') echo '--off' ;;
    *)
        echo "Got unknown power state from ipmipower: '$1'" >&2
        exit 1
    esac
}

# Determines the current state on which the machine finds itself.
# The argument passed comes from IPMI's stat command in the form:
# <ipmi-ip-address>: <on/off>
# This function evaluates whether it was <on/off>.
formulate_power_state() {
    case $2 in
    'on') echo 'on' ;;
    'off') echo 'off' ;;
    *)
        echo "Got unknown power state from ipmipower: '$2'" >&2
        exit 1
    esac
}

# Issue command to ipmipower, for the given system.
issue_ipmi_command() {
    # See https://launchpad.net/bugs/1053391 for details of this workaround
    driver_option=""
    if [ -n "$power_driver" ]
        then
          driver_option="--driver-type=${power_driver}"
    fi

    echo workaround |\
    ${ipmi_chassis_config} ${workarounds} ${driver_option} -h ${power_address} -u ${power_user} -p ${power_pass} --commit --filename ${config}
    echo workaround |\
    ${ipmipower} ${workarounds} ${driver_option} -h ${power_address} -u ${power_user} -p ${power_pass} "$@"
}

# This script deliberately does not check the current power state
# before issuing the requested power command. See bug 1171418 for an
# explanation.
power_command=$(formulate_power_command ${power_change})
issue_ipmi_command ${power_command}