~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/virt/xenapi/pool_states.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2010 OpenStack LLC.
 
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
"""Possible states for xen resource pools.
 
19
 
 
20
A pool may be 'created', in which case the admin has triggered its
 
21
creation, but the underlying hypervisor pool has not actually being set up
 
22
yet. An pool may be 'changing', meaning that the underlying hypervisor
 
23
pool is being setup. An pool may be 'active', in which case the underlying
 
24
hypervisor pool is up and running. An pool may be 'dismissed' when it has
 
25
no hosts and it has been deleted. An pool may be in 'error' in all other
 
26
cases.
 
27
A 'created' pool becomes 'changing' during the first request of
 
28
adding a host. During a 'changing' status no other requests will be accepted;
 
29
this is to allow the hypervisor layer to instantiate the underlying pool
 
30
without any potential race condition that may incur in master/slave-based
 
31
configurations. The pool goes into the 'active' state when the underlying
 
32
pool has been correctly instantiated.
 
33
All other operations (e.g. add/remove hosts) that succeed will keep the
 
34
pool in the 'active' state. If a number of continuous requests fail,
 
35
an 'active' pool goes into an 'error' state. To recover from such a state,
 
36
admin intervention is required. Currently an error state is irreversible,
 
37
that is, in order to recover from it an pool must be deleted.
 
38
"""
 
39
from nova import db
 
40
 
 
41
CREATED = 'created'
 
42
CHANGING = 'changing'
 
43
ACTIVE = 'active'
 
44
ERROR = 'error'
 
45
DISMISSED = 'dismissed'
 
46
 
 
47
# Metadata keys
 
48
KEY = 'operational_state'
 
49
POOL_FLAG = 'hypervisor_pool'
 
50
 
 
51
 
 
52
def is_hv_pool(context, aggregate_id):
 
53
    """Checks if aggregate is a hypervisor_pool"""
 
54
    metadata = db.aggregate_metadata_get(context, aggregate_id)
 
55
    return POOL_FLAG in metadata.keys()