This file is indexed.

/etc/maas/templates/power/virsh.template is in maas-cluster-controller 1.5+bzr2252-0ubuntu1.

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
# -*- mode: shell-script -*-
#
# Control virtual system's "power" through virsh.
#

# Parameters.
power_change={{power_change}}
power_address={{power_address}}
power_id={{power_id}}
virsh={{virsh}}


# Choose command for virsh to make the requested power change happen.
formulate_power_command() {
  if [ ${power_change} = 'on' ]
  then
      echo 'start'
  else
      echo 'destroy'
  fi
}


# Express system's current state as expressed by virsh as "on" or "off".
formulate_power_state() {
    case $1 in
    'running') echo 'on' ;;
    'shut off') echo 'off' ;;
    *)
        echo "Got unknown power state from virsh: '$1'" >&2
        exit 1
    esac
}


# Issue command to virsh, for the given system.
issue_virsh_command() {
    ${virsh} --connect ${power_address} $1 ${power_id}
}


# Get the given system's power state: 'on' or 'off'.
get_power_state() {
    virsh_state=$(issue_virsh_command domstate)
    formulate_power_state ${virsh_state}
}


if [ "$(get_power_state)" != "${power_change}" ]
then
    issue_virsh_command $(formulate_power_command)
fi