Commit 024d2865 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

lib/iscsi: Add iscsi_start_portal_group RPC to start listening if not yet



Add an new RPC, iscsi_start_portal_group, to start listening on
portals if the specified portal group is not started yet.
The next patch will add an new parameter wait to the existing RPC,
iscsi_create_portal_group.

The RPC allows the specified portal group to be already started,
and returns a success response in this case.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I631d6bccffb38092c95694f922f10648e24d6ff7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5090


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 7ac4961b
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -4472,6 +4472,42 @@ Example response:
}
~~~

## iscsi_start_portal_group method {#rpc_iscsi_start_portal_group}

Start listening on portals if the portal group is not started yet, or do nothing
if the portal group already started. Return a success response for both cases.

### Parameters

Name                        | Optional | Type    | Description
--------------------------- | -------- | --------| -----------
tag                         | Required | number  | Existing portal group tag

### Example

Example request:

~~~
{
  "params": {
    "tag": 1
  },
  "jsonrpc": "2.0",
  "method": "iscsi_start_portal_group",
  "id": 1
}
~~~

Example response:

~~~
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~

## iscsi_delete_portal_group method {#rpc_iscsi_delete_portal_group}

Delete an existing portal group.
+22 −0
Original line number Diff line number Diff line
@@ -881,6 +881,28 @@ rpc_iscsi_delete_portal_group(struct spdk_jsonrpc_request *request,
SPDK_RPC_REGISTER("iscsi_delete_portal_group", rpc_iscsi_delete_portal_group, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(iscsi_delete_portal_group, delete_portal_group)

static int
_rpc_iscsi_start_portal_group(int pg_tag)
{
	struct spdk_iscsi_portal_grp *pg;

	pg = iscsi_portal_grp_find_by_tag(pg_tag);
	if (!pg) {
		return -ENODEV;
	}

	iscsi_portal_grp_resume(pg);
	return 0;
}

static void
rpc_iscsi_start_portal_group(struct spdk_jsonrpc_request *request,
			     const struct spdk_json_val *params)
{
	_rpc_iscsi_change_portal_group(request, params, _rpc_iscsi_start_portal_group);
}
SPDK_RPC_REGISTER("iscsi_start_portal_group", rpc_iscsi_start_portal_group, SPDK_RPC_RUNTIME)

struct rpc_portal_group_auth {
	int32_t tag;
	bool disable_chap;
+9 −0
Original line number Diff line number Diff line
@@ -1197,6 +1197,15 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
    portal must be from a private portal group.""", action='store_true')
    p.set_defaults(func=iscsi_create_portal_group)

    def iscsi_start_portal_group(args):
        rpc.iscsi.iscsi_start_portal_group(args.client, tag=args.tag)

    p = subparsers.add_parser('iscsi_start_portal_group',
                              help='Start listening on portals if it is not started yet.')
    p.add_argument(
        'tag', help='Portal group tag (unique, integer > 0)', type=int)
    p.set_defaults(func=iscsi_start_portal_group)

    def iscsi_create_initiator_group(args):
        initiators = []
        netmasks = []
+13 −0
Original line number Diff line number Diff line
@@ -442,6 +442,19 @@ def iscsi_create_portal_group(client, portals, tag, private):
    return client.call('iscsi_create_portal_group', params)


def iscsi_start_portal_group(client, tag):
    """Start listening on portals if it is not started yet.

    Args:
        tag: Portal group tag (unique, integer > 0)

    Returns:
        True or False
    """
    params = {'tag': tag}
    return client.call('iscsi_start_portal_group', params)


@deprecated_alias('add_initiator_group')
def iscsi_create_initiator_group(client, tag, initiators, netmasks):
    """Add an initiator group.