Esempio n. 1
0
    def test_create(self):
        payload = base.ClusterActionPayload(cluster=self.cluster,
                                            action=self.action)

        sot = base.ClusterActionNotification(payload=payload)

        self.assertTrue(sot.obj_attr_is_set('payload'))
Esempio n. 2
0
    def test_create_with_no_exc(self):
        ex = None
        sot = base.ClusterActionPayload(cluster=self.cluster,
                                        action=self.action,
                                        exception=ex)

        self.assertTrue(sot.obj_attr_is_set('cluster'))
        self.assertTrue(sot.obj_attr_is_set('action'))
        self.assertTrue(sot.obj_attr_is_set('exception'))
        self.assertIsNone(sot.exception)
Esempio n. 3
0
    def test_create(self):
        exobj = None
        try:
            {}['key']
        except Exception:
            ex = exception.InvalidSpec(message='boom')
            exobj = base.ExceptionPayload.from_exception(ex)

        sot = base.ClusterActionPayload(cluster=self.cluster,
                                        action=self.action,
                                        exception=exobj)

        self.assertTrue(sot.obj_attr_is_set('cluster'))
        self.assertTrue(sot.obj_attr_is_set('action'))
        self.assertTrue(sot.obj_attr_is_set('exception'))
        self.assertIsNotNone(sot.exception)
Esempio n. 4
0
 def _notify_cluster_action(cls, ctx, level, cluster, 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='cluster',
                                 action=action_name,
                                 phase=phase)
     payload = nobj.ClusterActionPayload(cluster, action)
     notification = nobj.ClusterActionNotification(context=ctx,
                                                   priority=priority,
                                                   publisher=publisher,
                                                   event_type=event_type,
                                                   payload=payload)
     notification.emit(ctx)