@staticmethod
def availability_by_allocations(allocations):
    """Takes any iterator with alloctions and calculates the availability.
        Counts missing mirrors as 100% free and returns a value between 0-100
        in any case.
        For single allocations check the allocation.availability property.

        """
    total, expected_count, count = 0, 0, 0
    for allocation in allocations:
        total += allocation.availability
        count += 1
        if allocation.is_master:
            expected_count += allocation.quota
    if not expected_count:
        return 0
    missing = expected_count - count
    total += missing * 100
    return total / expected_count
