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
cfg_rpc: extending the functionality of cfg.get command #1321
Conversation
- rpc_get function can be also called with only entering the group name information. Before it used to work only with group name and variable name and returning the value for a variable. With the enhancement, it is also possible to retrieve all variable values belonging to a specific group. e.g.: kamcmd cfg.get core. Above given example will print the values of all variables of the configuration group "core".
var.len = 0; | ||
} | ||
else return; | ||
} |
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 think that the right way is to read with optional specifier *
:
n = rpc->scan(c, "S*S", &group, &var);
Then n is 2 if both were read or 1 if only group is read.
When n is -1, there can be other errors.
Otherwise, the patch is useful, thanks!
Can you do a new patch based on what I suggested? It can be a follow up of this one, we can squash from the web when merging.
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 for the review, sure i'll send a new patch with the changes.
@hdikme - planning to have the new patch soon? Just to evaluate if this needs to be in 5.1 or not which is going to be out in few days... |
@miconda - I have tested the code with the changes based on your review. First part is indeed more appropriate (S*S) but i have a problem with the value of n. If only one parameter (group name) is given , n is still assigned -1. Either way S*S or SS returns -1. What do you think? |
What do you use to send the rpc commands - |
Yes, I use kamcmd as I think this is the new one and this should replace kamctl someday in the future. I tried with kamctl rpc, but it just prints out the help page of kamctl. It seems kamctl does not know rpc as a parameter. Maybe you can provide me a more detailed description how to test this with kamctl? Or maybe it's even faster you test it yourself using kamctl? |
Are you testing with master branch (or 5.x)? |
Btw, kamcmd is not a replacement for kamctl. kamcmd is only a binrpc client application that connects to ctl module of kamailio. kamcli might replace kamctl, but no timeline for that. kamctl is still very active maintained and enhanced with each release. |
I have tested it with the version 5.0.1 using kamctl rpc ... and the result hasn't changed. |
- if only one parameter is given (group name), cfg.get returns a structure with all variables and their values in the group - patched enhaced from the PR #1321 by Huseyin Dikme <hueseyin.dikme@1und1.de>
The issue with Besides using the |
Before it used to work only with group name and variable name and returning the value for a variable.
With the enhancement, it is also possible to retrieve all variable values belonging to a specific group.
e.g.: kamcmd cfg.get core.
Above given example will print the values of all variables of the configuration group "core".
Pre-Submission Checklist
in
doc/
subfolder, the README file is autogenerated)Type Of Change
Checklist:
Description
rpc_get function can be also called with only entering the group name information.
Before it used to work only with group name and variable name and returning the value for a variable.
With the enhancement, it is also possible to retrieve all variable values belonging to a specific group.
e.g.: kamcmd cfg.get core.
Above given example will print the values of all variables of the configuration group "core".