def launch_server(environment, group, subnet_id, instance_type,
                  availability_zone, replica_set, data_volume_size,
                  data_volume_iops, journal_volume_size, journal_volume_iops,
                  log_volume_size, log_volume_iops, mongodb_package_version,
                  node_type, replica_set_template):

    log.debug('Preparing to launch a new node')

    node = None

    if node_type == 'data':
        node = MongoDataNode(group=group,
                             instance_type=instance_type,
                             environment=environment,
                             subnet_id=subnet_id,
                             availability_zone=availability_zone,
                             replica_set=replica_set,
                             data_volume_size=data_volume_size,
                             data_volume_iops=data_volume_iops,
                             journal_volume_size=journal_volume_size,
                             journal_volume_iops=journal_volume_iops,
                             log_volume_size=log_volume_size,
                             log_volume_iops=log_volume_iops,
                             mongodb_version=mongodb_package_version)

    elif node_type == 'datawarehousing':
        node = MongoDataWarehousingNode(
            group=group,
            instance_type=instance_type,
            environment=environment,
            subnet_id=subnet_id,
            availability_zone=availability_zone,
            replica_set=replica_set,
            data_volume_size=data_volume_size,
            mongodb_version=mongodb_package_version)
    elif node_type == 'arbiter':
        node = MongoArbiterNode(group=group,
                                instance_type=instance_type,
                                environment=environment,
                                subnet_id=subnet_id,
                                availability_zone=availability_zone,
                                replica_set=replica_set,
                                mongodb_version=mongodb_package_version)

    if replica_set_template is not None:
        node.REPLICA_SET_TEMPLATE = replica_set_template

    log.debug('Launching the node using autorun()')
    node.autorun()

    log.debug('Waiting until chef-client has finished running to proceed')
    baked = node.baked()

    if baked:
        return node

    else:
        log.critical('chef-client failed to finish running')
        sys.exit(1)
Exemple #2
0
    def provision(self):

        zones = 'cde'

        self.log.info('Building availability zone list')

        while len(zones) < (self.data_nodes+1):

            zones += zones

        self.log.info('Provisioning MongoDB Data Nodes')

        i = 0

        for i in range(self.data_nodes):

            node = MongoDataNode(group=self.group,
                                 server_type=self.server_type,
                                 instance_type=self.instance_type,
                                 environment=self.environment,
                                 ami=self.ami, region=self.region,
                                 role=self.role, keypair=self.keypair,
                                 chef_path=self.chef_path,
                                 replica_set=self.replica_set,
                                 security_groups=self.security_groups,
                                 block_devices=self.block_devices,
                                 availability_zone=zones[i],
                                 data_volume_size=self.data_volume_size,
                                 data_volume_iops=self.data_volume_iops,
                                 mongodb_version=self.mongodb_version)

            node.autorun()

            self.nodes.append(node)

        if (self.data_nodes % 2) == 0:

            self.log.info('Including Arbiter Node')

            node = MongoArbiterNode(group=self.group,
                                    server_type=self.server_type,
                                    instance_type=self.instance_type,
                                    environment=self.environment,
                                    ami=self.ami, region=self.region,
                                    role=self.role, keypair=self.keypair,
                                    chef_path=self.chef_path,
                                    replica_set=self.replica_set,
                                    security_groups=self.security_groups,
                                    block_devices=self.block_devices,
                                    availability_zone=zones[i+1],
                                    mongodb_version=self.mongodb_version)

            node.autorun()

            self.nodes.append(node)
Exemple #3
0
def launch_server(environment, group, subnet_id, instance_type,
                  availability_zone, replica_set, data_volume_size,
                  data_volume_iops, mongodb_package_version, node_type,
                  replica_set_template):

    log.debug('Preparing to launch a new node')

    node = None

    if node_type == 'data':
        node = MongoDataNode(group=group, instance_type=instance_type,
                             environment=environment,
                             subnet_id=subnet_id,
                             availability_zone=availability_zone,
                             replica_set=replica_set,
                             data_volume_size=data_volume_size,
                             data_volume_iops=data_volume_iops,
                             mongodb_version=mongodb_package_version)

    elif node_type == 'datawarehousing':
        node = MongoDataWarehousingNode(group=group,
                                        instance_type=instance_type,
                                        environment=environment,
                                        subnet_id=subnet_id,
                                        availability_zone=availability_zone,
                                        replica_set=replica_set,
                                        data_volume_size=data_volume_size,
                                        mongodb_version=mongodb_package_version
                                        )
    elif node_type == 'arbiter':
        node = MongoArbiterNode(group=group, instance_type=instance_type,
                                environment=environment,
                                subnet_id=subnet_id,
                                availability_zone=availability_zone,
                                replica_set=replica_set,
                                mongodb_version=mongodb_package_version)

    if replica_set_template is not None:
        node.REPLICA_SET_TEMPLATE = replica_set_template

    log.debug('Launching the node using autorun()')
    node.autorun()

    log.debug('Waiting until chef-client has finished running to proceed')
    baked = node.baked()

    if baked:
        return node

    else:
        log.critical('chef-client failed to finish running')
        sys.exit(1)
Exemple #4
0
    def provision(self):

        zones = 'cde'

        self.log.info('Building availability zone list')

        while len(zones) < (self.data_nodes+1):

            zones += zones

        self.log.info('Provisioning MongoDB Data Nodes')

        i = 0

        for i in range(self.data_nodes):

            node = MongoDataNode(group=self.group,
                                 server_type=self.server_type,
                                 instance_type=self.instance_type,
                                 environment=self.environment,
                                 ami=self.ami, region=self.region,
                                 role=self.role, keypair=self.keypair,
                                 chef_path=self.chef_path,
                                 dns_zones=self.dns_zones,
                                 replica_set=self.replica_set,
                                 security_groups=self.security_groups,
                                 block_devices=self.block_devices,
                                 availability_zone=zones[i],
                                 data_volume_size=self.data_volume_size,
                                 data_volume_iops=self.data_volume_iops,
                                 mongodb_version=self.mongodb_version)

            node.autorun()

            self.nodes.append(node)

        if (self.data_nodes % 2) == 0:

            self.log.info('Including Arbiter Node')

            node = MongoArbiterNode(group=self.group,
                                    server_type=self.server_type,
                                    instance_type=self.instance_type,
                                    environment=self.environment,
                                    ami=self.ami, region=self.region,
                                    role=self.role, keypair=self.keypair,
                                    chef_path=self.chef_path,
                                    dns_zones=self.dns_zones,
                                    replica_set=self.replica_set,
                                    security_groups=self.security_groups,
                                    block_devices=self.block_devices,
                                    availability_zone=zones[i+1],
                                    mongodb_version=self.mongodb_version)

            node.autorun()

            self.nodes.append(node)