Exemplo n.º 1
0
def _start_cluster(count):
    try:
        iterations_left = int(count)
    except ValueError:
        print("FAILED TO START cluster: %s is not an integer" % count)
        return
    sorted_instances = sorted(INSTANCES.iteritems(), key=lambda (key, value): value.node_id)
    available_instances = filter(lambda (key, value): value.node.descriptor == '', sorted_instances)
    cluster_descriptor = _find_descriptor_by_max_key_of_running_instances(sorted_instances)
    for instance_name, instance in available_instances:
        if iterations_left == 0:
            break

        if cluster_descriptor == '':
            cluster_descriptor = instance.start_node()
        else:
            instance.start_node(cluster_descriptor)
            iterations_left -= 1
Exemplo n.º 2
0
def _start_daisy_chain(count):
    try:
        iterations_left = int(count)
    except ValueError:
        print("FAILED TO START daisy chain: %s is not an integer" % count)
        return

    next_descriptor = ''
    for node_name, instance in sorted(INSTANCES.iteritems()):
        if iterations_left == 0:
            break

        if node_name == 'node-0':
            if instance.node.descriptor == '':
                next_descriptor = instance.start_node()
                print('started node-0 %s' % next_descriptor)
            else:
                next_descriptor = instance.node.descriptor
        else:
            next_descriptor = instance.start_node(next_descriptor)
            print('started %s %s' % (node_name, next_descriptor))
            iterations_left -= 1