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:
parent
683099e3b0
commit
6ee44c694e
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
~~~
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user