[L2 switch mode] Update l2switch.j2 template (#5981)
- Why I did it The l2switch.j2 template does not include all fields for PORT. This could be incompatible with the 201911 image or later. - How I did it Update l2switch.j2 template and add a unit test.
This commit is contained in:
parent
5b31996f7b
commit
e0781f463f
@ -2,13 +2,16 @@
|
|||||||
"DEVICE_METADATA": {{ DEVICE_METADATA | tojson }},
|
"DEVICE_METADATA": {{ DEVICE_METADATA | tojson }},
|
||||||
{% set ns = {'firstPrinted': False} -%}
|
{% set ns = {'firstPrinted': False} -%}
|
||||||
"PORT": {
|
"PORT": {
|
||||||
{%- for key,value in PORT.items() -%}
|
{%- for key, value in PORT.items() -%}
|
||||||
{%- if ns.firstPrinted %},{% endif %}
|
{%- if ns.firstPrinted %},{% endif %}
|
||||||
|
|
||||||
"{{ key }}": {
|
"{{ key }}": {
|
||||||
"alias": "{{ value.alias }}",
|
{%- for keyPort, valuePort in value.items() %}
|
||||||
"lanes": "{{ value.lanes }}",
|
|
||||||
"admin_status": "up"
|
{% if keyPort != "admin_status" %}"{{ keyPort }}": "{{ valuePort }}",{% endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
"admin_status": "{{ value.admin_status|default("up") }}"
|
||||||
}
|
}
|
||||||
{%- if ns.update({'firstPrinted': True}) %}{% endif -%}
|
{%- if ns.update({'firstPrinted': True}) %}{% endif -%}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -125,6 +125,13 @@ class TestJ2Files(TestCase):
|
|||||||
|
|
||||||
self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))
|
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):
|
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')
|
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')
|
qos_file = os.path.join(arista_dir_path, 'qos.json.j2')
|
||||||
|
Loading…
Reference in New Issue
Block a user