There is a bug in how yaql interprets its 3rd argument (aggregator). It was
supposed to be a function to aggregate values within each group but instead
was applied to the outcome of groupBy. I submitted a fix for this:

https://review.openstack.org/363191. Though I'm not sure we can release new
yaql version that late in the Newton cycle. Meanwhile it is better to use
one of alternative solutions above so that it won't break after this patch
get merged.

Sincerely yours,
Stan Lagun
Principal Software Engineer @ Mirantis

<sla...@mirantis.com>

On Tue, Aug 30, 2016 at 12:46 PM, Thomas Herve <the...@redhat.com> wrote:

> On Tue, Aug 30, 2016 at 6:02 PM, Steven Hardy <sha...@redhat.com> wrote:
> > On Tue, Aug 30, 2016 at 04:10:47PM +0200, Jiří Stránský wrote:
> >>
> >> On 30.8.2016 10:17, Steven Hardy wrote:
> >>
> >> <snip>
> >>
> >> > 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"]
> >> >
> >>
> >> Hoping this could do it:
> >>
> >> [stack@instack ~]$ cat yaq.yaml
> >> heat_template_version: 2016-10-14
> >>
> >> outputs:
> >>   debug:
> >>     value:
> >>       yaql:
> >>         expression: $.data.l.reduce($1.mergeWith($2))
> >>         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"]
> >
> > Thanks for this!
> >
> > Unfortunately I dont think it works with more than two list items:
> >
> >   debug_tripleo2:
> >     value:
> >       yaql:
> >         expression: $.data.l.reduce($1.mergeWith($2))
> >         data:
> >           l:
> >             - "gnocchi_metricd_node_names": ["overcloud-controller-0",
> >               "overcloud-controller-1", "overcloud-controller-2"]
> >               "tripleo_packages_node_names": ["overcloud-controller-0",
> "overcloud-controller-1", "overcloud-controller-2"]
> >             - "nova_compute_node_names": ["overcloud-compute-0"]
> >               "tripleo_packages_node_names": ["overcloud-compute-0"]
> >               "tripleo_packages_node_names2": ["overcloud-compute-0"]
> >             - "ceph_osd_node_names": ["overcloud-cephstorage-0"]
> >               "tripleo_packages_node_names": ["overcloud-cephstorage-0"]
> >               "tripleo_packages_node_names2":
> ["overcloud-cephstorage-0"]
> >
> > $ heat output-show foo5 debug_tripleo2
> > stack output show" instead
> > Output error: can only concatenate tuple (not "list") to tuple
> >
> > I've not dug too deeply yet, but assuming that's a yaql error vs a heat
> bug
> > it looks like it won't work.
>
> I'd say it's a yaql bug (commented on the bug opened in Heat), that
> can work around using the list_merger argument:
>
> $.data.l.reduce($1.mergeWith($2, listMerger => $1.toList() + $2.toList()))
>
> Still slightly more elegant than the one I came up with.
>
> --
> 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
>
__________________________________________________________________________
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