Exemplo n.º 1
0
        def get(rsrc_id):
            """Get cron job configuration."""
            job = cron.get_job(_scheduler(), rsrc_id)
            _LOGGER.debug('job: %r', job)

            if job is None:
                return job

            return cron.job_to_dict(job)
Exemplo n.º 2
0
    def _list():
        """List out all cron events"""
        scheduler = ctx['scheduler']

        jobs = scheduler.get_jobs()

        job_dicts = [cron.job_to_dict(job) for job in jobs]
        _LOGGER.debug('job_dicts: %r', jobs)

        cli.out(_FORMATTER(job_dicts))
Exemplo n.º 3
0
        def update(rsrc_id, rsrc, pause=False, resume=False):
            """Update cron job configuration."""
            _LOGGER.info('update: %s %r', rsrc_id, rsrc)

            if pause:
                job = _scheduler().pause_job(rsrc_id)
                return cron.job_to_dict(job)

            if resume:
                job = _scheduler().resume_job(rsrc_id)
                return cron.job_to_dict(job)

            event = rsrc.get('event')
            resource = rsrc.get('resource')
            expression = rsrc.get('expression')
            count = rsrc.get('count')

            job = cron_model.update(_scheduler(), rsrc_id, event, resource,
                                    expression, count)
            _LOGGER.debug('job: %r', job)

            return cron.job_to_dict(job)
Exemplo n.º 4
0
        def _list(match=None):
            """List configured instances."""
            if match is None:
                match = '*'

            jobs = scheduler().get_jobs()
            _LOGGER.debug('jobs: %r', jobs)

            filtered = [
                cron.job_to_dict(job) for job in jobs
                if fnmatch.fnmatch(job.id, match)
            ]
            return sorted(filtered)
Exemplo n.º 5
0
    def configure(job_id, event, resource, expression, count):
        """Create or modify an existing app start schedule"""
        scheduler = ctx['scheduler']

        job = None
        try:
            job = cron_model.create(scheduler, job_id, event, resource,
                                    expression, count)
        except exc.FoundError:
            job = cron_model.update(scheduler, job_id, event, resource,
                                    expression, count)

        cli.out(_FORMATTER(cron.job_to_dict(job)))
Exemplo n.º 6
0
        def create(rsrc_id, rsrc):
            """Create cron job."""
            _LOGGER.info('create: %s %r', rsrc_id, rsrc)

            event = rsrc.get('event')
            resource = rsrc.get('resource')
            expression = rsrc.get('expression')
            count = rsrc.get('count')

            job = cron_model.create(_scheduler(), rsrc_id, event, resource,
                                    expression, count)
            _LOGGER.debug('job: %r', job)

            return cron.job_to_dict(job)
Exemplo n.º 7
0
        def update(rsrc_id, rsrc):
            """Update instance configuration."""
            _LOGGER.info('update: %s %r', rsrc_id, rsrc)

            event = rsrc.get('event')
            resource = rsrc.get('resource')
            expression = rsrc.get('expression')
            count = rsrc.get('count')

            job = cron_model.update(scheduler(), rsrc_id, event, resource,
                                    expression, count)
            _LOGGER.debug('job: %r', job)

            return cron.job_to_dict(job)
Exemplo n.º 8
0
        def _list(match=None, resource=None):
            """List configured cron jobs."""
            jobs = _scheduler().get_jobs()
            _LOGGER.debug('jobs: %r', jobs)

            filtered = []
            for job_obj in jobs:
                job = cron.job_to_dict(job_obj)
                if not match and not resource:
                    filtered.append(job)
                    continue
                if match and fnmatch.fnmatch(job['_id'], match):
                    filtered.append(job)
                if resource and fnmatch.fnmatch(job['resource'], resource):
                    filtered.append(job)

            return sorted(filtered, key=lambda item: item['_id'])
Exemplo n.º 9
0
        def get(rsrc_id):
            """Get instance configuration."""
            job = cron.get_job(scheduler(), rsrc_id)
            _LOGGER.debug('job: %r', job)

            return cron.job_to_dict(job)