Fix getting instance events on subsequent attempts
When the code for getting the list of events for a given instance was moved into the InstanceEvents object, an indenting error was introduced, which causes the get method to return None instead of the list if the instance already has some events waiting. This corrects that issue. Closes-bug: #1296808 Change-Id: I099a605980dd9c2ae0659b82c633caeb8a19bbe9
This commit is contained in:
parent
c032ab8696
commit
bdd064f95f
@ -447,8 +447,8 @@ class InstanceEvents(object):
|
|||||||
def _create_or_get_event():
|
def _create_or_get_event():
|
||||||
if instance.uuid not in self._events:
|
if instance.uuid not in self._events:
|
||||||
self._events.setdefault(instance.uuid, {})
|
self._events.setdefault(instance.uuid, {})
|
||||||
return self._events[instance.uuid].setdefault(
|
return self._events[instance.uuid].setdefault(
|
||||||
event_name, eventlet.event.Event())
|
event_name, eventlet.event.Event())
|
||||||
LOG.debug(_('Preparing to wait for external event %(event)s'),
|
LOG.debug(_('Preparing to wait for external event %(event)s'),
|
||||||
{'event': event_name}, instance=instance)
|
{'event': event_name}, instance=instance)
|
||||||
return _create_or_get_event()
|
return _create_or_get_event()
|
||||||
|
@ -1013,6 +1013,22 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||||||
self.compute.instance_events._events['foo']['test-event'])
|
self.compute.instance_events._events['foo']['test-event'])
|
||||||
self.assertTrue(hasattr(result, 'send'))
|
self.assertTrue(hasattr(result, 'send'))
|
||||||
|
|
||||||
|
def test_prepare_for_instance_event_again(self):
|
||||||
|
inst_obj = instance_obj.Instance(uuid='foo')
|
||||||
|
self.compute.instance_events.prepare_for_instance_event(
|
||||||
|
inst_obj, 'test-event')
|
||||||
|
# A second attempt will avoid creating a new list; make sure we
|
||||||
|
# get the current list
|
||||||
|
result = self.compute.instance_events.prepare_for_instance_event(
|
||||||
|
inst_obj, 'test-event')
|
||||||
|
self.assertIn('foo', self.compute.instance_events._events)
|
||||||
|
self.assertIn('test-event',
|
||||||
|
self.compute.instance_events._events['foo'])
|
||||||
|
self.assertEqual(
|
||||||
|
result,
|
||||||
|
self.compute.instance_events._events['foo']['test-event'])
|
||||||
|
self.assertTrue(hasattr(result, 'send'))
|
||||||
|
|
||||||
def test_process_instance_event(self):
|
def test_process_instance_event(self):
|
||||||
event = eventlet_event.Event()
|
event = eventlet_event.Event()
|
||||||
self.compute.instance_events._events = {
|
self.compute.instance_events._events = {
|
||||||
|
Loading…
Reference in New Issue
Block a user