Exemplo n.º 1
0
    def _start_greenthread(self):
        # Find the first time.
        # We don't known when using this trigger first time.
        timer, first_run_time = self._get_timer_and_first_run_time(
            self._trigger_property)
        if not first_run_time:
            raise exception.TriggerIsInvalid(trigger_id=self._id)

        self._create_green_thread(first_run_time, timer)
Exemplo n.º 2
0
    def test_create_operation_receive_invalid_except(self):
        self.remote_operation_api._create_operation_exception =\
            exception.TriggerIsInvalid(trigger_id=None)

        param = self.default_create_operation_param.copy()
        body = self._get_create_operation_request_body(param)
        self.assertRaises(exc.HTTPBadRequest, self.controller.create, self.req,
                          body)

        self.remote_operation_api._create_operation_exception = None
Exemplo n.º 3
0
    def _start_greenthread(self):
        # Find the first time.
        # We don't known when using this trigger first time.
        timer = self._get_timer(self._trigger_property)
        first_run_time = self._compute_next_run_time(
            datetime.utcnow(), self._trigger_property['end_time'], timer)
        if not first_run_time:
            raise exception.TriggerIsInvalid(trigger_id=self._id)

        self._create_green_thread(first_run_time, timer)
Exemplo n.º 4
0
    def register_operation(self, operation_id, **kwargs):
        if operation_id in self._operation_ids:
            msg = (_("The operation_id(%s) is exist") % operation_id)
            raise exception.ScheduledOperationExist(msg)

        if self._greenthread and not self._greenthread.running:
            raise exception.TriggerIsInvalid(trigger_id=self._id)

        self._operation_ids.add(operation_id)
        if self._greenthread is None:
            self._start_greenthread()