Commit 139e4c07 authored by Pawel Kaminski's avatar Pawel Kaminski Committed by Jim Harris
Browse files

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: default avatarPawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465656


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 1f133d72
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -291,6 +291,7 @@ spdk_rpc_register_alias_deprecated(const char *method, const char *alias)

	m->is_alias_of = base;
	m->is_deprecated = true;
	m->state_mask = base->state_mask;

	/* TODO: use a hash table or sorted list */
	SLIST_INSERT_HEAD(&g_rpc_methods, m, slist);
@@ -342,10 +343,12 @@ spdk_rpc_close(void)

struct rpc_get_methods {
	bool current;
	bool include_aliases;
};

static const struct spdk_json_object_decoder rpc_get_methods_decoders[] = {
	{"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
@@ -368,6 +371,9 @@ spdk_rpc_get_methods(struct spdk_jsonrpc_request *request, const struct spdk_jso
	w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_array_begin(w);
	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)) {
			continue;
		}