Example #1
0
 def _notify_node_action(cls, ctx, level, node, action, **kwargs):
     action_name = cls._get_action_name(action.action)
     priority = utils.level_from_number(level).lower()
     publisher = nobj.NotificationPublisher(host=cfg.CONF.host,
                                            binary='senlin-engine')
     publisher.obj_set_defaults()
     phase = kwargs.get('phase')
     event_type = nobj.EventType(object='node',
                                 action=action_name,
                                 phase=phase)
     payload = nobj.NodeActionPayload(node, action)
     notification = nobj.NodeActionNotification(context=ctx,
                                                priority=priority,
                                                publisher=publisher,
                                                event_type=event_type,
                                                payload=payload)
     notification.emit(ctx)
Example #2
0
    def test_emit_with_host_and_binary_as_publisher(self, mock_notifier):
        event_type = notification.EventType(
            object='test_object', action=fields.NotificationAction.UPDATE)
        publisher = notification.NotificationPublisher(host='fake-host',
                                                       binary='senlin-fake')

        noti = TestNotification(event_type=event_type,
                                publisher=publisher,
                                priority=fields.NotificationPriority.INFO,
                                payload=self.payload)

        mock_context = mock.Mock()
        mock_context.to_dict.return_value = {}
        noti.emit(mock_context)

        self._verify_notification(mock_notifier,
                                  mock_context,
                                  expected_event_type='test_object.update',
                                  expected_payload=self.expected_payload)