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

def add_elasticache_node(self, node, cluster, region):

    if ((not self.all_elasticache_nodes) and (node['CacheNodeStatus'] != 'available')):
        return
    dest = node['Endpoint']['Address']
    if (not dest):
        return
    node_id = self.to_safe(((cluster['CacheClusterId'] + '_') + node['CacheNodeId']))
    self.index[dest] = [region, node_id]
    if self.group_by_instance_id:
        self.inventory[node_id] = [dest]
        if self.nested_groups:
            self.push_group(self.inventory, 'instances', node_id)
    if self.group_by_region:
        self.push(self.inventory, region, dest)
        if self.nested_groups:
            self.push_group(self.inventory, 'regions', region)
    if self.group_by_availability_zone:
        self.push(self.inventory, cluster['PreferredAvailabilityZone'], dest)
        if self.nested_groups:
            if self.group_by_region:
                self.push_group(self.inventory, region, cluster['PreferredAvailabilityZone'])
            self.push_group(self.inventory, 'zones', cluster['PreferredAvailabilityZone'])
    if self.group_by_instance_type:
        type_name = self.to_safe(('type_' + cluster['CacheNodeType']))
        self.push(self.inventory, type_name, dest)
        if self.nested_groups:
            self.push_group(self.inventory, 'types', type_name)
    if self.group_by_security_group:
        if (('SecurityGroups' in cluster) and (cluster['SecurityGroups'] is not None)):
            for security_group in cluster['SecurityGroups']:
                key = self.to_safe(('security_group_' + security_group['SecurityGroupId']))
                self.push(self.inventory, key, dest)
                if self.nested_groups:
                    self.push_group(self.inventory, 'security_groups', key)
    if self.group_by_elasticache_engine:
        self.push(self.inventory, self.to_safe(('elasticache_' + cluster['Engine'])), dest)
        if self.nested_groups:
            self.push_group(self.inventory, 'elasticache_engines', self.to_safe(('elasticache_' + cluster['Engine'])))
    if self.group_by_elasticache_cluster:
        self.push(self.inventory, self.to_safe(('elasticache_cluster_' + cluster['CacheClusterId'])), dest)
    self.push(self.inventory, 'elasticache_nodes', dest)
    host_info = self.get_host_info_dict_from_describe_dict(node)
    if (dest in self.inventory['_meta']['hostvars']):
        self.inventory['_meta']['hostvars'][dest].update(host_info)
    else:
        self.inventory['_meta']['hostvars'][dest] = host_info
