Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GCU] Handling non-compliant leaf-list with string values (#2174)
#### What I did Fixes #2170 Converting xpath to path: - There is only 1 case where the path is referring to the list itself. Example: ``` path="/BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list", xpath="/sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet9']/profile_list", ``` - There is no other case as we the list is just a single string, and we cannot refer to individual elements in string in ConfigDb. Converting path to xpath, there are 2 cases: - Xpath is pointing to leaf-list as a whole, return path of whole list ``` xpath="/sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet9']/profile_list", path="/BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list", ``` - Xpath is pointing to an element of the leaf-list, return path of whole list as well since it is not possible to point to specific element -- here we are pointing to the element `egress_lossy_profile` ``` xpath="/sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet9']/profile_list[.='egress_lossy_profile']", path="/BUFFER_PORT_EGRESS_PROFILE_LIST/Ethernet9/profile_list", ``` #### How I did it Only a single change if the xpath is pointing to a specific element, just return whole list token from ConfigDb format. Please note this solution is future proof, if ConfigDb changes how a list is saved as a string or json list, we don't care. #### How to verify it unit-test #### 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)
- Loading branch information