1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2010 OpenStack LLC.
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
10
# http://www.apache.org/licenses/LICENSE-2.0
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
18
"""Possible states for xen resource pools.
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
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.
45
DISMISSED = 'dismissed'
48
KEY = 'operational_state'
49
POOL_FLAG = 'hypervisor_pool'
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()