Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L2 switch mode] Update l2switch.j2 template #5981

Merged
merged 4 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 5 additions & 2 deletions src/sonic-config-engine/data/l2switch.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
{%- if ns.firstPrinted %},{% endif %}

"{{ key }}": {
"alias": "{{ value.alias }}",
"lanes": "{{ value.lanes }}",
{%- for keyPort,valuePort in value.items() %}
Copy link
Collaborator

@qiluo-msft qiluo-msft Nov 19, 2020

Choose a reason for hiding this comment

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

keyPort [](start = 20, length = 7)

If keyPort == 'admin_status', is it a problem? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added check to resolve the scenario with admin_status exists.

Copy link
Collaborator

@qiluo-msft qiluo-msft Nov 19, 2020

Choose a reason for hiding this comment

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

, [](start = 27, length = 1)

Add a blank after ,. Also some more occurrences in the whole file. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


"{{ keyPort }}": "{{ valuePort }}",
{%- endfor %}

"admin_status": "up"
}
{%- if ns.update({'firstPrinted': True}) %}{% endif -%}
Expand Down
7 changes: 7 additions & 0 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ def test_l2switch_template(self):

self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))

template_dir = os.path.join(self.test_dir, '..', 'data', 'l2switch.j2')
argument = '-t ' + template_dir + ' -k Mellanox-SN2700 -p ' + self.t0_port_config
output = self.run_script(argument)
output_json = json.loads(output)

self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))

def test_qos_arista7050_render_template(self):
arista_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'arista', 'x86_64-arista_7050_qx32s', 'Arista-7050-QX-32S')
qos_file = os.path.join(arista_dir_path, 'qos.json.j2')
Expand Down