コード例 #1
0
ファイル: run_cvel.py プロジェクト: astrowork/aws-chiles02
def start_servers(processes, ami_id, user_data, setup_disks, instance_type,
                  obs_ids, created_by, name, instance_details, spot_price,
                  frequency_channels, force):
    cvel_data = get_cvel()

    # Create the queue
    tasks = multiprocessing.JoinableQueue()

    # Start the consumers
    for x in range(processes):
        consumer = Consumer(tasks)
        consumer.start()

    counter = 1
    for obs_id in obs_ids:
        snapshot_id = OBS_IDS.get(obs_id)
        if snapshot_id is None:
            LOGGER.warning(
                'The obs-id: {0} does not exist in the settings file')
        else:
            obs_id_dashes = obs_id.replace('_', '-')
            for frequency_groups in get_frequency_groups(
                    frequency_channels, obs_id_dashes, cvel_data, force):
                tasks.put(
                    Task(ami_id, user_data, setup_disks, instance_type, obs_id,
                         snapshot_id, created_by, name, spot_price,
                         instance_details, frequency_groups, counter))
                counter += 1

        # Add a poison pill to shut things down
    for x in range(processes):
        tasks.put(None)

    # Wait for the queue to terminate
    tasks.join()
コード例 #2
0
ファイル: run_cvel.py プロジェクト: ICRAR/aws-chiles02
def start_servers(
        processes,
        ami_id,
        user_data,
        setup_disks,
        instance_type,
        obs_ids,
        created_by,
        name,
        instance_details,
        spot_price,
        frequency_channels,
        force):
    cvel_data = get_cvel()

    # Create the queue
    tasks = multiprocessing.JoinableQueue()

    # Start the consumers
    for x in range(processes):
        consumer = Consumer(tasks)
        consumer.start()

    counter = 1
    for obs_id in obs_ids:
        snapshot_id = OBS_IDS.get(obs_id)
        if snapshot_id is None:
            LOGGER.warning('The obs-id: {0} does not exist in the settings file')
        else:
            obs_id_dashes = obs_id.replace('_', '-')
            for frequency_groups in get_frequency_groups(frequency_channels, obs_id_dashes, cvel_data, force):
                tasks.put(
                    Task(
                        ami_id,
                        user_data,
                        setup_disks,
                        instance_type,
                        obs_id,
                        snapshot_id,
                        created_by,
                        name,
                        spot_price,
                        instance_details,
                        frequency_groups,
                        counter
                    )
                )
                counter += 1

        # Add a poison pill to shut things down
    for x in range(processes):
        tasks.put(None)

    # Wait for the queue to terminate
    tasks.join()
コード例 #3
0
def start_servers(
        ami_id,
        user_data,
        setup_disks,
        instance_type,
        obs_id,
        created_by,
        name,
        instance_details,
        spot_price):

    snapshot_id = OBS_IDS.get(obs_id)
    if snapshot_id is None:
        LOGGER.warning('The obs-id: {0} does not exist in the settings file')
    else:
        ec2_helper = EC2Helper()
        iops = None
        if instance_details.iops_support:
            iops = 500

        zone = ec2_helper.get_cheapest_spot_price(instance_type, spot_price)
        if zone is not None:
            volume, snapshot_name = ec2_helper.create_volume(snapshot_id, zone, iops=iops)
            LOGGER.info('obs_id: {0}, volume_name: {1}'.format(obs_id, snapshot_name))
            now = datetime.datetime.now()
            user_data_mime = get_mime_encoded_user_data(volume.id, setup_disks, user_data, now.strftime('%Y-%m-%dT%H-%M-%S'))

            if spot_price is not None:
                ec2_helper.run_spot_instance(
                    ami_id,
                    spot_price,
                    user_data_mime,
                    instance_type,
                    volume.id,
                    created_by,
                    '{1}-{0}'.format(name, snapshot_name),
                    instance_details,
                    zone,
                    ephemeral=True)
        else:
            LOGGER.error('Cannot get a spot instance of {0} for ${1}'.format(instance_type, spot_price))
コード例 #4
0
def start_servers(ami_id, user_data, setup_disks, instance_type, obs_id,
                  created_by, name, instance_details, spot_price):

    snapshot_id = OBS_IDS.get(obs_id)
    if snapshot_id is None:
        LOGGER.warning('The obs-id: {0} does not exist in the settings file')
    else:
        ec2_helper = EC2Helper()
        iops = None
        if instance_details.iops_support:
            iops = 500

        zone = ec2_helper.get_cheapest_spot_price(instance_type, spot_price)
        if zone is not None:
            volume, snapshot_name = ec2_helper.create_volume(snapshot_id,
                                                             zone,
                                                             iops=iops)
            LOGGER.info('obs_id: {0}, volume_name: {1}'.format(
                obs_id, snapshot_name))
            now = datetime.datetime.now()
            user_data_mime = get_mime_encoded_user_data(
                volume.id, setup_disks, user_data,
                now.strftime('%Y-%m-%dT%H-%M-%S'))

            if spot_price is not None:
                ec2_helper.run_spot_instance(ami_id,
                                             spot_price,
                                             user_data_mime,
                                             instance_type,
                                             volume.id,
                                             created_by,
                                             '{1}-{0}'.format(
                                                 name, snapshot_name),
                                             instance_details,
                                             zone,
                                             ephemeral=True)
        else:
            LOGGER.error('Cannot get a spot instance of {0} for ${1}'.format(
                instance_type, spot_price))