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

[sonic-cfggen] Fix init t1 config to align with YANG #21195

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 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 @@ -59,10 +60,13 @@ def generate_t1_sample_config(data):
for port in natsorted(data['PORT']):
data['PORT'][port]['admin_status'] = 'up'
data['PORT'][port]['mtu'] = '9100'
if 'speed' not in data['PORT'][port]:
data['PORT'][port]['speed'] = '100000'
local_addr = '10.0.{}.{}'.format(2 * port_count // 256, 2 * port_count % 256)
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 @@ -150,6 +154,8 @@ def generate_t1_smartswitch_dpu_sample_config(data, ss_config):
for port in natsorted(data['PORT']):
data['PORT'][port]['admin_status'] = 'up'
data['PORT'][port]['mtu'] = '9100'
if 'speed' not in data['PORT'][port]:
data['PORT'][port]['speed'] = '100000'

dash_crm_resources = ["vnet", "eni", "eni_ether_address_map", "ipv4_inbound_routing", "ipv6_inbound_routing", "ipv4_outbound_routing",
"ipv6_outbound_routing", "ipv4_pa_validation", "ipv6_pa_validation", "ipv4_outbound_ca_to_pa", "ipv6_outbound_ca_to_pa",
Expand Down Expand Up @@ -185,7 +191,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 Expand Up @@ -238,6 +244,7 @@ def generate_l2_config(data):
# Ports in use should be admin up, unused ports default to admin down
if port in downlinks or port in uplinks:
data['PORT'][port].setdefault('admin_status', 'up')
data['PORT'][port].setdefault('speed', '50000')
data['VLAN_MEMBER']['Vlan1000|{}'.format(port)] = {'tagging_mode': 'untagged'}

# Downlinks (connected to mux cable) need a MUX_CABLE entry
Expand All @@ -253,6 +260,7 @@ def generate_l2_config(data):
data['PORT'][port]['mux_cable'] = 'true'
else:
data['PORT'][port].setdefault('admin_status', 'up')
data['PORT'][port].setdefault('speed', '50000')
data['VLAN_MEMBER']['Vlan1000|{}'.format(port)] = {'tagging_mode': 'untagged'}
return data

Expand Down
3 changes: 2 additions & 1 deletion src/sonic-config-engine/data/l2switch.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
{% if keyPort != "admin_status" %}"{{ keyPort }}": "{{ valuePort }}",{% endif %}
{%- endfor %}

"admin_status": "{{ value.admin_status|default("up") }}"
"admin_status": "{{ value.admin_status|default("up") }}",
"speed": "50000"
}
{%- if ns.update({'firstPrinted': True}) %}{% endif -%}
{%- endfor %}
Expand Down
96 changes: 64 additions & 32 deletions src/sonic-config-engine/tests/sample_output/py2/l2switch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,162 +4,194 @@
"Ethernet8": {
"alias": "fortyGigE0/8",
"lanes": "37,38,39,40",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet0": {
"alias": "fortyGigE0/0",
"lanes": "29,30,31,32",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet4": {
"alias": "fortyGigE0/4",
"lanes": "25,26,27,28",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet108": {
"alias": "fortyGigE0/108",
"lanes": "81,82,83,84",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet100": {
"alias": "fortyGigE0/100",
"lanes": "125,126,127,128",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet104": {
"alias": "fortyGigE0/104",
"lanes": "85,86,87,88",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet68": {
"alias": "fortyGigE0/68",
"lanes": "69,70,71,72",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet96": {
"alias": "fortyGigE0/96",
"lanes": "121,122,123,124",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet124": {
"alias": "fortyGigE0/124",
"lanes": "101,102,103,104",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet92": {
"alias": "fortyGigE0/92",
"lanes": "113,114,115,116",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet120": {
"alias": "fortyGigE0/120",
"lanes": "97,98,99,100",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet52": {
"alias": "fortyGigE0/52",
"lanes": "53,54,55,56",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet56": {
"alias": "fortyGigE0/56",
"lanes": "61,62,63,64",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet76": {
"alias": "fortyGigE0/76",
"lanes": "73,74,75,76",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet72": {
"alias": "fortyGigE0/72",
"lanes": "77,78,79,80",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet64": {
"alias": "fortyGigE0/64",
"lanes": "65,66,67,68",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet32": {
"alias": "fortyGigE0/32",
"lanes": "9,10,11,12",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet16": {
"alias": "fortyGigE0/16",
"lanes": "41,42,43,44",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet36": {
"alias": "fortyGigE0/36",
"lanes": "13,14,15,16",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet12": {
"alias": "fortyGigE0/12",
"lanes": "33,34,35,36",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet88": {
"alias": "fortyGigE0/88",
"lanes": "117,118,119,120",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet116": {
"alias": "fortyGigE0/116",
"lanes": "93,94,95,96",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet80": {
"alias": "fortyGigE0/80",
"lanes": "105,106,107,108",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet112": {
"alias": "fortyGigE0/112",
"lanes": "89,90,91,92",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet84": {
"alias": "fortyGigE0/84",
"lanes": "109,110,111,112",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet48": {
"alias": "fortyGigE0/48",
"lanes": "49,50,51,52",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet44": {
"alias": "fortyGigE0/44",
"lanes": "17,18,19,20",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet40": {
"alias": "fortyGigE0/40",
"lanes": "21,22,23,24",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet28": {
"alias": "fortyGigE0/28",
"lanes": "1,2,3,4",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet60": {
"alias": "fortyGigE0/60",
"lanes": "57,58,59,60",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet20": {
"alias": "fortyGigE0/20",
"lanes": "45,46,47,48",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
},
"Ethernet24": {
"alias": "fortyGigE0/24",
"lanes": "5,6,7,8",
"admin_status": "up"
"admin_status": "up",
"speed": "50000"
}
},
"VLAN": {
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
Loading
Loading