Exemplo n.º 1
0
def handle_delete_rule(rule_name):
    rule_scheduled_jobs = EventsBackend.get().rule_scheduled_jobs
    job_id = rule_scheduled_jobs.get(rule_name)
    if job_id:
        LOG.debug("Removing scheduled Events: {} | job_id: {}".format(
            rule_name, job_id))
        JobScheduler.instance().cancel_job(job_id=job_id)
Exemplo n.º 2
0
def handle_delete_rule(rule_name):
    region = aws_stack.get_region()
    job_id = RULE_SCHEDULED_JOBS.get(region, {}).get(rule_name)
    if job_id:
        LOG.debug('Removing scheduled Events: {} | job_id: {}'.format(
            rule_name, job_id))
        JobScheduler.instance().cancel_job(job_id=job_id)
Exemplo n.º 3
0
 def disable_rule(
     self, context: RequestContext, name: RuleName, event_bus_name: EventBusNameOrArn = None
 ) -> None:
     rule_scheduled_jobs = EventsBackend.get().rule_scheduled_jobs
     job_id = rule_scheduled_jobs.get(name)
     if job_id:
         LOG.debug("Disabling Rule: {} | job_id: {}".format(name, job_id))
         JobScheduler.instance().disable_job(job_id=job_id)
     call_moto(context)
Exemplo n.º 4
0
 def delete_rule(
     self,
     context: RequestContext,
     name: RuleName,
     event_bus_name: EventBusNameOrArn = None,
     force: Boolean = None,
 ) -> None:
     rule_scheduled_jobs = EventsBackend.get().rule_scheduled_jobs
     job_id = rule_scheduled_jobs.get(name)
     if job_id:
         LOG.debug("Removing scheduled Events: {} | job_id: {}".format(name, job_id))
         JobScheduler.instance().cancel_job(job_id=job_id)
     call_moto(context)
Exemplo n.º 5
0
def put_rule(data):
    schedule = data.get('ScheduleExpression')
    if schedule:
        job_func = get_scheduled_rule_func(data)
        cron = convert_schedule_to_cron(schedule)
        LOG.debug('Adding new scheduled Events rule with cron schedule %s' %
                  cron)
        # TODO cancel job later on if DeleteRule API call is received
        job_id = JobScheduler.instance().add_job(job_func, cron)
        RULE_SCHEDULED_JOBS[job_id] = data
    return True
Exemplo n.º 6
0
def handle_put_rule(data):
    schedule = data.get('ScheduleExpression')
    if schedule:
        job_func = get_scheduled_rule_func(data)
        cron = convert_schedule_to_cron(schedule)
        LOG.debug('Adding new scheduled Events rule with cron schedule %s' % cron)

        job_id = JobScheduler.instance().add_job(job_func, cron)
        region = aws_stack.get_region()
        RULE_SCHEDULED_JOBS[region] = RULE_SCHEDULED_JOBS.get(region) or {}
        RULE_SCHEDULED_JOBS[region][data['Name']] = job_id

    return True
Exemplo n.º 7
0
def handle_put_rule(data):
    schedule = data.get("ScheduleExpression")
    enabled = data.get("State") != "DISABLED"

    if schedule:
        job_func = get_scheduled_rule_func(data)
        cron = convert_schedule_to_cron(schedule)
        LOG.debug("Adding new scheduled Events rule with cron schedule %s" % cron)

        job_id = JobScheduler.instance().add_job(job_func, cron, enabled)
        rule_scheduled_jobs = EventsBackend.get().rule_scheduled_jobs
        rule_scheduled_jobs[data["Name"]] = job_id

    return True
Exemplo n.º 8
0
    def put_rule_job_scheduler(
        name: Optional[RuleName],
        state: Optional[RuleState],
        schedule_expression: Optional[ScheduleExpression],
    ):
        enabled = state != "DISABLED"
        if schedule_expression:
            job_func = EventsProvider.get_scheduled_rule_func(name)
            cron = EventsProvider.convert_schedule_to_cron(schedule_expression)
            LOG.debug("Adding new scheduled Events rule with cron schedule %s", cron)

            job_id = JobScheduler.instance().add_job(job_func, cron, enabled)
            rule_scheduled_jobs = EventsBackend.get().rule_scheduled_jobs
            rule_scheduled_jobs[name] = job_id
Exemplo n.º 9
0
def handle_disable_rule(rule_name):
    rule_scheduled_jobs = EventsBackend.get().rule_scheduled_jobs
    job_id = rule_scheduled_jobs.get(rule_name)
    if job_id:
        LOG.debug("Disabling Rule: {} | job_id: {}".format(rule_name, job_id))
        JobScheduler.instance().disable_job(job_id=job_id)
Exemplo n.º 10
0
def handle_disable_rule(rule_name):
    region = aws_stack.get_region()
    job_id = RULE_SCHEDULED_JOBS.get(region, {}).get(rule_name)
    if job_id:
        LOG.debug('Disabling Rule: {} | job_id: {}'.format(rule_name, job_id))
        JobScheduler.instance().disable_job(job_id=job_id)