Skip to content

Commit 7e397b0

Browse files
authored
[sonic-cfggen] Fix init t1 config to align with YANG (sonic-net#21195)
Why I did it Improve the t1 config to align with YANG validation How I did it Add missing leafref and mandatory field to the config How to verify it YANG validation check on generated config
1 parent e1902e6 commit 7e397b0

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

src/sonic-config-engine/config_samples.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def generate_t1_sample_config(data):
5050
data['DEVICE_METADATA']['localhost']['hostname'] = 'sonic'
5151
data['DEVICE_METADATA']['localhost']['type'] = 'LeafRouter'
5252
data['DEVICE_METADATA']['localhost']['bgp_asn'] = '65100'
53-
data['LOOPBACK_INTERFACE'] = {"Loopback0|10.1.0.1/32": {}}
53+
data['LOOPBACK_INTERFACE'] = {"Loopback0": {},
54+
"Loopback0|10.1.0.1/32": {}}
5455
data['BGP_NEIGHBOR'] = {}
5556
data['DEVICE_NEIGHBOR'] = {}
5657
data['INTERFACE'] = {}
@@ -63,6 +64,7 @@ def generate_t1_sample_config(data):
6364
peer_addr = '10.0.{}.{}'.format(2 * port_count // 256, 2 * port_count % 256 + 1)
6465
peer_name='ARISTA{0:02d}{1}'.format(1+port_count%(total_port_amount // 2), 'T2' if port_count < (total_port_amount // 2) else 'T0')
6566
peer_asn = 65200 if port_count < (total_port_amount // 2) else 64001 + port_count - (total_port_amount // 2)
67+
data['INTERFACE']['{}'.format(port)] = {}
6668
data['INTERFACE']['{}|{}/31'.format(port, local_addr)] = {}
6769
data['BGP_NEIGHBOR'][peer_addr] = {
6870
'rrclient': 0,
@@ -185,7 +187,7 @@ def generate_global_dualtor_tables():
185187
data = defaultdict(lambda: defaultdict(dict))
186188
data['LOOPBACK_INTERFACE'] = {
187189
'Loopback2': {},
188-
'Loopback2|3.3.3.3': {}
190+
'Loopback2|3.3.3.3/32': {}
189191
}
190192
data['MUX_CABLE'] = {}
191193
data['PEER_SWITCH'] = {

src/sonic-config-engine/tests/sample_output/py2/l2switch_dualtor.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@
520520
},
521521
"LOOPBACK_INTERFACE": {
522522
"Loopback2": {},
523-
"Loopback2|3.3.3.3": {}
523+
"Loopback2|3.3.3.3/32": {}
524524
},
525525
"MUX_CABLE": {
526526
"Ethernet0": {

src/sonic-config-engine/tests/sample_output/py3/l2switch_dualtor.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@
520520
},
521521
"LOOPBACK_INTERFACE": {
522522
"Loopback2": {},
523-
"Loopback2|3.3.3.3": {}
523+
"Loopback2|3.3.3.3/32": {}
524524
},
525525
"MUX_CABLE": {
526526
"Ethernet0": {

src/sonic-config-engine/tests/sample_output/t1-smartswitch.json

+34-1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,38 @@
375375
}
376376
},
377377
"INTERFACE": {
378+
"Ethernet0":{},
379+
"Ethernet104": {},
380+
"Ethernet112": {},
381+
"Ethernet120": {},
382+
"Ethernet128": {},
383+
"Ethernet136": {},
384+
"Ethernet144": {},
385+
"Ethernet152": {},
386+
"Ethernet160": {},
387+
"Ethernet168": {},
388+
"Ethernet16": {},
389+
"Ethernet176": {},
390+
"Ethernet184": {},
391+
"Ethernet192": {},
392+
"Ethernet200": {},
393+
"Ethernet208": {},
394+
"Ethernet216": {},
395+
"Ethernet224": {},
396+
"Ethernet232": {},
397+
"Ethernet240": {},
398+
"Ethernet248": {},
399+
"Ethernet24": {},
400+
"Ethernet32": {},
401+
"Ethernet40": {},
402+
"Ethernet48": {},
403+
"Ethernet56": {},
404+
"Ethernet64": {},
405+
"Ethernet72": {},
406+
"Ethernet80": {},
407+
"Ethernet88": {},
408+
"Ethernet8": {},
409+
"Ethernet96": {},
378410
"Ethernet0|10.0.0.0/31": {},
379411
"Ethernet104|10.0.0.26/31": {},
380412
"Ethernet112|10.0.0.28/31": {},
@@ -409,6 +441,7 @@
409441
"Ethernet96|10.0.0.24/31": {}
410442
},
411443
"LOOPBACK_INTERFACE": {
444+
"Loopback0": {},
412445
"Loopback0|10.1.0.1/32": {}
413446
},
414447
"MID_PLANE_BRIDGE": {
@@ -611,4 +644,4 @@
611644
"mtu": "9100"
612645
}
613646
}
614-
}
647+
}

0 commit comments

Comments
 (0)