'Adds an instance to the inventory and index, as long as it is
addressable'

def add_instance(self, instance, region):

    if ((not self.all_instances) and (instance.state != 'running')):
        return
    if instance.subnet_id:
        dest = getattr(instance, self.vpc_destination_variable)
    else:
        dest = getattr(instance, self.destination_variable)
    if (not dest):
        return
    if (self.pattern_include and (not self.pattern_include.match(dest))):
        return
    if (self.pattern_exclude and self.pattern_exclude.match(dest)):
        return
    self.index[dest] = [region, instance.id]
    self.inventory[instance.id] = [dest]
    if self.nested_groups:
        self.push_group(self.inventory, 'instances', instance.id)
    if self.nested_groups:
        self.push_group(self.inventory, 'regions', region)
    else:
        self.push(self.inventory, region, dest)
    self.push(self.inventory, instance.placement, dest)
    if self.nested_groups:
        self.push_group(self.inventory, region, instance.placement)
    type_name = self.to_safe(('type_' + instance.instance_type))
    self.push(self.inventory, type_name, dest)
    if self.nested_groups:
        self.push_group(self.inventory, 'types', type_name)
    if instance.key_name:
        key_name = self.to_safe(('key_' + instance.key_name))
        self.push(self.inventory, key_name, dest)
        if self.nested_groups:
            self.push_group(self.inventory, 'keys', key_name)
    try:
        for group in instance.groups:
            key = self.to_safe(('security_group_' + group.name))
            self.push(self.inventory, key, dest)
            if self.nested_groups:
                self.push_group(self.inventory, 'security_groups', key)
    except AttributeError:
        print 'Package    boto    seems    a    bit    older.'
        print 'Please    upgrade    boto    >=    2.3.0.'
        sys.exit(1)
    for (k, v) in instance.tags.iteritems():
        key = self.to_safe(((('tag_' + k) + '=') + v))
        self.push(self.inventory, key, dest)
        if self.nested_groups:
            self.push_group(self.inventory, 'tags', self.to_safe(('tag_' + k)))
            self.push_group(self.inventory, self.to_safe(('tag_' + k)), key)
    if self.route53_enabled:
        route53_names = self.get_instance_route53_names(instance)
        for name in route53_names:
            self.push(self.inventory, name, dest)
            if self.nested_groups:
                self.push_group(self.inventory, 'route53', name)
    self.push(self.inventory, 'ec2', dest)
    self.inventory['_meta']['hostvars'][dest] = self.get_host_info_dict_from_instance(instance)
