Make cells use Fault obj for create

Add support into InstanceFault.create() to handle where we need to
duplicate any faults in the API cells. Convert the cells code to use
InstanceFault.create()

NOTE: This happens to fix an oversight where we accidentally left the
update_cells=False kwarg off of the db call in the cells code.

Change-Id: Iec11b8259aaecba055a6d5636ab60dfa0dbb6c83
This commit is contained in:
Chris Behrens
2014-05-02 09:25:50 -07:00
parent 0a0cd641ad
commit 0192a20e69

View File

@@ -14,10 +14,17 @@
import itertools
from nova.cells import opts as cells_opts
from nova.cells import rpcapi as cells_rpcapi
from nova import db
from nova import exception
from nova.objects import base
from nova.objects import fields
from nova.openstack.common.gettextutils import _LE
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
class InstanceFault(base.NovaPersistentObject, base.NovaObject):
@@ -67,6 +74,16 @@ class InstanceFault(base.NovaPersistentObject, base.NovaObject):
db_fault = db.instance_fault_create(context, values)
self._from_db_object(context, self, db_fault)
self.obj_reset_changes()
# Cells should only try sending a message over to nova-cells
# if cells is enabled and we're not the API cell. Otherwise,
# if the API cell is calling this, we could end up with
# infinite recursion.
if cells_opts.get_cell_type() == 'compute':
try:
cells_rpcapi.CellsAPI().instance_fault_create_at_top(
context, db_fault)
except Exception:
LOG.exception(_LE("Failed to notify cells of instance fault"))
class InstanceFaultList(base.ObjectListBase, base.NovaObject):