def update_status()

in bigtop-packages/src/charm/zeppelin/layer-zeppelin/reactive/zeppelin.py [0:0]


def update_status():
    hadoop_joined = is_state('hadoop.joined')
    hadoop_ready = is_state('hadoop.ready')
    hive_joined = is_state('hive.joined')
    hive_ready = is_state('hive.ready')
    spark_joined = is_state('spark.joined')
    spark_ready = is_state('spark.ready')
    spark_blocked = is_state('spark.master.unusable')

    # handle blockers first; then report what's ready/waiting
    if spark_blocked:
        hookenv.status_set('blocked',
                           'remote spark must be in standalone mode')
    else:
        waiting_apps = []
        ready_apps = []
        # Check status of the hadoop plugin
        if hadoop_joined and not hadoop_ready:
            waiting_apps.append('hadoop')
        elif hadoop_ready:
            ready_apps.append('hadoop')

        # Check status of Hive
        if hive_joined and not hive_ready:
            waiting_apps.append('hive')
        elif hive_ready:
            ready_apps.append('hive')

        # Check status of Spark
        if spark_joined and not spark_ready:
            waiting_apps.append('spark')
        elif spark_ready:
            ready_apps.append('spark')

        # Set appropriate status
        repo_ver = unitdata.kv().get('zeppelin.version.repo', False)
        if repo_ver:
            # Pending upgrade takes precedent over other status messages
            msg = "install version {} with the 'reinstall' action".format(repo_ver)
            hookenv.status_set('active', msg)
        elif waiting_apps:
            # Waiting takes precedent over active status messages
            msg = "waiting for: {}".format(' & '.join(waiting_apps))
            hookenv.status_set('waiting', msg)
        elif ready_apps:
            msg = "ready with: {}".format(' & '.join(ready_apps))
            hookenv.status_set('active', msg)
        else:
            hookenv.status_set('active', 'ready')