RPC: rename get_notifications to notify_get_notifications

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ie050a22d31903414496e536ca97aeed3db5d2b22
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468936
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Maciej Wawryk 2019-09-20 10:35:27 +02:00 committed by Jim Harris
parent c7174d9e07
commit 85ab05d32b
5 changed files with 29 additions and 26 deletions

View File

@ -5531,7 +5531,7 @@ Example response:
} }
~~~ ~~~
## get_notifications {#get_notifications} ## notify_get_notifications {#notify_get_notifications}
Request notifications. Returns array of notifications that happend since the specified id (or first that is available). Request notifications. Returns array of notifications that happend since the specified id (or first that is available).
@ -5562,7 +5562,7 @@ Example request:
{ {
"id": 1, "id": 1,
"jsonrpc": "2.0", "jsonrpc": "2.0",
"method": "get_notifications", "method": "notify_get_notifications",
"params": { "params": {
"id": 1, "id": 1,
"max": 10 "max": 10

View File

@ -69,23 +69,23 @@ spdk_rpc_notify_get_types(struct spdk_jsonrpc_request *request,
SPDK_RPC_REGISTER("notify_get_types", spdk_rpc_notify_get_types, SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER("notify_get_types", spdk_rpc_notify_get_types, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(notify_get_types, get_notification_types) SPDK_RPC_REGISTER_ALIAS_DEPRECATED(notify_get_types, get_notification_types)
struct rpc_get_notifications { struct rpc_notify_get_notifications {
uint64_t id; uint64_t id;
uint64_t max; uint64_t max;
struct spdk_json_write_ctx *w; struct spdk_json_write_ctx *w;
}; };
static const struct spdk_json_object_decoder rpc_get_notifications_decoders[] = { static const struct spdk_json_object_decoder rpc_notify_get_notifications_decoders[] = {
{"id", offsetof(struct rpc_get_notifications, id), spdk_json_decode_uint64, true}, {"id", offsetof(struct rpc_notify_get_notifications, id), spdk_json_decode_uint64, true},
{"max", offsetof(struct rpc_get_notifications, max), spdk_json_decode_uint64, true}, {"max", offsetof(struct rpc_notify_get_notifications, max), spdk_json_decode_uint64, true},
}; };
static int static int
get_notifications_cb(uint64_t id, const struct spdk_notify_event *ev, void *ctx) notify_get_notifications_cb(uint64_t id, const struct spdk_notify_event *ev, void *ctx)
{ {
struct rpc_get_notifications *req = ctx; struct rpc_notify_get_notifications *req = ctx;
spdk_json_write_object_begin(req->w); spdk_json_write_object_begin(req->w);
spdk_json_write_named_string(req->w, "type", ev->type); spdk_json_write_named_string(req->w, "type", ev->type);
@ -96,14 +96,14 @@ get_notifications_cb(uint64_t id, const struct spdk_notify_event *ev, void *ctx)
} }
static void static void
spdk_rpc_get_notifications(struct spdk_jsonrpc_request *request, spdk_rpc_notify_get_notifications(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params) const struct spdk_json_val *params)
{ {
struct rpc_get_notifications req = {0, UINT64_MAX}; struct rpc_notify_get_notifications req = {0, UINT64_MAX};
if (params && if (params &&
spdk_json_decode_object(params, rpc_get_notifications_decoders, spdk_json_decode_object(params, rpc_notify_get_notifications_decoders,
SPDK_COUNTOF(rpc_get_notifications_decoders), &req)) { SPDK_COUNTOF(rpc_notify_get_notifications_decoders), &req)) {
SPDK_DEBUGLOG(SPDK_NOTIFY_RPC, "spdk_json_decode_object failed\n"); SPDK_DEBUGLOG(SPDK_NOTIFY_RPC, "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,
@ -115,11 +115,12 @@ spdk_rpc_get_notifications(struct spdk_jsonrpc_request *request,
req.w = spdk_jsonrpc_begin_result(request); req.w = spdk_jsonrpc_begin_result(request);
spdk_json_write_array_begin(req.w); spdk_json_write_array_begin(req.w);
spdk_notify_foreach_event(req.id, req.max, get_notifications_cb, &req); spdk_notify_foreach_event(req.id, req.max, notify_get_notifications_cb, &req);
spdk_json_write_array_end(req.w); spdk_json_write_array_end(req.w);
spdk_jsonrpc_end_result(request, req.w); spdk_jsonrpc_end_result(request, req.w);
} }
SPDK_RPC_REGISTER("get_notifications", spdk_rpc_get_notifications, SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER("notify_get_notifications", spdk_rpc_notify_get_notifications, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(notify_get_notifications, get_notifications)
SPDK_LOG_REGISTER_COMPONENT("notify_rpc", SPDK_NOTIFY_RPC) SPDK_LOG_REGISTER_COMPONENT("notify_rpc", SPDK_NOTIFY_RPC)

View File

@ -2018,16 +2018,17 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
help='List available notifications that user can subscribe to.') help='List available notifications that user can subscribe to.')
p.set_defaults(func=notify_get_types) p.set_defaults(func=notify_get_types)
def get_notifications(args): def notify_get_notifications(args):
ret = rpc.notify.get_notifications(args.client, ret = rpc.notify.notify_get_notifications(args.client,
id=args.id, id=args.id,
max=args.max) max=args.max)
print_dict(ret) print_dict(ret)
p = subparsers.add_parser('get_notifications', help='Get notifications') p = subparsers.add_parser('notify_get_notifications', aliases=['get_notifications'],
help='Get notifications')
p.add_argument('-i', '--id', help="""First ID to start fetching from""", type=int) p.add_argument('-i', '--id', help="""First ID to start fetching from""", type=int)
p.add_argument('-n', '--max', help="""Maximum number of notifications to return in response""", type=int) p.add_argument('-n', '--max', help="""Maximum number of notifications to return in response""", type=int)
p.set_defaults(func=get_notifications) p.set_defaults(func=notify_get_notifications)
def thread_get_stats(args): def thread_get_stats(args):
print_dict(rpc.app.thread_get_stats(args.client)) print_dict(rpc.app.thread_get_stats(args.client))

View File

@ -6,9 +6,10 @@ def notify_get_types(client):
return client.call("notify_get_types") return client.call("notify_get_types")
def get_notifications(client, @deprecated_alias('get_notifications')
id=None, def notify_get_notifications(client,
max=None): id=None,
max=None):
""" """
Args: Args:
@ -26,4 +27,4 @@ def get_notifications(client,
if max: if max:
params['max'] = max params['max'] = max
return client.call("get_notifications", params) return client.call("notify_get_notifications", params)

View File

@ -87,7 +87,7 @@ function tgt_check_notifications() {
fi fi
shift shift
done < <(tgt_rpc get_notifications -i ${last_event_id} | jq -r '.[] | "\(.type):\(.ctx):\(.id)"') done < <(tgt_rpc notify_get_notifications -i ${last_event_id} | jq -r '.[] | "\(.type):\(.ctx):\(.id)"')
$rc $rc