[sonic-cfggen]: add --key option to show a specific key#3248
[sonic-cfggen]: add --key option to show a specific key#3248lguohan merged 5 commits intosonic-net:masterfrom
Conversation
…y config DB with more granularity. Signed-off-by: Vasant Patil <vapatil@linkedin.com>
src/sonic-config-engine/sonic-cfggen
Outdated
| group.add_argument("--print-data", help="print all data", action='store_true') | ||
| group.add_argument("--preset", help="generate sample configuration from a preset template", choices=get_available_config()) | ||
| group = parser.add_mutually_exclusive_group() | ||
| group.add_argument("-f", "--find", help="Find/Search for a specific key") |
There was a problem hiding this comment.
what is the difference between --var-json.
There was a problem hiding this comment.
--var-json is used to query one level higher keys. For example: BGP_NEIGHBOR, DEVICE_METADATA, INTERFACE, PORT, etc.. where as --find is used query one level down. For example Ethernet0 under PORT.
There was a problem hiding this comment.
then, why not use -k, --key option which is more specific?
There was a problem hiding this comment.
I though so as well, since -k is taken by hwSKU, I used -f. Please suggest if you have any other better alternative.
There was a problem hiding this comment.
Sounds good. Let me change that!
src/sonic-config-engine/sonic-cfggen
Outdated
|
|
||
| @staticmethod | ||
| def to_serialized(data): | ||
| def to_serialized(data, find_key = ""): |
|
when you add new function, please add sonic-cfggen unit test. |
|
Added 2 unit test cases. Below lines are copied from log file. |
* Adding --key option to sonic-cfggen script. This will help to display config DB with more granularity. Signed-off-by: Vasant Patil <vapatil@linkedin.com>
Signed-off-by: Vasant Patil vapatil@linkedin.com
This will help to dispy config DB with more granularity.
For example:
show runningconfiguration interface Ethernet0
show runningconfiguration interfaces Ethernet0
Testing done:
](url)
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)