'Convenience method for running spot or flat-rate instances'

def request_instances(self, image_id, price=None, instance_type='m1.small', min_count=1, max_count=1, count=1, key_name=None, security_groups=None, security_group_ids=None, launch_group=None, availability_zone_group=None, placement=None, user_data=None, placement_group=None, block_device_map=None, subnet_id=None, network_interfaces=None):

    if (not block_device_map):
        img = self.get_image(image_id)
        instance_store = (img.root_device_type == 'instance-store')
        if ((instance_type == 'm1.small') and (img.architecture == 'i386')):
            instance_store = True
        use_ephemeral = (instance_type != 't1.micro')
        bdmap = self.create_block_device_map(add_ephemeral_drives=use_ephemeral, num_ephemeral_drives=24, instance_store=instance_store)
        for dev in img.block_device_mapping:
            bdt = img.block_device_mapping.get(dev)
            if ((not bdt.ephemeral_name) and (dev in bdmap)):
                log.debug(('EBS    volume    already    mapped    to    %s    by    AMI' % dev))
                log.debug(('Removing    %s    from    runtime    block    device    map' % dev))
                bdmap.pop(dev)
        if (img.root_device_name in img.block_device_mapping):
            log.debug(('Forcing    delete_on_termination    for    AMI:    %s' % img.id))
            root = img.block_device_mapping[img.root_device_name]
            root.snapshot_id = None
            root.delete_on_termination = True
            if hasattr(root, 'encrypted'):
                root.encrypted = None
            bdmap[img.root_device_name] = root
        block_device_map = bdmap
    shared_kwargs = dict(instance_type=instance_type, key_name=key_name, subnet_id=subnet_id, placement=placement, placement_group=placement_group, user_data=user_data, block_device_map=block_device_map, network_interfaces=network_interfaces)
    if price:
        return self.request_spot_instances(price, image_id, count=count, launch_group=launch_group, security_group_ids=security_group_ids, availability_zone_group=availability_zone_group, **shared_kwargs)
    else:
        return self.run_instances(image_id, min_count=min_count, max_count=max_count, security_groups=security_groups, **shared_kwargs)
