def get_available_instance_w_most_containers(cluster, max_containers): """ JOB_ITEM_CONTAINERS_PER_INSTANCE Place the container on the instance that's nearly full This way less-active instances will free-up more frequently """ instance_ids = ecs.get_instance_ids_in_cluster(cluster) if len(instance_ids) == 0: return None max_count = 0 max_instance_id = None for instance_id in instance_ids: count = ecs.get_task_count_on_instance(cluster, instance_id) if count >= max_containers: pass elif count >= max_count: max_count = count max_instance_id = instance_id return max_instance_id
def test_describe_instances(cluster): instance_ids = ecs.get_instance_ids_in_cluster(cluster) assert instance_ids is not None if len(instance_ids) > 0: instances = ecs.describe_instances(cluster, instance_ids) assert instances is not None
def test_get_instance_ids_in_cluster(cluster): ids = ecs.get_instance_ids_in_cluster(cluster) print "INSTANCE_IDS IN CLUSTER: " + str(ids) assert ids is not None