Ejemplo n.º 1
0
def print_status(manager: PoolManager, args) -> None:
    sys.stdout.write('\n')
    print(
        f'Current status for the {manager.pool} pool in the {manager.cluster} cluster:\n'
    )
    print(
        f'Resource groups (target capacity: {manager.target_capacity}, fulfilled: {manager.fulfilled_capacity}, '
        f'non-orphan: {manager.non_orphan_fulfilled_capacity}):')

    node_metadatas = manager.get_node_metadatas() if args.verbose else {}

    for group in manager.resource_groups.values():
        _write_resource_group_line(group)
        for metadata in node_metadatas:
            if (metadata.instance.group_id != group.id
                    or (args.only_orphans
                        and metadata.agent.state != AgentState.ORPHANED) or
                (args.only_idle and metadata.agent.state != AgentState.IDLE)):
                continue
            _write_agent_details(metadata)

        sys.stdout.write('\n')

    _write_summary(manager)
    sys.stdout.write('\n')
Ejemplo n.º 2
0
def _status_json(manager: PoolManager, get_node_metadatas: bool) -> StatusJsonObject:
    node_metadatas = manager.get_node_metadatas() if get_node_metadatas else []
    return {
        'disabled': autoscaling_is_paused(manager.cluster, manager.pool, manager.scheduler, arrow.now()),
        'target_capacity': manager.target_capacity,
        'fulfilled_capacity': manager.fulfilled_capacity,
        'non_orphan_fulfilled_capacity': manager.non_orphan_fulfilled_capacity,
        'resource_groups': _get_resource_groups_json(manager.resource_groups.values(), node_metadatas),
    }