~ubuntu-branches/ubuntu/raring/maas/raring-proposed

« back to all changes in this revision

Viewing changes to src/provisioningserver/power/templates/ipmilan.template

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-17 08:28:36 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20120717082836-ucb2vou8tqg353eq
Tags: 0.1+bzr777+dfsg-0ubuntu1
* New upstream release
* Only run 'maas' command as root. (LP: #974046)
  - debian/extras/maas: Check id.
  - debian/maas.install: Install in 'sbin'.
* debian/maas.postinst:
  - restart apache2 after everything gets processed.
  - Update version to handle upgrades.
* debian/extras/maas-provision: Add wrapper to access 'maasprovisiong'
  command line.
* debian/patches/99_temporary_fix_path.patch: Dropped. No longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- mode: shell-script -*-
 
2
#
 
3
# Control a system via ipmitool
 
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
ipmitool={{ipmitool}}
 
12
interface={{power_ipmi_interface}}
 
13
 
 
14
 
 
15
formulate_power_state() {
 
16
    case $1 in
 
17
    'Chassis Power is on') echo 'on' ;;
 
18
    'Chassis Power is off') echo 'off' ;;
 
19
    *)
 
20
        echo "Got unknown power state from ipmitool: '$1'" >&2
 
21
        exit 1
 
22
    esac
 
23
}
 
24
 
 
25
# Issue command to ipmitool, for the given system.
 
26
issue_ipmi_command() {
 
27
    ${ipmitool} -I ${interface} -H ${power_address} -U ${power_user} -P ${power_pass} power $1
 
28
}
 
29
 
 
30
 
 
31
# Get the given system's power state: 'on' or 'off'.
 
32
get_power_state() {
 
33
    ipmi_state=$(issue_ipmi_command status)
 
34
    formulate_power_state ${ipmi_state}
 
35
}
 
36
 
 
37
 
 
38
if [ "$(get_power_state)" != "${power_change}" ]
 
39
then
 
40
    issue_ipmi_command ${power_change}
 
41
fi