def report_status()

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


def report_status():
    mode = hookenv.config()['spark_execution_mode']
    if (not is_state('spark.yarn.installed')) and mode.startswith('yarn'):
        # if hadoop isn't here at all, we're blocked; otherwise, we're waiting
        if is_state('hadoop.joined'):
            hookenv.status_set('waiting',
                               'waiting for yarn to become ready')
        else:
            hookenv.status_set('blocked',
                               'yarn execution mode not available')
        return

    if mode == 'standalone' and is_state('zookeeper.ready'):
        mode = mode + " - HA"
    elif mode == 'standalone' and is_state('leadership.is_leader'):
        mode = mode + " - master"

    if is_state('spark.cuda.configured'):
        mode = mode + " with CUDA"

    if is_state('spark.started'):
        # inform the user if we have a different repo pkg available
        repo_ver = unitdata.kv().get('spark.version.repo', False)
        if repo_ver:
            msg = "install version {} with the 'reinstall' action".format(repo_ver)
        else:
            msg = 'ready ({})'.format(mode)
        hookenv.status_set('active', msg)
    else:
        hookenv.status_set('blocked', 'unable to start spark ({})'.format(mode))