iscsi&scripts/rpc: Add get_iscsi_auth_groups RPC to get current configuration
Add an new RPC to get current authentication group configuration. This patch is utilized in the next patch to support JSON config dump for authentication group configuration. Change-Id: I34be9e196f8e7a484bcd316da54f05d0f6ee0300 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/421468 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
ad323b8064
commit
3a08001dd4
@ -2008,6 +2008,65 @@ Example response:
|
||||
}
|
||||
~~~
|
||||
|
||||
## get_iscsi_auth_groups {#rpc_get_iscsi_auth_groups}
|
||||
|
||||
Show information about all existing authentication group for CHAP authentication.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method has no parameters.
|
||||
|
||||
### Result
|
||||
|
||||
Array of objects describing authentication group.
|
||||
|
||||
Name | Type | Description
|
||||
--------------------------- | --------| -----------
|
||||
tag | number | Authentication group tag
|
||||
secrets | array | Array of @ref rpc_add_iscsi_auth_group_secret objects
|
||||
|
||||
### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "get_iscsi_auth_groups",
|
||||
"id": 1
|
||||
}
|
||||
~~~
|
||||
Example response:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": [
|
||||
{
|
||||
"secrets": [
|
||||
{
|
||||
"muser": "mu1",
|
||||
"secret": "s1",
|
||||
"user": "u1",
|
||||
"msecret": "ms1"
|
||||
}
|
||||
],
|
||||
"tag": 1
|
||||
},
|
||||
{
|
||||
"secrets": [
|
||||
{
|
||||
"secret": "s2",
|
||||
"user": "u2"
|
||||
}
|
||||
],
|
||||
"tag": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
~~~
|
||||
|
||||
## add_secret_to_iscsi_auth_group {#rpc_add_secret_to_iscsi_auth_group}
|
||||
|
||||
Add a secret to an existing authentication group for CHAP authentication.
|
||||
|
@ -408,6 +408,7 @@ int spdk_iscsi_auth_group_add_secret(struct spdk_iscsi_auth_group *group,
|
||||
const char *muser, const char *msecret);
|
||||
int spdk_iscsi_auth_group_delete_secret(struct spdk_iscsi_auth_group *group,
|
||||
const char *user);
|
||||
void spdk_iscsi_auth_groups_info_json(struct spdk_json_write_ctx *w);
|
||||
|
||||
void spdk_iscsi_send_nopin(struct spdk_iscsi_conn *conn);
|
||||
void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
|
||||
|
@ -1515,3 +1515,28 @@ spdk_rpc_delete_secret_from_iscsi_auth_group(struct spdk_jsonrpc_request *reques
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_secret_from_iscsi_auth_group",
|
||||
spdk_rpc_delete_secret_from_iscsi_auth_group, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_iscsi_auth_groups(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_iscsi_auth_groups requires no parameters");
|
||||
return;
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
if (w == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_json_write_array_begin(w);
|
||||
spdk_iscsi_auth_groups_info_json(w);
|
||||
spdk_json_write_array_end(w);
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_iscsi_auth_groups", spdk_rpc_get_iscsi_auth_groups, SPDK_RPC_RUNTIME)
|
||||
|
@ -1424,6 +1424,45 @@ spdk_iscsi_opts_info_json(struct spdk_json_write_ctx *w)
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_iscsi_auth_group_info_json(struct spdk_iscsi_auth_group *group,
|
||||
struct spdk_json_write_ctx *w)
|
||||
{
|
||||
struct spdk_iscsi_auth_secret *_secret;
|
||||
|
||||
spdk_json_write_object_begin(w);
|
||||
|
||||
spdk_json_write_named_int32(w, "tag", group->tag);
|
||||
|
||||
spdk_json_write_named_array_begin(w, "secrets");
|
||||
TAILQ_FOREACH(_secret, &group->secret_head, tailq) {
|
||||
spdk_json_write_object_begin(w);
|
||||
|
||||
spdk_json_write_named_string(w, "user", _secret->user);
|
||||
spdk_json_write_named_string(w, "secret", _secret->secret);
|
||||
|
||||
if (_secret->muser[0] != '\0') {
|
||||
spdk_json_write_named_string(w, "muser", _secret->muser);
|
||||
spdk_json_write_named_string(w, "msecret", _secret->msecret);
|
||||
}
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
spdk_json_write_array_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
void
|
||||
spdk_iscsi_auth_groups_info_json(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
struct spdk_iscsi_auth_group *group;
|
||||
|
||||
TAILQ_FOREACH(group, &g_spdk_iscsi.auth_group_head, tailq) {
|
||||
spdk_iscsi_auth_group_info_json(group, w);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_iscsi_opts_config_json(struct spdk_json_write_ctx *w)
|
||||
{
|
||||
|
@ -600,6 +600,14 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
p.add_argument('-u', '--user', help='User name for one-way CHAP authentication', required=True)
|
||||
p.set_defaults(func=delete_secret_from_iscsi_auth_group)
|
||||
|
||||
@call_cmd
|
||||
def get_iscsi_auth_groups(args):
|
||||
print_dict(rpc.iscsi.get_iscsi_auth_groups(args.client))
|
||||
|
||||
p = subparsers.add_parser('get_iscsi_auth_groups',
|
||||
help='Display current authentication group configuration')
|
||||
p.set_defaults(func=get_iscsi_auth_groups)
|
||||
|
||||
@call_cmd
|
||||
def get_portal_groups(args):
|
||||
print_dict(rpc.iscsi.get_portal_groups(args.client))
|
||||
|
@ -118,6 +118,15 @@ def set_iscsi_discovery_auth(
|
||||
return client.call('set_iscsi_discovery_auth', params)
|
||||
|
||||
|
||||
def get_iscsi_auth_groups(client):
|
||||
"""Display current authentication group configuration.
|
||||
|
||||
Returns:
|
||||
List of current authentication group configuration.
|
||||
"""
|
||||
return client.call('get_iscsi_auth_groups')
|
||||
|
||||
|
||||
def get_portal_groups(client):
|
||||
"""Display current portal group configuration.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user