diff --git a/src/sonic-config-engine/data/l2switch.j2 b/src/sonic-config-engine/data/l2switch.j2 index 86dca30cb739..56d19faeab1f 100644 --- a/src/sonic-config-engine/data/l2switch.j2 +++ b/src/sonic-config-engine/data/l2switch.j2 @@ -6,8 +6,11 @@ {%- if ns.firstPrinted %},{% endif %} "{{ key }}": { - "alias": "{{ value.alias }}", - "lanes": "{{ value.lanes }}", + {%- for k,v in value.items() %} + + "{{ k }}": "{{ v }}", + {%- endfor %} + "admin_status": "up" } {%- if ns.update({'firstPrinted': True}) %}{% endif -%} diff --git a/src/sonic-config-engine/tests/test_j2files.py b/src/sonic-config-engine/tests/test_j2files.py index 2dec13425e19..ba5d30604b48 100644 --- a/src/sonic-config-engine/tests/test_j2files.py +++ b/src/sonic-config-engine/tests/test_j2files.py @@ -106,6 +106,14 @@ 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-D48C8 -p ' + self.t0_port_config + output = self.run_script(argument) + print(json.dumps(output_json, sort_keys=True)) + print(json.dumps(sample_output_json, sort_keys=True)) + + 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')