'Makes an AWS EC2 API call to the list of instances in a particular
region'

def get_instances_by_region(self, region):

    try:
        if self.eucalyptus:
            conn = boto.connect_euca(host=self.eucalyptus_host)
            conn.APIVersion = '2010-08-31'
        else:
            conn = ec2.connect_to_region(region)
        if (conn is None):
            print ('region    name:    %s    likely    not    supported,    or    AWS    is    down.        connection    to    region    failed.' % region)
            sys.exit(1)
        reservations = []
        if self.ec2_instance_filters:
            for (filter_key, filter_values) in self.ec2_instance_filters.iteritems():
                reservations.extend(conn.get_all_instances(filters={filter_key: filter_values}))
        else:
            reservations = conn.get_all_instances()
        for reservation in reservations:
            for instance in reservation.instances:
                self.add_instance(instance, region)
    except boto.exception.BotoServerError as e:
        if (not self.eucalyptus):
            print 'Looks    like    AWS    is    down    again:'
        print e
        sys.exit(1)
