コード例 #1
0
ファイル: kill.py プロジェクト: pschorf/Cook
 def __kill(cluster, uuids, kill_fn, entity_type):
     if len(uuids) > 0:
         for uuid_batch in partition(uuids, kill_batch_size):
             success = kill_fn(cluster, uuid_batch)
             batch = [{
                 'cluster': cluster,
                 'type': entity_type,
                 'uuid': u
             } for u in uuid_batch]
             (succeeded if success else failed).extend(batch)
コード例 #2
0
ファイル: querying.py プロジェクト: murraju/Cook
def query_cluster(cluster, uuids, pred, timeout, interval, make_request_fn, entity_type):
    """Delegates to __query_cluster in batches of at most 100 UUIDs and combines the results"""
    if len(uuids) == 0:
        return []

    # Cook will give us back two copies if the user asks for the same UUID twice, e.g.
    # $ cs show d38ea6bd-8a26-4ddf-8a93-5926fa2991ce d38ea6bd-8a26-4ddf-8a93-5926fa2991ce
    # Prevent this by calling distinct:
    uuids = distinct(uuids)

    entities = []
    query_batch_size = 100
    for uuid_batch in partition(uuids, query_batch_size):
        entity_batch = __query_cluster(cluster, uuid_batch, pred, timeout, interval, make_request_fn, entity_type)
        entities.extend(entity_batch)
    return entities