def environment_tag_targets_for_instances(ilist):
    """
    Generate List of possible targets ordered by environment key.
    """
    env_nodes = {}

    for i in ilist:
        if i.tags is None:
            continue
        for tag in i.tags:
            if tag['Key'] == 'environment' or tag['Key'] == 'Environment':
                name = tag['Value']
                if name not in env_nodes:
                    env_nodes[name] = []
                env_nodes[name].append(i.private_ip_address)

    return [('env:{}'.format(env), ips) for env, ips in env_nodes.items()]
dataset/ETHPy150Open grahamc/ish/ish/aws.py/environment_tag_targets_for_instances/original