Пример #1
0
        def scheduler():
            """Lazily get scheduler"""
            if self.scheduler:
                return self.scheduler

            zkclient = context.GLOBAL.zk.conn
            self.scheduler = cron.get_scheduler(zkclient)

            return self.scheduler
Пример #2
0
def _do_watch(zkclient):
    """Actually do the children watch"""
    scheduler = cron.get_scheduler(zkclient)

    @zkclient.ChildrenWatch(z.CRON_JOBS)
    @utils.exit_on_unhandled
    def _new_cron_jobs(_children):
        """Children watch on new cron jobs"""
        _LOGGER.info(
            'Waking up the job scheduler, as children have changed'
        )
        scheduler.wakeup()
Пример #3
0
def start(job_id=None, app_name=None, count=1):
    """Start an application in the given cell"""
    _LOGGER.debug('app_name: %s', app_name)
    _LOGGER.debug('job_id: %s', job_id)
    _LOGGER.debug('count: %s', count)

    zkclient = context.GLOBAL.zk.conn
    scheduler = cron.get_scheduler(zkclient)

    job = scheduler.get_job(job_id)

    if not app_name:
        _LOGGER.error('No app name provided, cannot continue')
        return

    admin_app = admin.Application(context.GLOBAL.ldap.conn)

    configured = admin_app.get(app_name)

    if not configured:
        _LOGGER.info('App %s is not configured, pausing job %s', app_name,
                     job.id)
        job.pause()
        return

    instance_plugin = None
    try:
        instance_plugin = importlib.import_module(
            'treadmill.plugins.api.instance')
    except ImportError as err:
        _LOGGER.info('Unable to load auth plugin: %s', err)

    if instance_plugin:
        configured = instance_plugin.add_attributes(app_name, configured)

    if 'identity_group' not in configured:
        configured['identity_group'] = None

    if 'affinity' not in configured:
        configured['affinity'] = '{0}.{1}'.format(*app_name.split('.'))

    if '_id' in configured:
        del configured['_id']
    _LOGGER.info('Configured: %s %r', app_name, configured)

    scheduled = master.create_apps(zkclient, app_name, configured, count)
    _LOGGER.debug('scheduled: %r', scheduled)
Пример #4
0
        def _scheduler():
            """Lazily get scheduler"""

            zkclient = context.GLOBAL.zk.conn
            return cron.get_scheduler(zkclient)
Пример #5
0
 def cron_group():
     """Manage Treadmill cron jobs"""
     zkclient = context.GLOBAL.zk.conn
     ctx['scheduler'] = cron.get_scheduler(zkclient)