rpc: rename RPC get_rpc_methods to rpc_get_methods

Make the old name a deprecated alias.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ibbf50676e0d989b67121e465fc140f94faec46ed

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453033
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2019-05-03 13:59:01 -07:00 committed by Darek Stojaczyk
parent 683099e3b0
commit 6ee44c694e
9 changed files with 32 additions and 30 deletions

View File

@ -86,7 +86,7 @@ will enter the `RUNTIME` state and the list of available commands becomes much
larger. larger.
To see which RPC methods are available in the current state, issue the 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. For more details see @ref jsonrpc documentation.

View File

@ -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 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. can list available commands by running this script with `-h` or `--help` flag.
Additionally user can retrieve currently supported set of RPC commands 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 Detailed help for each command can be displayed by adding `-h` flag as a
command parameter. command parameter.

View File

@ -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. Get an array of supported RPC methods.
@ -227,7 +227,7 @@ Example request:
{ {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"id": 1, "id": 1,
"method": "get_rpc_methods" "method": "rpc_get_methods"
} }
~~~ ~~~

View File

@ -340,25 +340,24 @@ spdk_rpc_close(void)
} }
} }
struct rpc_get_rpc_methods { struct rpc_get_methods {
bool current; bool current;
}; };
static const struct spdk_json_object_decoder rpc_get_rpc_methods_decoders[] = { static const struct spdk_json_object_decoder rpc_get_methods_decoders[] = {
{"current", offsetof(struct rpc_get_rpc_methods, current), spdk_json_decode_bool, true}, {"current", offsetof(struct rpc_get_methods, current), spdk_json_decode_bool, true},
}; };
static void static void
spdk_rpc_get_rpc_methods(struct spdk_jsonrpc_request *request, spdk_rpc_get_methods(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
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_json_write_ctx *w;
struct spdk_rpc_method *m; struct spdk_rpc_method *m;
if (params != NULL) { if (params != NULL) {
if (spdk_json_decode_object(params, rpc_get_rpc_methods_decoders, if (spdk_json_decode_object(params, rpc_get_methods_decoders,
SPDK_COUNTOF(rpc_get_rpc_methods_decoders), &req)) { SPDK_COUNTOF(rpc_get_methods_decoders), &req)) {
SPDK_ERRLOG("spdk_json_decode_object failed\n"); SPDK_ERRLOG("spdk_json_decode_object failed\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"Invalid parameters"); "Invalid parameters");
@ -381,7 +380,8 @@ spdk_rpc_get_rpc_methods(struct spdk_jsonrpc_request *request,
spdk_json_write_array_end(w); spdk_json_write_array_end(w);
spdk_jsonrpc_end_result(request, 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 static void
spdk_rpc_get_spdk_version(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params) spdk_rpc_get_spdk_version(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)

View File

@ -48,13 +48,13 @@ if __name__ == "__main__":
p = subparsers.add_parser('wait_subsystem_init', help='Block until subsystems have been initialized') p = subparsers.add_parser('wait_subsystem_init', help='Block until subsystems have been initialized')
p.set_defaults(func=wait_subsystem_init) p.set_defaults(func=wait_subsystem_init)
def get_rpc_methods(args): def rpc_get_methods(args):
print_dict(rpc.get_rpc_methods(args.client, print_dict(rpc.rpc_get_methods(args.client,
current=args.current)) 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.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): def get_spdk_version(args):
print(rpc.get_spdk_version(args.client)) print(rpc.get_spdk_version(args.client))

View File

@ -17,6 +17,7 @@ from . import subsystem
from . import trace from . import trace
from . import vhost from . import vhost
from . import client as rpc_client from . import client as rpc_client
from .helpers import deprecated_alias
def start_subsystem_init(client): def start_subsystem_init(client):
@ -29,7 +30,8 @@ def wait_subsystem_init(client):
return client.call('wait_subsystem_init') 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. """Get list of supported RPC methods.
Args: Args:
current: Get list of RPC methods only callable in the current state. 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: if current:
params['current'] = current params['current'] = current
return client.call('get_rpc_methods', params) return client.call('rpc_get_methods', params)
def get_spdk_version(client): def get_spdk_version(client):
@ -91,7 +93,7 @@ def load_config(client, fd):
subsystems.remove(subsystem) subsystems.remove(subsystem)
# check if methods in the config file are known # 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: if not subsystems and 'start_subsystem_init' in allowed_methods:
start_subsystem_init(client) start_subsystem_init(client)
return return
@ -103,7 +105,7 @@ def load_config(client, fd):
raise rpc_client.JSONRPCException("Unknown method was included in the config file") raise rpc_client.JSONRPCException("Unknown method was included in the config file")
while subsystems: while subsystems:
allowed_methods = client.call('get_rpc_methods', {'current': True}) allowed_methods = client.call('rpc_get_methods', {'current': True})
allowed_found = False allowed_found = False
for subsystem in list(subsystems): for subsystem in list(subsystems):
@ -155,13 +157,13 @@ def load_subsystem_config(client, fd):
if not subsystem['config']: if not subsystem['config']:
return return
allowed_methods = client.call('get_rpc_methods') allowed_methods = client.call('rpc_get_methods')
config = subsystem['config'] config = subsystem['config']
for elem in list(config): for elem in list(config):
if 'method' not in elem or elem['method'] not in allowed_methods: if 'method' not in elem or elem['method'] not in allowed_methods:
raise rpc_client.JSONRPCException("Unknown method was included in the config file") 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): for elem in list(config):
if 'method' not in elem or elem['method'] not in allowed_methods: if 'method' not in elem or elem['method'] not in allowed_methods:
continue continue

View File

@ -23,7 +23,7 @@ class UIRoot(UINode):
self.methods = [] self.methods = []
def refresh(self): 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: if self.is_init is False:
methods = "\n".join(self.methods) methods = "\n".join(self.methods)
self.shell.log.warning("SPDK Application is not yet initialized.\n" self.shell.log.warning("SPDK Application is not yet initialized.\n"
@ -95,11 +95,11 @@ class UIRoot(UINode):
with open(filename, "w") as fd: with open(filename, "w") as fd:
rpc.save_subsystem_config(self.client, fd, indent, subsystem) rpc.save_subsystem_config(self.client, fd, indent, subsystem)
def get_rpc_methods(self, current=False): def rpc_get_methods(self, current=False):
return rpc.get_rpc_methods(self.client, current=current) return rpc.rpc_get_methods(self.client, current=current)
def check_init(self): 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): def get_bdevs(self, bdev_type):
if self.is_init: if self.is_init:

View File

@ -359,7 +359,7 @@ function waitforlisten() {
# On FreeBSD netstat output 'State' column is missing for Unix sockets. # On FreeBSD netstat output 'State' column is missing for Unix sockets.
# To workaround this issue just try to use provided address. # To workaround this issue just try to use provided address.
# XXX: This solution could be used for other distros. # 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 break
fi fi
fi fi

View File

@ -89,7 +89,7 @@ spdk_jsonrpc_client_check_rpc_method(struct spdk_jsonrpc_client *client, char *m
return -ENOMEM; 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_end_request(request, w);
spdk_jsonrpc_client_send_request(client, request); spdk_jsonrpc_client_send_request(client, request);
@ -301,7 +301,7 @@ static void *
rpc_client_th(void *arg) rpc_client_th(void *arg)
{ {
struct spdk_jsonrpc_client *client = NULL; struct spdk_jsonrpc_client *client = NULL;
char *method_name = "get_rpc_methods"; char *method_name = "rpc_get_methods";
int rc; int rc;