rpc: add get_spdk_version rpc method

Change-Id: Iacc1766a60fb1e15a1013475f83f7f13cd45fe12
Signed-off-by: Chunyang Hui <chunyang.hui@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448613
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Chunyang Hui 2019-03-21 18:02:04 -04:00 committed by Jim Harris
parent b949f1318e
commit 38902a5a27
5 changed files with 91 additions and 0 deletions

View File

@ -67,6 +67,10 @@ spdk_env_fini() and spdk_env_dpdk_post_fini() were added to release any resource
allocated by spdk_env_init() or spdk_env_dpdk_post_init() respectively. It is expected
that common usage of those functions is to call them just before terminating the process.
### rpc
New `get_spdk_version` RPC method is introduced to get version info of the running SPDK application.
## v19.01:
### ocf bdev

View File

@ -5074,3 +5074,43 @@ Example response:
}
~~~
## get_spdk_version {#rpc_get_spdk_version}
Get the version info of the running SPDK application.
### Parameters
This method has no parameters.
### Response
The response is the version number including major version number, minor version number, patch level number and suffix string.
### Example
Example request:
~~
{
"jsonrpc": "2.0",
"id": 1,
"method": "get_spdk_version"
}
~~
Example response:
~~
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"version": "19.04-pre",
"fields" : {
"major": 19,
"minor": 4,
"patch": 0,
"suffix": "-pre"
}
}
}
~~

View File

@ -41,6 +41,7 @@
#include "spdk/log.h"
#include "spdk/string.h"
#include "spdk/util.h"
#include "spdk/version.h"
#define RPC_DEFAULT_PORT "5260"
@ -309,3 +310,38 @@ spdk_rpc_get_rpc_methods(struct spdk_jsonrpc_request *request,
spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("get_rpc_methods", spdk_rpc_get_rpc_methods, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
static void
spdk_rpc_get_version(struct spdk_jsonrpc_request *request, const struct spdk_json_val *params)
{
struct spdk_json_write_ctx *w;
if (params != NULL) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"get_spdk_version method requires no parameters");
}
w = spdk_jsonrpc_begin_result(request);
if (w == NULL) {
return;
}
spdk_json_write_object_begin(w);
spdk_json_write_named_string_fmt(w, "version", "%s", SPDK_VERSION_STRING);
spdk_json_write_named_object_begin(w, "fields");
spdk_json_write_named_uint32(w, "major", SPDK_VERSION_MAJOR);
spdk_json_write_named_uint32(w, "minor", SPDK_VERSION_MINOR);
spdk_json_write_named_uint32(w, "patch", SPDK_VERSION_PATCH);
spdk_json_write_named_string_fmt(w, "suffix", "%s", SPDK_VERSION_SUFFIX);
spdk_json_write_object_end(w);
spdk_json_write_object_end(w);
spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("get_spdk_version", spdk_rpc_get_version, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)

View File

@ -54,6 +54,12 @@ if __name__ == "__main__":
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)
def get_spdk_version(args):
print(rpc.get_spdk_version(args.client))
p = subparsers.add_parser('get_spdk_version', help='Get SPDK version')
p.set_defaults(func=get_spdk_version)
def save_config(args):
rpc.save_config(args.client,
sys.stdout,

View File

@ -41,6 +41,11 @@ def get_rpc_methods(client, current=None):
return client.call('get_rpc_methods', params)
def get_spdk_version(client):
"""Get SPDK version"""
return client.call('get_spdk_version')
def _json_dump(config, fd, indent):
if indent is None:
indent = 2