查询指定的iSCSI target
更新时间 2025-09-29 17:49:38
最近更新时间: 2025-09-29 17:49:38
本节主要介绍如何使用API查询指定的iSCSI target。
此操作用来查询指定的iSCSI target。
请求语法
GET /rest/v1/block/target/targetName HTTP/1.1
Date: date
Host: ip:port
Authorization: authorization请求参数
| 参数 | 类型 | 描述 | 是否必须 |
|---|---|---|---|
| targetName | String | iSCSI target名称。 说明 如果不填写此项,会返回所有target信息。 取值:长度范围是1~16,可以由小写字母、数字、句点(.)和短横线(-)组成,且仅支持以字母或数字开头。 | 否 |
响应结果
| 名称 | 类型 | 描述 |
|---|---|---|
| targetName | String | iSCSI target名称。 |
| maxSessions | Integer | iSCSI target下每个IQN允许建立的最大会话数。 |
| iSCSITargets | Array of iSCSITarget | iSCSI target属性集合,详见“表1 响应参数iSCSITarget说明”。 |
| luns | Array of lun | 关联卷的属性,详见“表7 响应参数lun说明”。 |
| chap.name | String | CHAP认证名称。 |
| chap.status | String | CHAP认证状态:
|
| createTime | Long | 创建iSCSI target的时间,unix时间戳(UTC),精确到毫秒。 |
| serverIds | Array of string | iSCSI target对应的服务器ID(仅集群版支持)。 |
| num | Integer | target所在的服务器数量(仅集群版支持)。 |
| reclaimPolicy | String | iSCSI target的回收策略:
|
| status | String | iSCSI target的状态:
仅iSCSI target处于删除中会返回此项。 |
表1 响应参数iSCSITarget说明
| 名称 | 类型 | 描述 |
|---|---|---|
| iqn | String | iSCSI target IQN。 |
| ips | Array of ip | iSCSI target的IP属性集合,包含: ip、port,详见“表2 响应参数ip说明”。 |
| targetPortalIP | Object | iSCSI目标门户,详见“表3 响应参数targetPortalIP说明”。 |
| serverId | String | iSCSI target的IQN所在的服务器ID。 |
| allowlist.initiator | Array of initiator | iSCSI发起方(initiator)允许访问列表。详见“表5 响应参数initiator说明”。 |
| allowlist.target | Array of target | 目标端(target)的允许访问列表。详见“表6 响应参数target说明”。 |
表2 响应参数ip说明
| 名称 | 类型 | 描述 |
|---|---|---|
| ip | String | iSCSI target的IP。 |
| port | Integer | iSCSI target的端口号。 |
表3 响应参数targetPortalIP说明
| 名称 | 类型 | 描述 |
|---|---|---|
| ips | Array of ip | iSCSI目标门户的IP属性集合,详见“表4 响应参数targetPortalIP.ip说明”。 |
| targetPortalIP.status | String | iSCSI目标门户IP状态:
说明 如果未配置,不返回该项。 |
表4 响应参数ip(iSCSI目标门户的IP)说明
| 名称 | 类型 | 描述 |
|---|---|---|
| ip | String | iSCSI目标门户IP。 |
| port | Integer | iSCSI目标门户端口号。 |
表5 响应参数initiator说明
| 名称 | 类型 | 描述 |
|---|---|---|
| IPs | Array of ip | 根据initiator IP地址设置的iSCSI发起方允许访问列表。 |
| names | Array of name | 根据initiator名称设置的iSCSI发起方允许访问列表。 |
表6 响应参数target说明
| 名称 | 类型 | 描述 |
|---|---|---|
| IPs | Array of ip | 通过target端IP进行设置的target允许访问列表,表示只允许通过target端的指定IP访问target。 |
| NICs | Array of NIC | 通过target端的网卡名称设置的target允许访问列表,表示只允许通过target端的指定网卡访问target。 |
表7 响应参数lun说明
| 名称 | 类型 | 描述 |
|---|---|---|
| lunName | String | 关联卷的名称。 |
| number | Integer | 卷编号。 |
请求示例1
单机版:查询iSCSI target名称为targeta的信息。
GET /rest/v1/block/target/targeta HTTP/1.1
Date: Mon, 08 Sep 2025 01:29:15 GMT
Authorization: HBlock userName:signature
Host: 192.168.0.32:1443
Connection: keep-alive响应示例1
HTTP/1.1 200 OK
x-hblock-request-id: e66f2a16825240009d3de70b158ad161
Connection: keep-alive
Content-Length: 478
Date: Mon, 08 Sep 2025 01:29:15 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"targetName": "targeta",
"maxSessions": 3,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:targeta.1",
"ips": [
{
"ip": "192.168.0.66",
"port": 3260
}
],
"serverId": "hblock_1",
"allowlist": {
"initiator": [
{
"names": [
"iqn.1994-05.com.redhat:c73bf5e45bd4"
],
"IPs": [
"192.168.0.68"
]
},
{
"IPs": [
"192.168.0.70"
]
}
],
"target": [
{
"IPs": [
"192.168.0.66"
]
}
]
}
}
],
"luns": [
{
"lunName": "luna1",
"number": 0
},
{
"lunName": "luna1-clone1",
"number": 1
}
],
"createTime": 1754375366254,
"num": 1,
"reclaimPolicy": "Delete"
}
}请求示例2
集群版:查询iSCSI target名称为target03的信息。
GET /rest/v1/block/target/target03 HTTP/1.1
Date: Thu, 24 Jul 2025 08:36:15 GMT
Authorization: HBlock userName:signature
Host: 192.168.0.64:1443
Connection: keep-alive响应示例2
HTTP/1.1 200 OK
x-hblock-request-id: b859187a66164328b538bc421c2861da
Connection: keep-alive
Content-Length: 1096
Date: Thu, 24 Jul 2025 08:36:15 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"targetName": "target03",
"maxSessions": 2,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target03.5",
"ips": [
{
"ip": "192.168.0.67",
"port": 3260
}
],
"serverId": "hblock_3",
"allowlist": {
"initiator": [
{
"names": [
"iqn.1991-05.com.microsoft:songt-0001"
],
"IPs": [
"192.168.0.70"
]
},
{
"IPs": [
"192.168.0.66"
]
}
],
"target": [
{
"IPs": [
"192.168.0.64"
]
},
{
"IPs": [
"192.168.0.65"
]
},
{
"IPs": [
"192.168.0.67"
]
},
{
"IPs": [
"192.168.0.64",
"192.168.0.65",
"192.168.0.67"
]
},
{
"IPs": [
"192.168.0.71"
]
}
]
}
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target03.6",
"ips": [
{
"ip": "192.168.0.65",
"port": 3260
}
],
"serverId": "hblock_1",
"allowlist": {
"initiator": [
{
"names": [
"iqn.1991-05.com.microsoft:songt-0001"
],
"IPs": [
"192.168.0.70"
]
},
{
"IPs": [
"192.168.0.66"
]
}
],
"target": [
{
"IPs": [
"192.168.0.64"
]
},
{
"IPs": [
"192.168.0.65"
]
},
{
"IPs": [
"192.168.0.67"
]
},
{
"IPs": [
"192.168.0.64",
"192.168.0.65",
"192.168.0.67"
]
},
{
"IPs": [
"192.168.0.71"
]
}
]
}
}
],
"luns": [
{
"lunName": "lun03a",
"number": 0
},
{
"lunName": "lun03b",
"number": 1
}
],
"chap": {
"name": "chap-test",
"status": "Disabled"
},
"createTime": 1752111720420,
"serverIds": [
"hblock_1",
"hblock_3"
],
"num": 2,
"reclaimPolicy": "Delete"
}
}