From 6ee44c694e0101f9d6d3d47d1e2428f8ee8e7c79 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 3 May 2019 13:59:01 -0700 Subject: [PATCH] rpc: rename RPC get_rpc_methods to rpc_get_methods Make the old name a deprecated alias. Signed-off-by: Jim Harris Change-Id: Ibbf50676e0d989b67121e465fc140f94faec46ed Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453033 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- doc/applications.md | 2 +- doc/bdev.md | 2 +- doc/jsonrpc.md | 4 ++-- lib/rpc/rpc.c | 18 +++++++++--------- scripts/rpc.py | 8 ++++---- scripts/rpc/__init__.py | 14 ++++++++------ scripts/spdkcli/ui_root.py | 8 ++++---- test/common/autotest_common.sh | 2 +- test/rpc_client/rpc_client_test.c | 4 ++-- 9 files changed, 32 insertions(+), 30 deletions(-) diff --git a/doc/applications.md b/doc/applications.md index 3bfd54a2e..cb360c7f1 100644 --- a/doc/applications.md +++ b/doc/applications.md @@ -86,7 +86,7 @@ will enter the `RUNTIME` state and the list of available commands becomes much larger. To see which RPC methods are available in the current state, issue the -`get_rpc_methods` with the parameter `current` set to `true`. +`rpc_get_methods` with the parameter `current` set to `true`. For more details see @ref jsonrpc documentation. diff --git a/doc/bdev.md b/doc/bdev.md index 9cedd5329..568f7b6cc 100644 --- a/doc/bdev.md +++ b/doc/bdev.md @@ -31,7 +31,7 @@ chapters is done by using JSON-RPC commands. SPDK provides a python-based command line tool for sending RPC commands located at `scripts/rpc.py`. User can list available commands by running this script with `-h` or `--help` flag. Additionally user can retrieve currently supported set of RPC commands -directly from SPDK application by running `scripts/rpc.py get_rpc_methods`. +directly from SPDK application by running `scripts/rpc.py rpc_get_methods`. Detailed help for each command can be displayed by adding `-h` flag as a command parameter. diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 0f568ac4c..aa0bd45ec 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -205,7 +205,7 @@ Example response: } ~~~ -## get_rpc_methods {#rpc_get_rpc_methods} +## rpc_get_methods {#rpc_rpc_get_methods} Get an array of supported RPC methods. @@ -227,7 +227,7 @@ Example request: { "jsonrpc": "2.0", "id": 1, - "method": "get_rpc_methods" + "method": "rpc_get_methods" } ~~~ diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index ff20a4685..dbd2f8865 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -340,25 +340,24 @@ spdk_rpc_close(void) } } -struct rpc_get_rpc_methods { +struct rpc_get_methods { bool current; }; -static const struct spdk_json_object_decoder rpc_get_rpc_methods_decoders[] = { - {"current", offsetof(struct rpc_get_rpc_methods, current), spdk_json_decode_bool, true}, +static const struct spdk_json_object_decoder rpc_get_methods_decoders[] = { + {"current", offsetof(struct rpc_get_methods, current), spdk_json_decode_bool, true}, }; static void -spdk_rpc_get_rpc_methods(struct spdk_jsonrpc_request *request, - const struct spdk_json_val *params) +spdk_rpc_get_methods(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params) { - struct rpc_get_rpc_methods req = {}; + struct rpc_get_methods req = {}; struct spdk_json_write_ctx *w; struct spdk_rpc_method *m; if (params != NULL) { - if (spdk_json_decode_object(params, rpc_get_rpc_methods_decoders, - SPDK_COUNTOF(rpc_get_rpc_methods_decoders), &req)) { + if (spdk_json_decode_object(params, rpc_get_methods_decoders, + SPDK_COUNTOF(rpc_get_methods_decoders), &req)) { SPDK_ERRLOG("spdk_json_decode_object failed\n"); spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters"); @@ -381,7 +380,8 @@ spdk_rpc_get_rpc_methods(struct spdk_jsonrpc_request *request, spdk_json_write_array_end(w); spdk_jsonrpc_end_result(request, w); } -SPDK_RPC_REGISTER("get_rpc_methods", spdk_rpc_get_rpc_methods, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER("rpc_get_methods", spdk_rpc_get_methods, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER_ALIAS_DEPRECATED(rpc_get_methods, get_rpc_methods) static void spdk_rpc_get_spdk_version(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params) diff --git a/scripts/rpc.py b/scripts/rpc.py index 7bab8795e..625243efa 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -48,13 +48,13 @@ if __name__ == "__main__": p = subparsers.add_parser('wait_subsystem_init', help='Block until subsystems have been initialized') p.set_defaults(func=wait_subsystem_init) - def get_rpc_methods(args): - print_dict(rpc.get_rpc_methods(args.client, + def rpc_get_methods(args): + print_dict(rpc.rpc_get_methods(args.client, current=args.current)) - p = subparsers.add_parser('get_rpc_methods', help='Get list of supported RPC methods') + p = subparsers.add_parser('rpc_get_methods', help='Get list of supported RPC methods', aliases=['get_rpc_methods']) p.add_argument('-c', '--current', help='Get list of RPC methods only callable in the current state.', action='store_true') - p.set_defaults(func=get_rpc_methods) + p.set_defaults(func=rpc_get_methods) def get_spdk_version(args): print(rpc.get_spdk_version(args.client)) diff --git a/scripts/rpc/__init__.py b/scripts/rpc/__init__.py index 0f29373e1..4623a19f9 100644 --- a/scripts/rpc/__init__.py +++ b/scripts/rpc/__init__.py @@ -17,6 +17,7 @@ from . import subsystem from . import trace from . import vhost from . import client as rpc_client +from .helpers import deprecated_alias def start_subsystem_init(client): @@ -29,7 +30,8 @@ def wait_subsystem_init(client): return client.call('wait_subsystem_init') -def get_rpc_methods(client, current=None): +@deprecated_alias("get_rpc_methods") +def rpc_get_methods(client, current=None): """Get list of supported RPC methods. Args: current: Get list of RPC methods only callable in the current state. @@ -39,7 +41,7 @@ def get_rpc_methods(client, current=None): if current: params['current'] = current - return client.call('get_rpc_methods', params) + return client.call('rpc_get_methods', params) def get_spdk_version(client): @@ -91,7 +93,7 @@ def load_config(client, fd): subsystems.remove(subsystem) # check if methods in the config file are known - allowed_methods = client.call('get_rpc_methods') + allowed_methods = client.call('rpc_get_methods') if not subsystems and 'start_subsystem_init' in allowed_methods: start_subsystem_init(client) return @@ -103,7 +105,7 @@ def load_config(client, fd): raise rpc_client.JSONRPCException("Unknown method was included in the config file") while subsystems: - allowed_methods = client.call('get_rpc_methods', {'current': True}) + allowed_methods = client.call('rpc_get_methods', {'current': True}) allowed_found = False for subsystem in list(subsystems): @@ -155,13 +157,13 @@ def load_subsystem_config(client, fd): if not subsystem['config']: return - allowed_methods = client.call('get_rpc_methods') + allowed_methods = client.call('rpc_get_methods') config = subsystem['config'] for elem in list(config): if 'method' not in elem or elem['method'] not in allowed_methods: raise rpc_client.JSONRPCException("Unknown method was included in the config file") - allowed_methods = client.call('get_rpc_methods', {'current': True}) + allowed_methods = client.call('rpc_get_methods', {'current': True}) for elem in list(config): if 'method' not in elem or elem['method'] not in allowed_methods: continue diff --git a/scripts/spdkcli/ui_root.py b/scripts/spdkcli/ui_root.py index 3bd6c4b15..b2485eedd 100644 --- a/scripts/spdkcli/ui_root.py +++ b/scripts/spdkcli/ui_root.py @@ -23,7 +23,7 @@ class UIRoot(UINode): self.methods = [] def refresh(self): - self.methods = self.get_rpc_methods(current=True) + self.methods = self.rpc_get_methods(current=True) if self.is_init is False: methods = "\n".join(self.methods) self.shell.log.warning("SPDK Application is not yet initialized.\n" @@ -95,11 +95,11 @@ class UIRoot(UINode): with open(filename, "w") as fd: rpc.save_subsystem_config(self.client, fd, indent, subsystem) - def get_rpc_methods(self, current=False): - return rpc.get_rpc_methods(self.client, current=current) + def rpc_get_methods(self, current=False): + return rpc.rpc_get_methods(self.client, current=current) def check_init(self): - return "start_subsystem_init" not in self.get_rpc_methods(current=True) + return "start_subsystem_init" not in self.rpc_get_methods(current=True) def get_bdevs(self, bdev_type): if self.is_init: diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index faa98aaf2..ab643e666 100644 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -359,7 +359,7 @@ function waitforlisten() { # On FreeBSD netstat output 'State' column is missing for Unix sockets. # To workaround this issue just try to use provided address. # XXX: This solution could be used for other distros. - if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" get_rpc_methods &>/dev/null; then + if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" rpc_get_methods &>/dev/null; then break fi fi diff --git a/test/rpc_client/rpc_client_test.c b/test/rpc_client/rpc_client_test.c index 938749fd7..228d6754d 100644 --- a/test/rpc_client/rpc_client_test.c +++ b/test/rpc_client/rpc_client_test.c @@ -89,7 +89,7 @@ spdk_jsonrpc_client_check_rpc_method(struct spdk_jsonrpc_client *client, char *m return -ENOMEM; } - w = spdk_jsonrpc_begin_request(request, 1, "get_rpc_methods"); + w = spdk_jsonrpc_begin_request(request, 1, "rpc_get_methods"); spdk_jsonrpc_end_request(request, w); spdk_jsonrpc_client_send_request(client, request); @@ -301,7 +301,7 @@ static void * rpc_client_th(void *arg) { struct spdk_jsonrpc_client *client = NULL; - char *method_name = "get_rpc_methods"; + char *method_name = "rpc_get_methods"; int rc;