Only consider the last interesting event when checking traits.

Was previously looking at the last .start event when
comparing important traits against the .exists event.
Now it will look at the last important .end event it found (if any).

For delete operations, it will be the last event in the chain.
This may need to change to a specific event as well, like
compute.instance.delete.end or something.

Change-Id: Ie85e69716cd730c3546d06bae28e52e0c301940f
This commit is contained in:
Sandy Walsh 2015-04-17 07:39:44 -07:00
parent 775256d6b1
commit a2710a98d9
3 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
[metadata]
description-file = README.md
name = winchester
version = 0.54
version = 0.55
author = Monsyne Dragon
author_email = mdragon@rackspace.com
summary = An OpenStack notification event processing library.

View File

@ -268,7 +268,7 @@ class TestUsageHandler(unittest.TestCase):
@mock.patch.object(pipeline_handler.UsageHandler, '_find_deleted_events')
@mock.patch.object(pipeline_handler.UsageHandler, '_confirm_delete')
def test_do_check_interesting(self, cd, fde, inee, vf, gcf, cla):
block = [{'event_type': 'compute.instance.rebuild.start',
block = [{'event_type': 'compute.instance.rebuild.end',
'message_id': 1}]
exists = {'event_type': 'compute.instance.exists',
'message_id': 2}

View File

@ -291,7 +291,7 @@ class UsageHandler(PipelineHandlerBase):
raise UsageException("U7", "Multiple .delete.end events")
if delete_events:
self._verify_fields(exists, delete_events[0], fields)
self._verify_fields(exists, delete_events[-1], fields)
def _confirm_launched_at(self, block, exists):
if exists.get('state') != 'active':
@ -319,9 +319,9 @@ class UsageHandler(PipelineHandlerBase):
'os_architecture', 'os_version', 'os_distro']
def _do_checks(self, block, exists):
interesting = ['compute.instance.rebuild.start',
'compute.instance.resize.prep.start',
'compute.instance.rescue.start']
interesting = ['compute.instance.rebuild.end',
'compute.instance.resize.prep.end',
'compute.instance.rescue.end']
self._confirm_launched_at(block, exists)