lib/rpc: Add include_aliases flag to rpc_get_methods implementation.
When getting the list of available RPCs from a tool like rpc.py, aliases often should be hidden. However, when getting the list of RPCs available for loading from a JSON config file, aliases should be included. Change-Id: Ie22d8b0ec2515d37dbfadf01b5cb709c160beb3e Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465656 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
1f133d7279
commit
139e4c0783
@ -291,6 +291,7 @@ spdk_rpc_register_alias_deprecated(const char *method, const char *alias)
|
|||||||
|
|
||||||
m->is_alias_of = base;
|
m->is_alias_of = base;
|
||||||
m->is_deprecated = true;
|
m->is_deprecated = true;
|
||||||
|
m->state_mask = base->state_mask;
|
||||||
|
|
||||||
/* TODO: use a hash table or sorted list */
|
/* TODO: use a hash table or sorted list */
|
||||||
SLIST_INSERT_HEAD(&g_rpc_methods, m, slist);
|
SLIST_INSERT_HEAD(&g_rpc_methods, m, slist);
|
||||||
@ -342,10 +343,12 @@ spdk_rpc_close(void)
|
|||||||
|
|
||||||
struct rpc_get_methods {
|
struct rpc_get_methods {
|
||||||
bool current;
|
bool current;
|
||||||
|
bool include_aliases;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct spdk_json_object_decoder rpc_get_methods_decoders[] = {
|
static const struct spdk_json_object_decoder rpc_get_methods_decoders[] = {
|
||||||
{"current", offsetof(struct rpc_get_methods, current), spdk_json_decode_bool, true},
|
{"current", offsetof(struct rpc_get_methods, current), spdk_json_decode_bool, true},
|
||||||
|
{"include_aliases", offsetof(struct rpc_get_methods, include_aliases), spdk_json_decode_bool, true},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -368,6 +371,9 @@ spdk_rpc_get_methods(struct spdk_jsonrpc_request *request, const struct spdk_jso
|
|||||||
w = spdk_jsonrpc_begin_result(request);
|
w = spdk_jsonrpc_begin_result(request);
|
||||||
spdk_json_write_array_begin(w);
|
spdk_json_write_array_begin(w);
|
||||||
SLIST_FOREACH(m, &g_rpc_methods, slist) {
|
SLIST_FOREACH(m, &g_rpc_methods, slist) {
|
||||||
|
if (m->is_alias_of != NULL && !req.include_aliases) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (req.current && ((m->state_mask & g_rpc_state) != g_rpc_state)) {
|
if (req.current && ((m->state_mask & g_rpc_state) != g_rpc_state)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user