Skip to content
Closed
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
37 changes: 36 additions & 1 deletion src/sonic-config-engine/config_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@
else:
UNICODE_TYPE = unicode


# The new enhancements to this file provides capabilities to generate l1 & l3
# configuration in addition the existing l2, t1 and empty configurations
# So the following capabilities exits now:
# 't1': generate_t1_sample_config,
# 'l2': generate_l2_config,
# 'empty': generate_empty_config,
# 'l1': generate_l1_config,
# 'l3': generate_l3_config

def generate_l1_config(data):
data['DEVICE_METADATA']['localhost']['hostname'] = 'sonic'
data['DEVICE_METADATA']['localhost']['type'] = 'LeafRouter'
for port in natsorted(data['PORT']):
data['PORT'][port]['admin_status'] = 'up'
data['PORT'][port]['mtu'] = '9100'
return data;

def generate_l3_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": {},
"Loopback0|10.1.0.1/32": {}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove those hardcoded 'type', 'bgp_asn' and 'LOOPBACK_INTERFACE'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-config-engine/config_samples.py
The new methods for L1 & L3 are just extensions to the existing methods and has the minimum set of parameters required for L1 & L3 System bringup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked thru #7637

data['BGP_NEIGHBOR'] = {}
data['DEVICE_NEIGHBOR'] = {}
data['INTERFACE'] = {}
for port in natsorted(data['PORT']):
data['PORT'][port]['admin_status'] = 'up'
data['PORT'][port]['mtu'] = '9100'
data['INTERFACE']['{}'.format(port)] = {}
return data;

def generate_t1_sample_config(data):
data['DEVICE_METADATA']['localhost']['hostname'] = 'sonic'
data['DEVICE_METADATA']['localhost']['type'] = 'LeafRouter'
Expand Down Expand Up @@ -95,7 +128,9 @@ def generate_l2_config(data):
_sample_generators = {
't1': generate_t1_sample_config,
'l2': generate_l2_config,
'empty': generate_empty_config
'empty': generate_empty_config,
'l1': generate_l1_config,
'l3': generate_l3_config
Copy link
Copy Markdown
Collaborator

@lguohan lguohan Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain what is l1, l3 config and why we need them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L1 configuration generates only the default port admin_status and mtu values. This is minimally required configuration for any system interfaces to come up.

L2 configuration generates Vlan interface configuration. For instance the api generate_l2_config is generating Vlan1000 data port configuration. A "routed" system may not need a L2 configuration

def generate_l2_config(data):
data['VLAN'] = {'Vlan1000': {'vlanid': '1000'}}
data['VLAN_MEMBER'] = {}
for port in natsorted(data['PORT']):
data['PORT'][port].setdefault('admin_status', 'up')
data['VLAN_MEMBER']['Vlan1000|{}'.format(port)] = {'tagging_mode': 'untagged'}
return data

L3 generates "routed" configuration like, which are minimally required for configuring the system as a L3 device.

  • BGP ASN
  • Loopback IP
  • Dummy Interfaces

}

def get_available_config():
Expand Down