def get_existing_pool()

in src/hpcadvisor/batch_handler.py [0:0]


def get_existing_pool(sku, number_of_nodes):

    if not batch_client:
        log.critical("batch_client is None")
        return None

    log.info(f"Get existing pool for sku: {sku}")

    options = PoolListOptions(filter="state eq 'active'")

    batch_pools = batch_client.pool.list(pool_list_options=options)

    for pool in batch_pools:
        if (
            pool.vm_size.lower() == sku.lower()
            and pool.target_dedicated_nodes == number_of_nodes
        ):
            log.info(
                f"Reusing pool {pool.id} found with sku {sku} and nodes {number_of_nodes}"
            )
            return pool.id

    return None