Skip to content

Commit

Permalink
[sonic-cfggen] Fix init t1 config to align with YANG (#21195)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wen587 authored Jan 15, 2025
1 parent e1902e6 commit 7e397b0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/sonic-config-engine/config_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def generate_t1_sample_config(data):
data['DEVICE_METADATA']['localhost']['hostname'] = 'sonic'
data['DEVICE_METADATA']['localhost']['type'] = 'LeafRouter'
data['DEVICE_METADATA']['localhost']['bgp_asn'] = '65100'
data['LOOPBACK_INTERFACE'] = {"Loopback0|10.1.0.1/32": {}}
data['LOOPBACK_INTERFACE'] = {"Loopback0": {},
"Loopback0|10.1.0.1/32": {}}
data['BGP_NEIGHBOR'] = {}
data['DEVICE_NEIGHBOR'] = {}
data['INTERFACE'] = {}
Expand All @@ -63,6 +64,7 @@ def generate_t1_sample_config(data):
peer_addr = '10.0.{}.{}'.format(2 * port_count // 256, 2 * port_count % 256 + 1)
peer_name='ARISTA{0:02d}{1}'.format(1+port_count%(total_port_amount // 2), 'T2' if port_count < (total_port_amount // 2) else 'T0')
peer_asn = 65200 if port_count < (total_port_amount // 2) else 64001 + port_count - (total_port_amount // 2)
data['INTERFACE']['{}'.format(port)] = {}
data['INTERFACE']['{}|{}/31'.format(port, local_addr)] = {}
data['BGP_NEIGHBOR'][peer_addr] = {
'rrclient': 0,
Expand Down Expand Up @@ -185,7 +187,7 @@ def generate_global_dualtor_tables():
data = defaultdict(lambda: defaultdict(dict))
data['LOOPBACK_INTERFACE'] = {
'Loopback2': {},
'Loopback2|3.3.3.3': {}
'Loopback2|3.3.3.3/32': {}
}
data['MUX_CABLE'] = {}
data['PEER_SWITCH'] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@
},
"LOOPBACK_INTERFACE": {
"Loopback2": {},
"Loopback2|3.3.3.3": {}
"Loopback2|3.3.3.3/32": {}
},
"MUX_CABLE": {
"Ethernet0": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@
},
"LOOPBACK_INTERFACE": {
"Loopback2": {},
"Loopback2|3.3.3.3": {}
"Loopback2|3.3.3.3/32": {}
},
"MUX_CABLE": {
"Ethernet0": {
Expand Down
35 changes: 34 additions & 1 deletion src/sonic-config-engine/tests/sample_output/t1-smartswitch.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,38 @@
}
},
"INTERFACE": {
"Ethernet0":{},
"Ethernet104": {},
"Ethernet112": {},
"Ethernet120": {},
"Ethernet128": {},
"Ethernet136": {},
"Ethernet144": {},
"Ethernet152": {},
"Ethernet160": {},
"Ethernet168": {},
"Ethernet16": {},
"Ethernet176": {},
"Ethernet184": {},
"Ethernet192": {},
"Ethernet200": {},
"Ethernet208": {},
"Ethernet216": {},
"Ethernet224": {},
"Ethernet232": {},
"Ethernet240": {},
"Ethernet248": {},
"Ethernet24": {},
"Ethernet32": {},
"Ethernet40": {},
"Ethernet48": {},
"Ethernet56": {},
"Ethernet64": {},
"Ethernet72": {},
"Ethernet80": {},
"Ethernet88": {},
"Ethernet8": {},
"Ethernet96": {},
"Ethernet0|10.0.0.0/31": {},
"Ethernet104|10.0.0.26/31": {},
"Ethernet112|10.0.0.28/31": {},
Expand Down Expand Up @@ -409,6 +441,7 @@
"Ethernet96|10.0.0.24/31": {}
},
"LOOPBACK_INTERFACE": {
"Loopback0": {},
"Loopback0|10.1.0.1/32": {}
},
"MID_PLANE_BRIDGE": {
Expand Down Expand Up @@ -611,4 +644,4 @@
"mtu": "9100"
}
}
}
}

0 comments on commit 7e397b0

Please sign in to comment.