Merge "Handle no nova CDM in notification code"
This commit is contained in:
commit
1e6ce53273
@ -279,5 +279,10 @@ class VersionedNotification(NovaNotification):
|
||||
metadata=metadata))
|
||||
func = self.notification_mapping.get(event_type)
|
||||
if func:
|
||||
LOG.debug(payload)
|
||||
func(self, payload)
|
||||
# The nova CDM is not built until an audit is performed.
|
||||
if self.cluster_data_model:
|
||||
LOG.debug(payload)
|
||||
func(self, payload)
|
||||
else:
|
||||
LOG.debug('Nova CDM has not yet been built; ignoring '
|
||||
'notifications until an audit is performed.')
|
||||
|
@ -743,3 +743,21 @@ class TestNovaNotifications(NotificationTestCase):
|
||||
|
||||
self.assertEqual(
|
||||
element.InstanceState.SUSPENDED.value, instance0.state)
|
||||
|
||||
def test_info_no_cdm(self):
|
||||
# Tests that a notification is received before an audit has been
|
||||
# performed which would create the nova CDM.
|
||||
mock_collector = mock.Mock(cluster_data_model=None)
|
||||
handler = novanotification.VersionedNotification(mock_collector)
|
||||
payload = {
|
||||
'nova_object.data': {
|
||||
'uuid': '9966d6bd-a45c-4e1c-9d57-3054899a3ec7',
|
||||
'host': None
|
||||
}
|
||||
}
|
||||
with mock.patch.object(handler, 'update_instance') as update_instance:
|
||||
handler.info(mock.sentinel.ctxt, 'publisher_id', 'instance.update',
|
||||
payload, metadata={})
|
||||
# update_instance should not be called since we did not add an
|
||||
# Instance object to the CDM since the CDM does not exist yet.
|
||||
update_instance.assert_not_called()
|
||||
|
Loading…
Reference in New Issue
Block a user