<div dir="ltr">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: 







<p class=""><span class=""><a href="https://review.openstack.org/363191">https://review.openstack.org/363191</a>. 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.</span></p></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span style="border-collapse:separate;color:rgb(0,0,0);font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="font-family:arial;font-size:small">Sincerely yours,<br>Stan Lagun<br>Principal Software Engineer @ Mirantis</span></span><br><span style="border-collapse:separate;color:rgb(0,0,0);font-family:'Times New Roman';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="font-family:arial;font-size:small"><br><a href="mailto:slagun@mirantis.com" target="_blank"></a></span></span></div></div></div>
<br><div class="gmail_quote">On Tue, Aug 30, 2016 at 12:46 PM, Thomas Herve <span dir="ltr"><<a href="mailto:therve@redhat.com" target="_blank">therve@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Aug 30, 2016 at 6:02 PM, Steven Hardy <<a href="mailto:shardy@redhat.com">shardy@redhat.com</a>> wrote:<br>
> On Tue, Aug 30, 2016 at 04:10:47PM +0200, Jiří Stránský wrote:<br>
>><br>
>> On 30.8.2016 10:17, Steven Hardy wrote:<br>
>><br>
>> <snip><br>
>><br>
>> > Yeah, that gets us closer, but we do need to handle more than one value<br>
>> > (list entry) per key, e.g:<br>
>> ><br>
>> >          data:<br>
>> >            l:<br>
>> >              - "gnocchi_metricd_node_names": ["a0", "a1", "a2"]<br>
>> >                "tripleo_packages_node_names": ["a0", "a1", "a2"]<br>
>> >              - "nova_compute_node_names": ["b0"]<br>
>> >                "tripleo_packages_node_names": ["b0"]<br>
>> ><br>
>> > Output needs to be like:<br>
>> ><br>
>> >              "gnocchi_metricd_node_names": ["a0", "a1", "a2"]<br>
>> >              "tripleo_packages_node_names": ["a0", "a1", "a2", "b0"]<br>
>> >              "nova_compute_node_names": ["b0"]<br>
>> ><br>
>><br>
>> Hoping this could do it:<br>
>><br>
>> [stack@instack ~]$ cat yaq.yaml<br>
>> heat_template_version: 2016-10-14<br>
>><br>
>> outputs:<br>
>>   debug:<br>
>>     value:<br>
>>       yaql:<br>
>>         expression: $.data.l.reduce($1.mergeWith($<wbr>2))<br>
>>         data:<br>
>>           l:<br>
>>             - "gnocchi_metricd_node_names": ["a0", "a1", "a2"]<br>
>>               "tripleo_packages_node_names": ["a0", "a1", "a2"]<br>
>>             - "nova_compute_node_names": ["b0"]<br>
>>               "tripleo_packages_node_names": ["b0"]<br>
><br>
> Thanks for this!<br>
><br>
> Unfortunately I dont think it works with more than two list items:<br>
><br>
>   debug_tripleo2:<br>
>     value:<br>
>       yaql:<br>
>         expression: $.data.l.reduce($1.mergeWith($<wbr>2))<br>
>         data:<br>
>           l:<br>
>             - "gnocchi_metricd_node_names": ["overcloud-controller-0",<br>
>               "overcloud-controller-1", "overcloud-controller-2"]<br>
>               "tripleo_packages_node_names": ["overcloud-controller-0", "overcloud-controller-1", "overcloud-controller-2"]<br>
>             - "nova_compute_node_names": ["overcloud-compute-0"]<br>
>               "tripleo_packages_node_names": ["overcloud-compute-0"]<br>
>               "tripleo_packages_node_names2"<wbr>: ["overcloud-compute-0"]<br>
>             - "ceph_osd_node_names": ["overcloud-cephstorage-0"]<br>
>               "tripleo_packages_node_names": ["overcloud-cephstorage-0"]<br>
>               "tripleo_packages_node_names2"<wbr>: ["overcloud-cephstorage-0"]<br>
><br>
> $ heat output-show foo5 debug_tripleo2<br>
> stack output show" instead<br>
> Output error: can only concatenate tuple (not "list") to tuple<br>
><br>
> I've not dug too deeply yet, but assuming that's a yaql error vs a heat bug<br>
> it looks like it won't work.<br>
<br>
</div></div>I'd say it's a yaql bug (commented on the bug opened in Heat), that<br>
can work around using the list_merger argument:<br>
<br>
$.data.l.reduce($1.mergeWith($<wbr>2, listMerger => $1.toList() + $2.toList()))<br>
<br>
Still slightly more elegant than the one I came up with.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Thomas<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>______________________________<wbr>______________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.<wbr>openstack.org?subject:<wbr>unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/<wbr>cgi-bin/mailman/listinfo/<wbr>openstack-dev</a><br>
</div></div></blockquote></div><br></div>