Beispiel #1
0
def spawn(data, cloud):
    """
    Generates the keypair and creates security groups specific to the
    cluster and boots the instances.

    @param data: The job document stored in mongo database.
    @type data: dict

    @param cloud: Cloud object containing information of a specific
    cloud provider.
    @type cloud: dict
    """

    image_id = cloud['default_image_id']

    data['job']['nodes'] = []
    data['job']['status'] = 'spawning'
    flush_data_to_mongo('job', data)

    job_name = data['job']['name']
    keypair_name, sec_master, sec_slave = ec2.ec2_entities(job_name)

    conn = ec2.make_connection(cloud['auth'])
    ec2.create_keypair(conn, keypair_name)
    ec2.create_security_groups(conn, sec_master, sec_slave)

    master = data['job']['master']

    res_master = ec2.boot_instances(
        conn,
        1,
        keypair_name,
        [sec_master],
        flavor = master['flavor'],
		image_id = image_id
        )

    data['job']['nodes'] += get_node_objects(conn, "master", res_master.id)
    flush_data_to_mongo('job', data)

    for slave in data['job']['slaves']:
        res_slave = ec2.boot_instances(
            conn,
            slave['instances'],
            keypair_name,
            [sec_slave],
            flavor = slave['flavor'],
			image_id = image_id
            )
        data['job']['nodes'] += get_node_objects(conn, "slave", res_slave.id)
        flush_data_to_mongo('job', data)

    return
Beispiel #2
0
def spawn(data, cloud):
    """
    Generates the keypair and creates security groups specific to the
    cluster and boots the instances.

    @param data: The job document stored in mongo database.
    @type data: dict

    @param cloud: Cloud object containing information of a specific
    cloud provider.
    @type cloud: dict
    """

    image_id = cloud['default_image_id']

    data['job']['nodes'] = []
    data['job']['status'] = 'spawning'
    flush_data_to_mongo('job', data)

    job_name = data['job']['name']
    keypair_name, sec_master, sec_slave = ec2.ec2_entities(job_name)

    conn = ec2.make_connection(cloud['auth'])
    ec2.create_keypair(conn, keypair_name)
    ec2.create_security_groups(conn, sec_master, sec_slave)

    master = data['job']['master']

    res_master = ec2.boot_instances(conn,
                                    1,
                                    keypair_name, [sec_master],
                                    flavor=master['flavor'],
                                    image_id=image_id)

    data['job']['nodes'] += get_node_objects(conn, "master", res_master.id)
    flush_data_to_mongo('job', data)

    for slave in data['job']['slaves']:
        res_slave = ec2.boot_instances(conn,
                                       slave['instances'],
                                       keypair_name, [sec_slave],
                                       flavor=slave['flavor'],
                                       image_id=image_id)
        data['job']['nodes'] += get_node_objects(conn, "slave", res_slave.id)
        flush_data_to_mongo('job', data)

    return
Beispiel #3
0
def add_nodes(data, cloud, job_id, general_config):
    """
    Add nodes to a cluster and updates the job object

    @param data: The job document stored in mongo database.
    @type data: dict

    @param cloud: Cloud object containing information of a specific
    cloud provider.
    @type cloud: dict

    @param job_id: Job ID
    @type job_id: string

    @param general_config: General config parameters of multistack
    @type general_config: dict
    """

    conn = ec2.make_connection(cloud['auth'])

    job_db_item = multistack.main.mongo.db.job.find_one({"_id": objectid.ObjectId(job_id)})
    job_obj = job_db_item['job']
    job_name = job_obj['name']
    new_node_obj_list = list()

    keypair_name, sec_master, sec_slave = ec2.ec2_entities(job_name)
    key_location = '/tmp/'  + keypair_name + '.pem'

    for slave in data['slaves']:
        res_slave = ec2.boot_instances(
                conn,
                slave['instances'],
                keypair_name,
                [sec_master],
                slave['flavor'],
                cloud['default_image_id']
                )

        # Incrementing the number of slaves in job object
        for count in range (0, len(job_obj['slaves'])):
            if slave['flavor'] == job_obj['slaves'][count]['flavor']:
                job_obj['slaves'][count]['instances'] += 1

        node_obj = get_node_objects(conn, "slave", res_slave.id)
        job_obj['nodes'] += node_obj
        new_node_obj_list += node_obj
        job_db_item['job'] = job_obj
        flush_data_to_mongo('job', job_db_item)

    for new_node_obj in new_node_obj_list:
        configure_slave(new_node_obj['ip_address'],
                        key_location, job_name, cloud['user'],
                        general_config['chef_server_hostname'],
                        general_config['chef_server_ip'])
Beispiel #4
0
def add_nodes(data, cloud, job_id, general_config):
    """
    Add nodes to a cluster and updates the job object

    @param data: The job document stored in mongo database.
    @type data: dict

    @param cloud: Cloud object containing information of a specific
    cloud provider.
    @type cloud: dict

    @param job_id: Job ID
    @type job_id: string

    @param general_config: General config parameters of multistack
    @type general_config: dict
    """

    conn = ec2.make_connection(cloud['auth'])

    job_db_item = multistack.main.mongo.db.job.find_one(
        {"_id": objectid.ObjectId(job_id)})
    job_obj = job_db_item['job']
    job_name = job_obj['name']
    new_node_obj_list = list()

    keypair_name, sec_master, sec_slave = ec2.ec2_entities(job_name)
    key_location = '/tmp/' + keypair_name + '.pem'

    for slave in data['slaves']:
        res_slave = ec2.boot_instances(conn, slave['instances'], keypair_name,
                                       [sec_master], slave['flavor'],
                                       cloud['default_image_id'])

        # Incrementing the number of slaves in job object
        for count in range(0, len(job_obj['slaves'])):
            if slave['flavor'] == job_obj['slaves'][count]['flavor']:
                job_obj['slaves'][count]['instances'] += 1

        node_obj = get_node_objects(conn, "slave", res_slave.id)
        job_obj['nodes'] += node_obj
        new_node_obj_list += node_obj
        job_db_item['job'] = job_obj
        flush_data_to_mongo('job', job_db_item)

    for new_node_obj in new_node_obj_list:
        configure_slave(new_node_obj['ip_address'], key_location, job_name,
                        cloud['user'], general_config['chef_server_hostname'],
                        general_config['chef_server_ip'])