コード例 #1
0
    def delete(self, name):
        """Delete cron trigger."""
        acl.enforce('cron_triggers:delete', context.ctx())

        LOG.info("Delete cron trigger [name=%s]" % name)

        triggers.delete_cron_trigger(name)
コード例 #2
0
    def delete(self, identifier):
        """Delete cron trigger.

        :param identifier: Id or name of cron trigger to delete
        """
        acl.enforce('cron_triggers:delete', context.ctx())

        LOG.debug("Delete cron trigger [identifier=%s]", identifier)

        triggers.delete_cron_trigger(identifier)
コード例 #3
0
    def delete(self, name):
        """Delete cron trigger.

        :param name: Name of cron trigger to delete
        """
        acl.enforce('cron_triggers:delete', context.ctx())

        LOG.info("Delete cron trigger [name=%s]", name)

        triggers.delete_cron_trigger(name)
コード例 #4
0
def advance_cron_trigger(t):
    modified_count = 0

    try:
        # If the cron trigger is defined with limited execution count.
        if t.remaining_executions is not None and t.remaining_executions > 0:
            t.remaining_executions -= 1

        # If this is the last execution.
        if t.remaining_executions == 0:
            modified_count = triggers.delete_cron_trigger(t.name,
                                                          trust_id=t.trust_id,
                                                          delete_trust=False)
        else:  # if remaining execution = None or > 0.
            # In case the we are lagging or if the api stopped for some time
            # we use the max of the current time or the next scheduled time.
            next_time = triggers.get_next_execution_time(
                t.pattern,
                max(datetime.datetime.utcnow(), t.next_execution_time))

            # Update the cron trigger with next execution details
            # only if it wasn't already updated by a different process.
            updated, modified_count = db_api_v2.update_cron_trigger(
                t.name, {
                    'next_execution_time': next_time,
                    'remaining_executions': t.remaining_executions
                },
                query_filter={'next_execution_time': t.next_execution_time})
    except exc.DBEntityNotFoundError as e:
        # Cron trigger was probably already deleted by a different process.
        LOG.debug("Cron trigger named '%s' does not exist anymore: %s", t.name,
                  str(e))

    # Return True if this engine was able to modify the cron trigger in DB.
    return modified_count > 0
コード例 #5
0
ファイル: periodic.py プロジェクト: openstack/mistral
def advance_cron_trigger(t):
    modified_count = 0

    try:
        # If the cron trigger is defined with limited execution count.
        if t.remaining_executions is not None and t.remaining_executions > 0:
            t.remaining_executions -= 1

        # If this is the last execution.
        if t.remaining_executions == 0:
            modified_count = triggers.delete_cron_trigger(
                t.name,
                trust_id=t.trust_id,
                delete_trust=False
            )
        else:  # if remaining execution = None or > 0.
            # In case the we are lagging or if the api stopped for some time
            # we use the max of the current time or the next scheduled time.
            next_time = triggers.get_next_execution_time(
                t.pattern,
                max(datetime.datetime.utcnow(), t.next_execution_time)
            )

            # Update the cron trigger with next execution details
            # only if it wasn't already updated by a different process.
            updated, modified_count = db_api_v2.update_cron_trigger(
                t.name,
                {
                    'next_execution_time': next_time,
                    'remaining_executions': t.remaining_executions
                },
                query_filter={
                    'next_execution_time': t.next_execution_time
                }
            )
    except exc.DBEntityNotFoundError as e:
        # Cron trigger was probably already deleted by a different process.
        LOG.debug(
            "Cron trigger named '%s' does not exist anymore: %s",
            t.name, str(e)
        )

    # Return True if this engine was able to modify the cron trigger in DB.
    return modified_count > 0