Esempio n. 1
0
def progressUpdate(clusterid):
    """Calculate the installing progress of given cluster.

    Args:
        clusterid: int, to updte installing progress of the cluster.

    Returns:
        None
    """
    progress_update.updateProgress(clusterid)
Esempio n. 2
0
def main(argv):
    """entry function."""
    global BUSY
    global KILLED
    clusterids = [
        int(clusterid) for clusterid in flags.OPTIONS.clusterids.split(',')
        if clusterid
    ]
    signal.signal(signal.SIGINT, handle_term)

    while True:
        BUSY = True
        with database.session() as session:
            if not clusterids:
                clusters = session.query(Cluster).all()
                update_clusterids = [cluster.id for cluster in clusters]
            else:
                update_clusterids = clusterids

        logging.info('update progress for clusters: %s', update_clusterids)
        for clusterid in update_clusterids:
            if flags.OPTIONS. async:
                celery.send_task('compass.tasks.progress_update',
                                 (clusterid, ))
            else:
                progress_update.updateProgress(clusterid)

        BUSY = False
        if KILLED:
            logging.info('exit progress update loop')
            break

        if flags.OPTIONS.once:
            logging.info('trigger installer finsished')
            break

        if flags.OPTIONS.run_interval > 0:
            logging.info('will rerun the trigger install after %s',
                         flags.OPTIONS.run_interval)
            time.sleep(flags.OPTIONS.run_interval)
        else:
            logging.info('rerun the trigger installer immediately')
Esempio n. 3
0
def main(argv):
    """entry function."""
    global BUSY
    global KILLED
    clusterids = [
        int(clusterid) for clusterid in flags.OPTIONS.clusterids.split(',')
        if clusterid
    ]
    signal.signal(signal.SIGINT, handle_term)

    while True:
        BUSY = True
        with database.session() as session:
            if not clusterids:
                clusters = session.query(Cluster).all()
                update_clusterids = [cluster.id for cluster in clusters]
            else:
                update_clusterids = clusterids

        logging.info('update progress for clusters: %s', update_clusterids)
        for clusterid in update_clusterids:
            if flags.OPTIONS.async:
                celery.send_task('compass.tasks.progress_update', (clusterid,))
            else:
                progress_update.updateProgress(clusterid)

        BUSY = False
        if KILLED:
            logging.info('exit progress update loop')
            break

        if flags.OPTIONS.once:
            logging.info('trigger installer finsished')
            break

        if flags.OPTIONS.run_interval > 0:
            logging.info('will rerun the trigger install after %s',
                         flags.OPTIONS.run_interval)
            time.sleep(flags.OPTIONS.run_interval)
        else:
            logging.info('rerun the trigger installer immediately')