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

[bluefield] Add new 'appliance' sample config for DPU platforms. #109

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
38 changes: 36 additions & 2 deletions src/sonic-config-engine/config_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def generate_common_config(data):
# 'l2': generate_l2_config,
# 'empty': generate_empty_config,
# 'l1': generate_l1_config,
# 'l3': generate_l3_config
# 'l3': generate_l3_config,
# 'appliance': generate_appliance_config

def generate_l1_config(data):
for port in natsorted(data['PORT']):
Expand Down Expand Up @@ -243,13 +244,46 @@ def generate_l2_config(data):
data['VLAN_MEMBER']['Vlan1000|{}'.format(port)] = {'tagging_mode': 'untagged'}
return data

def generate_appliance_config(data):
data['DEVICE_METADATA']['localhost']['hostname'] = 'sonic'
data['DEVICE_METADATA']['localhost']['switch_type'] = 'dpu'
data['DEVICE_METADATA']['localhost']['type'] = 'SonicHost'
data['DEVICE_METADATA']['localhost']['subtype'] = 'Appliance'
data['DEVICE_METADATA']['localhost']['bgp_asn'] = '65100'
data['LOOPBACK_INTERFACE'] = {"Loopback0|10.1.0.1/32": {}}
data['BGP_NEIGHBOR'] = {}
data['DEVICE_NEIGHBOR'] = {}
data['INTERFACE'] = {}
port_number = 0
total_port_amount = len(data['PORT'])
for port in natsorted(data['PORT']):
data['PORT'][port]['admin_status'] = 'up'
data['PORT'][port]['mtu'] = '9100'
local_addr = '10.0.{}.{}'.format(2 * port_number // 256, 2 * port_number % 256)
peer_addr = '10.0.{}.{}'.format(2 * port_number // 256, 2 * port_number % 256 + 1)
peer_name='ARISTA{0:02d}T1'.format(1 + port_number % (total_port_amount // 2))
peer_asn = 64001 + port_number
data['INTERFACE']['{}|{}/31'.format(port, local_addr)] = {}
data['BGP_NEIGHBOR'][peer_addr] = {
'rrclient': 0,
'name': peer_name,
'local_addr': local_addr,
'nhopself': 0,
'holdtime': '180',
'asn': str(peer_asn),
'keepalive': '60'
}
port_number += 1
return data

_sample_generators = {
't1': generate_t1_sample_config,
'l2': generate_l2_config,
't1-smartswitch': generate_t1_smartswitch_sample_config,
'empty': generate_empty_config,
'l1': generate_l1_config,
'l3': generate_l3_config
'l3': generate_l3_config,
'appliance': generate_appliance_config
}

def get_available_config():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ module sonic-device_metadata {

leaf subtype {
type string {
pattern "DualToR|SmartSwitch";
pattern "DualToR|SmartSwitch|Appliance";
}
}

Expand Down