~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/api/ec2/inst_state.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandleman
  • Date: 2012-01-13 09:51:10 UTC
  • mfrom: (1.1.40)
  • Revision ID: package-import@ubuntu.com-20120113095110-ffd6163drcg77wez
Tags: 2012.1~e3~20120113.12049-0ubuntu1
[Chuck Short]
* New upstream version.
* debian/nova_sudoers, debian/nova-common.install, 
  Switch out to nova-rootwrap. (LP: #681774)
* Add "get-origsource-git" which allows developers to 
  generate a tarball from github, by doing:
  fakeroot debian/rules get-orig-source-git
* debian/debian/nova-objectstore.logrotate: Dont determine
  if we are running Debian or Ubuntu. (LP: #91379)

[Adam Gandleman]
* Removed python-nova.postinst, let dh_python2 generate instead since
  python-support is not a dependency. (LP: #907543)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2011 Isaku Yamahata <yamahata at valinux co jp>
 
4
# All Rights Reserved.
 
5
#
 
6
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
7
#    not use this file except in compliance with the License. You may obtain
 
8
#    a copy of the License at
 
9
#
 
10
#         http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
#    Unless required by applicable law or agreed to in writing, software
 
13
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
14
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
15
#    License for the specific language governing permissions and limitations
 
16
#    under the License.
 
17
 
 
18
PENDING_CODE = 0
 
19
RUNNING_CODE = 16
 
20
SHUTTING_DOWN_CODE = 32
 
21
TERMINATED_CODE = 48
 
22
STOPPING_CODE = 64
 
23
STOPPED_CODE = 80
 
24
 
 
25
PENDING = 'pending'
 
26
RUNNING = 'running'
 
27
SHUTTING_DOWN = 'shutting-down'
 
28
TERMINATED = 'terminated'
 
29
STOPPING = 'stopping'
 
30
STOPPED = 'stopped'
 
31
 
 
32
# non-ec2 value
 
33
SHUTOFF = 'shutoff'
 
34
MIGRATE = 'migrate'
 
35
RESIZE = 'resize'
 
36
PAUSE = 'pause'
 
37
SUSPEND = 'suspend'
 
38
RESCUE = 'rescue'
 
39
 
 
40
# EC2 API instance status code
 
41
_NAME_TO_CODE = {
 
42
    PENDING: PENDING_CODE,
 
43
    RUNNING: RUNNING_CODE,
 
44
    SHUTTING_DOWN: SHUTTING_DOWN_CODE,
 
45
    TERMINATED: TERMINATED_CODE,
 
46
    STOPPING: STOPPING_CODE,
 
47
    STOPPED: STOPPED_CODE,
 
48
 
 
49
    # approximation
 
50
    SHUTOFF: TERMINATED_CODE,
 
51
    MIGRATE: RUNNING_CODE,
 
52
    RESIZE: RUNNING_CODE,
 
53
    PAUSE: STOPPED_CODE,
 
54
    SUSPEND: STOPPED_CODE,
 
55
    RESCUE: RUNNING_CODE,
 
56
}
 
57
 
 
58
 
 
59
def name_to_code(name):
 
60
    return _NAME_TO_CODE.get(name, PENDING_CODE)