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'])
Exemple #2
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
    """

    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()

    initiate_cloud(cloud['provider'], job_name, cloud['auth'])

    key_location = '/tmp/'  + current_app.cloud.keypair + '.pem'

    for slave in data['slaves']:
        res_slave = current_app.cloud.boot_instances(
                slave['instances'],
                current_app.cloud.keypair,
                [current_app.cloud.slave_security_group],
                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("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:
        slave_public_ip = current_app.cloud.associate_public_ip(new_node_obj['id'])
        configure_slave(slave_public_ip,
                        key_location, job_name, cloud['user'],
                        general_config['chef_server_hostname'],
                        general_config['chef_server_ip'])
        current_app.cloud.release_public_ip(slave_public_ip)
Exemple #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
    """

    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()

    initiate_cloud(cloud['provider'], job_name, cloud['auth'])

    key_location = '/tmp/' + current_app.cloud.keypair + '.pem'

    for slave in data['slaves']:
        res_slave = current_app.cloud.boot_instances(
            slave['instances'], current_app.cloud.keypair,
            [current_app.cloud.slave_security_group], 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("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:
        slave_public_ip = current_app.cloud.associate_public_ip(
            new_node_obj['id'])
        configure_slave(slave_public_ip, key_location, job_name, cloud['user'],
                        general_config['chef_server_hostname'],
                        general_config['chef_server_ip'])
        current_app.cloud.release_public_ip(slave_public_ip)
Exemple #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'])