On Mon, Aug 29, 2016 at 04:03:27PM +0200, Thomas Herve wrote: > 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 :).
Heh, thanks for the help, I appreciate it! > $.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. Yeah, that gets us closer, but we do need to handle more than one value (list entry) per key, e.g: data: l: - "gnocchi_metricd_node_names": ["a0", "a1", "a2"] "tripleo_packages_node_names": ["a0", "a1", "a2"] - "nova_compute_node_names": ["b0"] "tripleo_packages_node_names": ["b0"] Output needs to be like: "gnocchi_metricd_node_names": ["a0", "a1", "a2"] "tripleo_packages_node_names": ["a0", "a1", "a2", "b0"] "nova_compute_node_names": ["b0"] I'm almost tempted to just write a map_deep_merge patch for heat, but I'm guessing we won't be able to land it for newton at this point anyway. Thanks! Steve __________________________________________________________________________ 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