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

[yang]: Add yang models for table BGP_ALLOWED_PREFIXES #10142

Merged
merged 2 commits into from
Mar 5, 2022

Conversation

StormLiangMS
Copy link
Contributor

@StormLiangMS StormLiangMS commented Mar 3, 2022

Why I did it

end2end test is blocked by Yang model for BGP allowed prefix list.

How I did it

Create new yang files for BGP allowed prefix list, and add UT.

How to verify it

Run UT for sonic-yang-models.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Fix: #9866

@StormLiangMS
Copy link
Contributor Author

@wen587 I verified this on master image, looks ok now, the reason is that the previous key pattern is wrong, I use "prefixs_p4", now it works.

admin@str-s6000-acs-11:$ ls
add.json verify_yang.py
admin@str-s6000-acs-11:
$ cat add.json
{
"BGP_ALLOWED_PREFIXES": {
"DEPLOYMENT_ID|0": {
"prefixes_v4": [
"10.20.0.0/16"
],
"prefixes_v6": [
"fc02:20::/64"
]
}
}
}
admin@str-s6000-acs-11:$ cat verify_yang.py
import subprocess
import sonic_yang
import json
def get_config_db_json():
cmd = "show runningconfiguration all"
result = subprocess.Popen(cmd, shell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
text, err = result.communicate()
return json.loads(text)
configDbJson = get_config_db_json()
sy = sonic_yang.SonicYang("/usr/local/yang-models")
sy.loadYangModel()
sy.loadData(configDbJson )
sy.validate_data_tree()
admin@str-s6000-acs-11:
$ python3 verify_yang.py
sonic_yang(6):Note: Below table(s) have no YANG models: CONSOLE_SWITCH, CRM, DHCP_SERVER, FEATURE, KDUMP, RESTAPI, SNMP, SNMP_COMMUNITY, TELEMETRY, XCVRD_LOG
admin@str-s6000-acs-11:~$

Copy link
Contributor

@wen587 wen587 left a comment

Choose a reason for hiding this comment

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

LGTM. Please wait for other reviewer's approval.

}

leaf community {
type string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does community have any pattern? 123:123?

Copy link
Contributor Author

@StormLiangMS StormLiangMS Mar 3, 2022

Choose a reason for hiding this comment

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

@ganglyu good catch, I found there are at least 2 different formats for community id, one is 4 bytes, the other is 2 bytes:2bytes, I took a reference from existing yang model files, all of them take string as the type of community and no pattern enforcement.
As you suggested, I think we should put a enforcement for the community id for all cases, filed an issue to track this, address this may beyond the scope of this PR.
#10145

@lguohan lguohan added the YANG YANG model related changes label Mar 4, 2022
@StormLiangMS StormLiangMS merged commit 55a0722 into sonic-net:master Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
YANG YANG model related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[yang] Need Yang for BGP_ALLOWED_PREFIXES table
5 participants