Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dockers/docker-orchagent/ports.json.j2
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[
{% if PORT %}
{% set ns = {'firstPrinted': False} %}
{% for port in PORT %}
{% if PORT[port].has_key('speed') %}
{
{% if ns.firstPrinted %},{% endif %}{
"PORT_TABLE:{{ port }}": {
"speed": "{{ PORT[port]['speed'] }}"
},
"OP": "SET"
}{% if not loop.last %},{% endif %}
}{% if ns.update({'firstPrinted': True}) %} {% endif %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need another if here, we can probably do { % set ns = {'firstPrinted': True} %}

Copy link
Author

@Mrak-IW Mrak-IW Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we can't change variable in a loop in a straight way. You couldn't be able to notice that changes inside the loop itself.
You also can not simply call the function like {% ns.update({'firstPrinted': True}) %}. It leads to error and ports.json is empty as a result.
The main idea was that this function must be called to calculate that if condition. Unfortunately, I have not found another way to do it.


{% endif %}
{% endfor %}
Expand Down