Skip to content
32 changes: 31 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,34 @@
else:
UNICODE_TYPE = unicode


# The new enhancements to this file provides capabilities to generate l1 & l3
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment looks more like PR description. I think this should be removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, it will require the comment update again once someone add an additional template..

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.

Thanks. Fixed the comments and uploaded the new change.

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.

The tests for both L1 & L3 passed as belows.

test_l1_ports_template (tests.test_j2files.TestJ2Files) ... ok
test_l3_ports_template (tests.test_j2files.TestJ2Files) ... ok

New failures are seen in unrleated area.

# 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):
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['LOOPBACK_INTERFACE'] = {"Loopback0": {},
"Loopback0|10.1.0.1/32": {}}
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 +123,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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you please add a unit test for this? You can refer as done for #7215

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.

Thanks for the comments. Added UT. Please review.

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.

@prsunny do you have any more comments or else would be able to approve this PR ?

'l3': generate_l3_config
}

def get_available_config():
Expand Down