On Mon, Aug 29, 2016 at 3:16 PM, Steven Hardy <sha...@redhat.com> wrote:
> On Mon, Aug 29, 2016 at 07:07:09AM +0200, Thomas Herve wrote:
>> dict($.groupBy($.keys().toList()[0], $.values().toList()[0][0]))
>>
>> ought to work, I believe?
>
> So, as it turns out, my example above was bad, and groupBy only works if
> you have a list of maps with exactly one key, we actually need this:
>
>   # Example of tripleo format
>   # We need an output of
>   # "gnocchi_metricd_node_names": ["overcloud-controller-0"]
>   # "tripleo_packages_node_names": ["overcloud-controller-0", 
> "overcloud-compute-0"]
>   # "nova_compute_node_names": ["overcloud-compute-0"]
>   debug_tripleo:
>     value:
>       yaql:
>         expression: dict($.data.l.groupBy($.keys().toList()[0], 
> $.values().toList()[0][0]))
>         data:
>           l:
>             - "gnocchi_metricd_node_names": ["overcloud-controller-0"]
>               "tripleo_packages_node_names": ["overcloud-controller-0"]
>             - "nova_compute_node_names": ["overcloud-compute-0"]
>               "tripleo_packages_node_names": ["overcloud-compute-0"]
>
> So, I'm back to wondering how we make the intermediate assignement of 
> tripleo_packages_node_names

Well I didn't know all the constraints :).

$.selectMany($.items()).groupBy($[0], $[1][0])

is another attempt. It won't work if you have more than one value per
key in the original data, but I think it will handle multiple keys.

-- 
Thomas

__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to