-
Notifications
You must be signed in to change notification settings - Fork 712
[GCU] Add PORT table StateDB Validator #2936
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
Conversation
|
||
|
||
def read_statedb_entry(table, field): | ||
state_db = SonicV2Connector(host="127.0.0.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.. is Table class recommended over SonicV2Connector use_unix_socket_path? In the future, this function may be extended to include tables other than PORT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, the benefit is no need to concat table name/separator/key. You can create multiple Table from one DBConnector, and they are not heavy.
if key == "speed": | ||
supported_speeds_str = read_statedb_entry('{}|{}'.format("PORT_TABLE", port), "supported_speeds") or '' | ||
supported_speeds = [int(s) for s in supported_speeds_str.split(',') if s] | ||
if supported_speeds and int(value) not in supported_speeds: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I added exception handling
patch_element_str = json.dumps(patch_element) | ||
path = patch_element["path"] | ||
value = patch_element.get("value") | ||
keys = ['fec', 'speed'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -145,6 +145,9 @@ | |||
} | |||
} | |||
} | |||
}, | |||
"PORT": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on 202305 branch, confirmed no cherry-pick conflicts |
Cherry-pick PR to 202305: #3096 |
Feature ADO 24806590
Test Case Bug Fix ADO 26158250
What I did
Add PORT table StateDB Validator
How I did it
Add new validating function for PORT table field and fec fields
How to verify it
Unit tests, updated sonic-mgmt tests: https://github.com/sonic-net/sonic-mgmt/pull/9403/files
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)