Merge "Remove 'instance_fault_create_at_top'"
This commit is contained in:
commit
be1ff9188b
@ -236,10 +236,6 @@ class CellsManager(manager.Manager):
|
||||
self.msg_runner.instance_delete_everywhere(ctxt, instance,
|
||||
delete_type)
|
||||
|
||||
def instance_fault_create_at_top(self, ctxt, instance_fault):
|
||||
"""Create an instance fault at the top level cell."""
|
||||
self.msg_runner.instance_fault_create_at_top(ctxt, instance_fault)
|
||||
|
||||
def bw_usage_update_at_top(self, ctxt, bw_update_info):
|
||||
"""Update bandwidth usage at top level cell."""
|
||||
self.msg_runner.bw_usage_update_at_top(ctxt, bw_update_info)
|
||||
|
@ -1084,18 +1084,6 @@ class _BroadcastMessageMethods(_BaseMessageMethods):
|
||||
else:
|
||||
self.compute_api.delete(message.ctxt, instance)
|
||||
|
||||
def instance_fault_create_at_top(self, message, instance_fault, **kwargs):
|
||||
"""Destroy an instance from the DB if we're a top level cell."""
|
||||
if not self._at_the_top():
|
||||
return
|
||||
items_to_remove = ['id']
|
||||
for key in items_to_remove:
|
||||
instance_fault.pop(key, None)
|
||||
LOG.debug("Got message to create instance fault: %s", instance_fault)
|
||||
fault = objects.InstanceFault(context=message.ctxt)
|
||||
fault.update(instance_fault)
|
||||
fault.create()
|
||||
|
||||
def bw_usage_update_at_top(self, message, bw_update_info, **kwargs):
|
||||
"""Update Bandwidth usage in the DB if we're a top level cell."""
|
||||
if not self._at_the_top():
|
||||
@ -1406,14 +1394,6 @@ class MessageRunner(object):
|
||||
run_locally=False)
|
||||
message.process()
|
||||
|
||||
def instance_fault_create_at_top(self, ctxt, instance_fault):
|
||||
"""Create an instance fault at the top level cell."""
|
||||
message = _BroadcastMessage(self, ctxt,
|
||||
'instance_fault_create_at_top',
|
||||
dict(instance_fault=instance_fault),
|
||||
'up', run_locally=False)
|
||||
message.process()
|
||||
|
||||
def bw_usage_update_at_top(self, ctxt, bw_update_info):
|
||||
"""Update bandwidth usage at top level cell."""
|
||||
message = _BroadcastMessage(self, ctxt, 'bw_usage_update_at_top',
|
||||
|
@ -234,12 +234,6 @@ class CellsAPI(object):
|
||||
cctxt.cast(ctxt, 'instance_delete_everywhere', instance=instance,
|
||||
delete_type=delete_type)
|
||||
|
||||
def instance_fault_create_at_top(self, ctxt, instance_fault):
|
||||
"""Create an instance fault at the top."""
|
||||
instance_fault_p = jsonutils.to_primitive(instance_fault)
|
||||
self.client.cast(ctxt, 'instance_fault_create_at_top',
|
||||
instance_fault=instance_fault_p)
|
||||
|
||||
def bw_usage_update_at_top(self, ctxt, uuid, mac, start_period,
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out, last_refreshed=None):
|
||||
"""Broadcast upwards that bw_usage was updated."""
|
||||
|
@ -16,8 +16,6 @@ import itertools
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from nova.cells import opts as cells_opts
|
||||
from nova.cells import rpcapi as cells_rpcapi
|
||||
from nova.db import api as db
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
@ -78,16 +76,6 @@ class InstanceFault(base.NovaPersistentObject, base.NovaObject,
|
||||
db_fault = db.instance_fault_create(self._context, values)
|
||||
self._from_db_object(self._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(
|
||||
self._context, db_fault)
|
||||
except Exception:
|
||||
LOG.exception("Failed to notify cells of instance fault")
|
||||
|
||||
|
||||
@base.NovaObjectRegistry.register
|
||||
|
@ -187,15 +187,6 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
|
||||
self.ctxt, instance='fake-instance',
|
||||
delete_type='fake-type')
|
||||
|
||||
def test_instance_fault_create_at_top(self):
|
||||
self.mox.StubOutWithMock(self.msg_runner,
|
||||
'instance_fault_create_at_top')
|
||||
self.msg_runner.instance_fault_create_at_top(self.ctxt,
|
||||
'fake-fault')
|
||||
self.mox.ReplayAll()
|
||||
self.cells_manager.instance_fault_create_at_top(
|
||||
self.ctxt, instance_fault='fake-fault')
|
||||
|
||||
def test_bw_usage_update_at_top(self):
|
||||
self.mox.StubOutWithMock(self.msg_runner,
|
||||
'bw_usage_update_at_top')
|
||||
|
@ -1620,29 +1620,6 @@ class CellsBroadcastMethodsTestCase(test.NoDBTestCase):
|
||||
self.src_msg_runner.instance_delete_everywhere(self.ctxt,
|
||||
instance, 'soft')
|
||||
|
||||
def test_instance_fault_create_at_top(self):
|
||||
fake_instance_fault = {'id': 1,
|
||||
'message': 'fake-message',
|
||||
'details': 'fake-details'}
|
||||
|
||||
if_mock = mock.Mock(spec_set=objects.InstanceFault)
|
||||
|
||||
def _check_create():
|
||||
self.assertEqual('fake-message', if_mock.message)
|
||||
self.assertEqual('fake-details', if_mock.details)
|
||||
# Should not be set
|
||||
self.assertNotEqual(1, if_mock.id)
|
||||
|
||||
if_mock.create.side_effect = _check_create
|
||||
|
||||
with mock.patch.object(objects, 'InstanceFault') as if_obj_mock:
|
||||
if_obj_mock.return_value = if_mock
|
||||
self.src_msg_runner.instance_fault_create_at_top(
|
||||
self.ctxt, fake_instance_fault)
|
||||
|
||||
if_obj_mock.assert_called_once_with(context=self.ctxt)
|
||||
if_mock.create.assert_called_once_with()
|
||||
|
||||
def test_bw_usage_update_at_top(self):
|
||||
fake_bw_update_info = {'uuid': 'fake_uuid',
|
||||
'mac': 'fake_mac',
|
||||
|
@ -199,19 +199,6 @@ class CellsAPITestCase(test.NoDBTestCase):
|
||||
self._check_result(call_info, 'instance_delete_everywhere',
|
||||
expected_args, version='1.27')
|
||||
|
||||
def test_instance_fault_create_at_top(self):
|
||||
fake_instance_fault = {'id': 2,
|
||||
'other': 'meow'}
|
||||
|
||||
call_info = self._stub_rpc_method('cast', None)
|
||||
|
||||
self.cells_rpcapi.instance_fault_create_at_top(
|
||||
self.fake_context, fake_instance_fault)
|
||||
|
||||
expected_args = {'instance_fault': fake_instance_fault}
|
||||
self._check_result(call_info, 'instance_fault_create_at_top',
|
||||
expected_args)
|
||||
|
||||
def test_bw_usage_update_at_top(self):
|
||||
update_args = ('fake_uuid', 'fake_mac', 'fake_start_period',
|
||||
'fake_bw_in', 'fake_bw_out', 'fake_ctr_in',
|
||||
|
@ -72,9 +72,8 @@ class _TestInstanceFault(object):
|
||||
self.assertEqual(0, len(faults))
|
||||
get_mock.assert_called_once_with(self.context, ['fake-uuid'])
|
||||
|
||||
@mock.patch('nova.cells.rpcapi.CellsAPI.instance_fault_create_at_top')
|
||||
@mock.patch('nova.db.api.instance_fault_create')
|
||||
def _test_create(self, update_cells, mock_create, cells_fault_create):
|
||||
def test_create(self, mock_create):
|
||||
mock_create.return_value = fake_faults['fake-uuid'][1]
|
||||
fault = instance_fault.InstanceFault(context=self.context)
|
||||
fault.instance_uuid = uuids.faults_instance
|
||||
@ -90,23 +89,6 @@ class _TestInstanceFault(object):
|
||||
'message': 'foo',
|
||||
'details': 'you screwed up',
|
||||
'host': 'myhost'})
|
||||
if update_cells:
|
||||
cells_fault_create.assert_called_once_with(
|
||||
self.context, fake_faults['fake-uuid'][1])
|
||||
else:
|
||||
self.assertFalse(cells_fault_create.called)
|
||||
|
||||
def test_create_no_cells(self):
|
||||
self.flags(enable=False, group='cells')
|
||||
self._test_create(False)
|
||||
|
||||
def test_create_api_cell(self):
|
||||
self.flags(cell_type='api', enable=True, group='cells')
|
||||
self._test_create(False)
|
||||
|
||||
def test_create_compute_cell(self):
|
||||
self.flags(cell_type='compute', enable=True, group='cells')
|
||||
self._test_create(True)
|
||||
|
||||
def test_create_already_created(self):
|
||||
fault = instance_fault.InstanceFault(context=self.context)
|
||||
|
Loading…
x
Reference in New Issue
Block a user