sonic-buildimage/dockers/docker-teamd/teamd.j2
Shuotian Cheng a74b3a1eb7 [teamd]: Fix Jinja2 template for calculating min_ports (#791)
In Jinja2, '|' cannot be treated directly as piping operator. The
operator precedence of '|' is higher than '*'. The filter only applies
to the value just before it. Group the expression to make sure that the
filter is applied to the outcome of the expression.

Update the unit test to add such case.
2017-07-06 16:33:24 -07:00

22 lines
535 B
Django/Jinja

{
"device": "{{ pc }}",
"hwaddr": "{{ hwaddr }}",
"runner": {
"name": "lacp",
"active": true,
{# Use 75% links upperbound as min-links #}
"min_ports": {{ (minigraph_portchannels[pc]['members'] | length * 0.75) | round(0, 'ceil') | int }},
"tx_hash": ["eth", "ipv4", "ipv6"]
},
"link_watch": {
"name": "ethtool"
},
"ports": {
{% for member in minigraph_portchannels[pc]['members'] %}
"{{ member }}": {}{% if not loop.last %},{% endif %}
{% endfor %}
}
}