Targets

The iSCSI target commands are used to manage iSCSI targets and iSCSI target groups. The available commands are listed in the table below.

The targets commands take the following URI parameters:

protocol

SAN protocol: fc, iscsi, or srp

target

Target ID: IQN, WWN, or EUI

Table 11-5 Target Commands

Request Append to Path /san/v{1|2} Description

GET

/protocol/targets

List all SAN target for the given protocol: fc, iscsi, srp objects

GET

/protocol/targets/target

Get the specified SAN target for the given protocol: fc, iscsi, srp properties

POST

/protocol/targets

Create a new SAN target for the given protocol: fc, iscsi, srp

PUT

/protocol/targets/target

Modify the specified SAN target for the given protocol: fc, iscsi, srp object

DELETE

/protocol/targets/target

Destroy the specified target object

The get target commands return target properties. The create and modify target commands use the properties listed in the following table as input.

Table 11-6 Target Input Properties

Property Protocol Description

alias

iscsi

Simple human readable name

iqn

iscsi

The iSCSI qualified name

state

iscsi

State of the iSCSI target ("online", "offline")

auth

iscsi

Optional authentication type ("none", "chap")

targetchapuser

iscsi

Optional CHAP user authentication

targetchapsecret

iscsi

Optional CHAP secret authentication

interfaces

iscsi

List of network interfaces that target is available

wwn

fc

Worldwide name for this target

port

fc

Physical location of the port

mode

fc

Mode of this port (initiator or target)

speed

fc

Negotiated speed of this port

discovered_ports

fc

Number of discovered remote initiator ports

alias

srp

Alias for the SRP target

eui

srp

Extended unique identifier for this target

The following properties are used for getting iSCSI target group information.

Table 11-7 Target Group Properties

Property Type Description

protocol

string

The target group protocol: FC, iSCSI, or SRP

name

string

The iSCSI target group name

targets

array

A list of iSCSI target IQN group members

List Targets

Lists all of the SAN targets of the specified protocol available on Oracle ZFS Storage Appliance.

Example Request:

GET /api/san/v1/iscsi/targets HTTP/1.1
Host: zfs-storage.example.com:215
Authorization: Basic Tm8gcGVla2luZyE=
Accept: application/json

Example Result:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1337

{
    "size": 7,
     "targets": [{
        "alias": "tst.volumes.py.12866.target",
        "href": "/api/san/v1/iscsi/targets/iqn.zfs-storage.example.com.sun:02:
            72b6fa9a-96c4-e511-db19-aadb9bac2052",
        "iqn": "iqn.zfs-storage.example.com.sun:02:72b6fa9a-96c4-
            e511-db19-aadb9bac2052",
        ...
    }, {
        "alias": "tst.volumes.py.96238.target",
         "href": "/api/san/v1/iscsi/targets/iqn.zfs-storage.example.com.sun:02:
            31d26d2e-6aa0-6054-fe58-8b1fb508b008",
        "iqn": "iqn.zfs-storage.example.com.sun:31d26d2e-6aa0-6054-fe58-8b1fb508b008",
        ...
    }
    ...]
}

Get Target Details

Gets properties from a single target. The target can be selected by using the "iqn" property or by using "alias=alias".

Example Request:

GET /api/san/v1/iscsi/targets/alias=test-target HTTP/1.1
Host: zfs-storage.example.com:215
Authorization: Basic Tm8gcGVla2luZyE=
Accept: application/json

Example Result:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 251

{
    "target": {
        "alias": "test-target",
        "auth": "none",
        "href": "/api/san/v1/iscsi/targets/alias=test-target",
        "interfaces": ["ixgbe0"],
        "iqn": "iqn.zfs-storage.example.com.sun:02:31d26d2e-6aa0-6054-fe58-8b1fb508b008",
        "targetchapsecret": "",
        "targetchapuser": ""
    }
}

Create a Target

Creates a new target. The request body has a JSON object with a single name property that is the name of the new iSCSI target group.

Example Request:

POST /api/san/v1/iscsi/targets HTTP/1.1
Host: zfs-storage.example.com:215
Authorization: Basic Tm8gcGVla2luZyE=
Content-Type: application/json
Content-Length: 23
Accept: application/json

{"alias": "test-target"}

Example Result:

HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 233
X-Zfssa-San-Api: 1.0
Location: /api/san/v1/iscsi/targets/iqn.zfs-storage.example.com.sun:02:31d26d2e-6aa0-6054-fe58-8b1fb508b008

{
    "target": {
        "href": "/api/san/v1/iscsi/targets/iqn.zfs-storage.example.com.sun:02:31d26d2e-6aa0-6054-fe58-8b1fb508b008",
        "alias": "test-target",
        "iqn": "iqn.zfs-storage.example.com.sun:02:31d26d2e-6aa0-6054-fe58-8b1fb508b008",
        "auth": "none",
        "targetchapuser": "",
        "targetchapsecret": "",
        "interfaces": ["ixgbe0"]
    }
}

Modify a Target

Modifies an existing iSCSI target. The request body contains a JSON object that contains the iSCSI target properties that are modified. HTTP status 202 (Accepted) is returned on success. The response body contains the resulting iSCSI target properties for the target encoded in a JSON object.

Example Request:

PUT /api/san/v1/iscsi/targets/alias=test-target HTTP/1.1
Host: zfs-storage.example.com:215
Authorization: Basic Tm8gcGVla2luZyE=
Content-Type: application/json
Content-Length: 54
Accept: application/json

{"targetchapsecret":"secret", "auth":"chap",
 "targetchapuser":"admin5"}

Example Result:

HTTP/1.1 202 Accepted
Content-Type: application/json
Content-Length: 189
X-Zfssa-San-Api: 1.0

{
    "target": {
        "href": "/api/san/v1/iscsi/targets/alias=test-target",
        "auth": "chap",
        "targetchapsecret": "secret",
        "alias": "test-target",
        "iqn": "iqn.zfs-storage.example.com.sun:02:31d26d2e-6aa0-6054-fe58-8b1fb508b008",
        "targetchapuser": "admin5",
        "interfaces": ["ixgbe0"]
    }
}

Delete a Target

Removes a SAN target from the Oracle ZFS Storage Appliance system.

Example Request:

DELETE /api/san/v1/iscsi/targets/iqn.zfs-storage.example.com.sun:02:e7e688b1 HTTP/1.1
Host: zfs-storage.example.com:215
Authorization: Basic Tm8gcGVla2luZyE=

Successful Delete returns HTTP code 204 (No Content):

HTTP/1.1 204 No-Content