def _notification_create_attributes(self, skip_uuid=False): notification_obj = notification.Notification(context=self.context) notification_obj.generated_time = NOW notification_obj.type = "COMPUTE_HOST" notification_obj.payload = {'fake_key': 'fake_value'} notification_obj.status = "new" if not skip_uuid: notification_obj.notification_uuid = uuidsentinel.fake_notification notification_obj.source_host_uuid = uuidsentinel.fake_host return notification_obj
def test_notify_about_notification_update(self, mock_from_exception, mock_NotificationApiPayload, mock_NotificationApiNotification, mock_NotificationPublisher, mock_EventType): mock_fault = mock.Mock() mock_from_exception.return_value = mock_fault mock_payload = mock.Mock() mock_NotificationApiPayload.return_value = mock_payload mock_engine_notification = mock.Mock() mock_NotificationApiNotification.return_value = ( mock_engine_notification) mock_engine_notification.emit.return_value = None mock_publisher = mock.Mock() mock_NotificationPublisher.return_value = mock_publisher mock_event_type = mock.Mock() mock_EventType.return_value = mock_event_type mock_context = mock.Mock() notification = notification_obj.Notification() action = fields.EventNotificationAction.NOTIFICATION_PROCESS phase = fields.EventNotificationPhase.ERROR e = Exception() engine_utils.notify_about_notification_update(mock_context, notification, action=action, phase=phase, exception=e) mock_from_exception.assert_called_once_with(e, None) mock_NotificationApiPayload.assert_called_once_with( notification=notification, fault=mock_fault) mock_NotificationApiNotification.assert_called_once_with( context=mock_context, priority=fields.EventNotificationPriority.ERROR, publisher=mock_publisher, event_type=mock_event_type, payload=mock_payload) mock_NotificationPublisher.assert_called_once_with( context=mock_context, host=socket.gethostname(), binary='masakari-engine') mock_engine_notification.emit.assert_called_once_with(mock_context)
def _make_notifications_list(notifications_list): return notification_obj.Notification( objects=[_make_notification_obj(a) for a in notifications_list])
def _make_notification_obj(notification_dict): return notification_obj.Notification(**notification_dict)
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. from masakari.notifications.objects import base from masakari.notifications.objects import exception from masakari.notifications.objects import notification as event_notification from masakari.objects import host as host_obj from masakari.objects import notification as notification_obj from masakari.objects import segment as segment_obj segment = segment_obj.FailoverSegment() host = host_obj.Host() notification = notification_obj.Notification() fault = None init_args = { event_notification.SegmentApiPayloadBase: [segment], event_notification.SegmentApiPayload: [segment, fault], event_notification.HostApiPayloadBase: [host], event_notification.HostApiPayload: [host, fault], event_notification.NotificationApiPayloadBase: [notification], event_notification.NotificationApiPayload: [notification, fault], event_notification.SegmentApiNotification: [], event_notification.HostApiNotification: [], event_notification.NotificationApiNotification: [], exception.ExceptionPayload: [], exception.ExceptionNotification: [], base.EventType: [],