[openstack-dev] [heat][yaql] Deep merge map of lists?
Jiří Stránský
jistr at redhat.com
Tue Aug 30 14:10:47 UTC 2016
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 at 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"]
[stack at instack ~]$ heat output-show yaq debug
WARNING (shell) "heat output-show" is deprecated, please use "openstack
stack output show" instead
{
"gnocchi_metricd_node_names": [
"a0",
"a1",
"a2"
],
"tripleo_packages_node_names": [
"a0",
"a1",
"a2",
"b0"
],
"nova_compute_node_names": [
"b0"
]
}
Jirka
More information about the OpenStack-dev
mailing list