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:
parent
53a13df03d
commit
47ba28ecb7
@ -17,12 +17,28 @@
|
||||
|
||||
"""Possible states for host aggregates.
|
||||
|
||||
An aggregate may be 'building', in which case the admin has triggered its
|
||||
creation, but the underlying hypervisor pool has not actually being created
|
||||
yet. An aggregate may be 'active', in which case the underlying hypervisor
|
||||
pool is up and running. An aggregate may be in 'error' in all other cases.
|
||||
An aggregate may be 'created', in which case the admin has triggered its
|
||||
creation, but the underlying hypervisor pool has not actually being set up
|
||||
yet. An aggregate may be 'changing', meaning that the underlying hypervisor
|
||||
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'
|
||||
ERROR = 'error'
|
||||
DISMISSED = 'dismissed'
|
||||
|
@ -4257,7 +4257,7 @@ def aggregate_create(context, values, metadata=None):
|
||||
try:
|
||||
aggregate = models.Aggregate()
|
||||
aggregate.update(values)
|
||||
aggregate.operational_state = aggregate_states.BUILDING
|
||||
aggregate.operational_state = aggregate_states.CREATED
|
||||
aggregate.save()
|
||||
except exception.DBError:
|
||||
raise exception.AggregateNameExists(aggregate_name=values['name'])
|
||||
@ -4435,20 +4435,27 @@ def aggregate_host_delete(context, aggregate_id, host):
|
||||
@require_admin_context
|
||||
@require_aggregate_exists
|
||||
def aggregate_host_add(context, aggregate_id, host):
|
||||
session = get_session()
|
||||
host_ref = _aggregate_get_query(context,
|
||||
models.AggregateHost,
|
||||
models.AggregateHost.aggregate_id,
|
||||
aggregate_id,
|
||||
read_deleted='no').\
|
||||
session=session,
|
||||
read_deleted='yes').\
|
||||
filter_by(host=host).first()
|
||||
if not host_ref:
|
||||
try:
|
||||
host_ref = models.AggregateHost()
|
||||
values = {"host": host, "aggregate_id": aggregate_id, }
|
||||
host_ref.update(values)
|
||||
host_ref.save()
|
||||
host_ref.save(session=session)
|
||||
except exception.DBError:
|
||||
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:
|
||||
raise exception.AggregateHostExists(host=host,
|
||||
aggregate_id=aggregate_id)
|
||||
|
Loading…
Reference in New Issue
Block a user