-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[sonic-cfggen]: add --key option to show a specific key #3248
[sonic-cfggen]: add --key option to show a specific key #3248
Conversation
…y config DB with more granularity. Signed-off-by: Vasant Patil <vapatil@linkedin.com>
src/sonic-config-engine/sonic-cfggen
Outdated
@@ -181,6 +190,8 @@ def main(): | |||
group.add_argument("-w", "--write-to-db", help="write config into configdb", action='store_true') | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between --var-json.
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.
--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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then, why not use -k, --key option which is more specific?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-K
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.
Sounds good. Let me change that!
src/sonic-config-engine/sonic-cfggen
Outdated
@@ -124,9 +124,18 @@ TODO(taoyl): Current version of config db only supports BGP admin states. | |||
return db_data | |||
|
|||
@staticmethod | |||
def to_serialized(data): | |||
def to_serialized(data, find_key = ""): |
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.
-> lookup_key = None
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)