blueprint host-aggregates: OSAPI/virt integration, via nova.compute.api

This commit introduces the first cut of integration between the OSAPI
Admin extensions for host aggregates and the virt layer.

This is part of a series of commits that have started with change:

https://review.openstack.org/#change,3035

Change-Id: I75d8b616e3b8f8cef75d40d937e0dce9f29b16db
This commit is contained in:
Armando Migliaccio 2012-01-18 19:47:36 +00:00
parent 53a13df03d
commit 47ba28ecb7
2 changed files with 31 additions and 8 deletions

View File

@ -17,12 +17,28 @@
"""Possible states for host aggregates. """Possible states for host aggregates.
An aggregate may be 'building', in which case the admin has triggered its An aggregate may be 'created', in which case the admin has triggered its
creation, but the underlying hypervisor pool has not actually being created creation, but the underlying hypervisor pool has not actually being set up
yet. An aggregate may be 'active', in which case the underlying hypervisor yet. An aggregate may be 'changing', meaning that the underlying hypervisor
pool is up and running. An aggregate may be in 'error' in all other cases. pool is being setup. An aggregate may be 'active', in which case the underlying
hypervisor pool is up and running. An aggregate may be 'dismissed' when it has
no hosts and it has been deleted. An aggregate may be in 'error' in all other
cases.
A 'created' aggregate becomes 'changing' during the first request of
adding a host. During a 'changing' status no other requests will be accepted;
this is to allow the hypervisor layer to instantiate the underlying pool
without any potential race condition that may incur in master/slave-based
configurations. The aggregate goes into the 'active' state when the underlying
pool has been correctly instantiated.
All other operations (e.g. add/remove hosts) that succeed will keep the
aggregate in the 'active' state. If a number of continuous requests fail,
an 'active' aggregate goes into an 'error' state. To recover from such a state,
admin intervention is required. Currently an error state is irreversible,
that is, in order to recover from it an aggregate must be deleted.
""" """
BUILDING = 'building' CREATED = 'created'
CHANGING = 'changing'
ACTIVE = 'active' ACTIVE = 'active'
ERROR = 'error' ERROR = 'error'
DISMISSED = 'dismissed'

View File

@ -4257,7 +4257,7 @@ def aggregate_create(context, values, metadata=None):
try: try:
aggregate = models.Aggregate() aggregate = models.Aggregate()
aggregate.update(values) aggregate.update(values)
aggregate.operational_state = aggregate_states.BUILDING aggregate.operational_state = aggregate_states.CREATED
aggregate.save() aggregate.save()
except exception.DBError: except exception.DBError:
raise exception.AggregateNameExists(aggregate_name=values['name']) raise exception.AggregateNameExists(aggregate_name=values['name'])
@ -4435,20 +4435,27 @@ def aggregate_host_delete(context, aggregate_id, host):
@require_admin_context @require_admin_context
@require_aggregate_exists @require_aggregate_exists
def aggregate_host_add(context, aggregate_id, host): def aggregate_host_add(context, aggregate_id, host):
session = get_session()
host_ref = _aggregate_get_query(context, host_ref = _aggregate_get_query(context,
models.AggregateHost, models.AggregateHost,
models.AggregateHost.aggregate_id, models.AggregateHost.aggregate_id,
aggregate_id, aggregate_id,
read_deleted='no').\ session=session,
read_deleted='yes').\
filter_by(host=host).first() filter_by(host=host).first()
if not host_ref: if not host_ref:
try: try:
host_ref = models.AggregateHost() host_ref = models.AggregateHost()
values = {"host": host, "aggregate_id": aggregate_id, } values = {"host": host, "aggregate_id": aggregate_id, }
host_ref.update(values) host_ref.update(values)
host_ref.save() host_ref.save(session=session)
except exception.DBError: except exception.DBError:
raise exception.AggregateHostConflict(host=host) raise exception.AggregateHostConflict(host=host)
elif host_ref.deleted:
host_ref.update({'deleted': False,
'deleted_at': None,
'updated_at': literal_column('updated_at')})
host_ref.save(session=session)
else: else:
raise exception.AggregateHostExists(host=host, raise exception.AggregateHostExists(host=host,
aggregate_id=aggregate_id) aggregate_id=aggregate_id)