此操作用來批量查詢iSCSI target。
請求語法
GET /rest/v1/block/target?filter=filter&range=i-j HTTP/1.1
Date: date
Host: ip:port
Authorization: authorization請求參數
| 參數 | 類型 | 描述 | 是否必須 |
|---|---|---|---|
| filter | String | 查詢的過濾條件。可以選擇多個查詢,如果是或的關系,使用or將查詢條件分隔開;如果是與的關系,使用and將查詢條件分隔開。 支持的過濾條件類型包括:
| 否 |
| range | String | 查詢iSCSI target的范圍,格式為i-j,i和j為正整數,0 < j-i < 1000。按照target名稱進行排序,返回第i到第j的target。 如果輸入的查詢范圍超過iSCSI target的總個數,返回的結果為空,如果未指定range,則返回所有符合條件的iSCSI target。 | 否 |
響應結果
| 名稱 | 類型 | 描述 |
|---|---|---|
| targets | Array of target | iSCSI target信息集合,詳見“表1 響應參數target說明”。 |
表1 響應參數target說明
| 名稱 | 類型 | 描述 |
|---|---|---|
| targetName | String | iSCSI target名稱。 |
| maxSessions | Integer | iSCSI target下每個IQN允許建立的最大會話數。 |
| iSCSITargets | Array of iSCSITarget | iSCSI target屬性集合,詳見“表2 響應參數iSCSITarget說明”。 |
| 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處于刪除中會返回此項。 |
表2 響應參數iSCSITarget說明
| 名稱 | 類型 | 描述 |
|---|---|---|
| iqn | String | iSCSI target IQN。 |
| ips | Array of ip | iSCSI target的IP屬性集合,詳見“表3 響應參數ip說明”。 |
| targetPortalIP | Object | iSCSI目標門戶,詳見“表4 響應參數targetPortalIP說明”。 |
| serverId | String | iSCSI target的IQN所在的服務器ID。 |
| allowlist.initiator | Array of initiator | iSCSI發起方(initiator)允許訪問列表。詳見“表6 響應參數initiator說明”。 |
| allowlist.target | Array of target | 目標端(target)的允許訪問列表。詳見“表7 響應參數target說明”。 |
表3 響應參數ip說明
| 名稱 | 類型 | 描述 |
|---|---|---|
| ip | String | iSCSI target的IP。 |
| port | Integer | iSCSI target的端口號。 |
表4 響應參數targetPortalIP說明
| 名稱 | 類型 | 描述 |
|---|---|---|
| ips | Array of ip | iSCSI目標門戶的IP屬性集合,詳見“表5 響應參數targetPortalIP.ip說明”。 |
| status | String | iSCSI目標門戶的狀態:
說明 如果未配置,不返回該項。 |
表5 響應參數targetPortalIP.ip說明
| 名稱 | 類型 | 描述 |
|---|---|---|
| ip | String | iSCSI目標門戶的IP地址。 |
| port | Integer | iSCSI目標門戶的端口號。 |
表6 響應參數initiator說明
| 名稱 | 類型 | 描述 |
|---|---|---|
| IPs | Array of ip | 根據initiator IP地址設置的iSCSI發起方允許訪問列表。 |
| names | Array of name | 根據initiator名稱設置的iSCSI發起方允許訪問列表。 |
表7 響應參數target說明
| 名稱 | 類型 | 描述 |
|---|---|---|
| IPs | Array of ip | 通過target端IP進行設置的target允許訪問列表,表示只允許通過target端的指定IP訪問target。 |
| NICs | Array of NIC | 通過target端的網卡名稱設置的target允許訪問列表,表示只允許通過target端的指定網卡訪問target。 |
請求示例1
單機版:查詢iSCSI target名稱中包含target,且關聯的卷名稱包含lun的iSCSI target,且只列出第1個到第3個的查詢結果。
GET /rest/v1/block/target?filter=targetName:target and lunName:lun&range=1-3 HTTP/1.1
Date: Thu, 24 Jul 2025 08:16:12 GMT
Authorization: HBlock userName:signature
Host: 192.168.0.66:1443響應示例1
HTTP/1.1 200 OK
x-hblock-request-id: c5271562a56f4805a9ce2f39214953ab
Connection: keep-alive
Content-Length: 874
Date: Thu, 24 Jul 2025 08:16:12 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"targets": [
{
"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": [
{
"IPs": [
"192.168.0.68"
]
},
{
"IPs": [
"192.168.0.70"
]
}
],
"target": [
{
"IPs": [
"192.168.0.66"
]
}
]
}
}
],
"chap": {
"name": "chanptest",
"status": "Disabled"
},
"createTime": 1753172337443,
"num": 1,
"reclaimPolicy": "Delete"
},
{
"targetName": "targetb",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:targetb.2",
"ips": [
{
"ip": "192.168.0.66",
"port": 3260
}
],
"serverId": "hblock_1"
}
],
"createTime": 1753237554317,
"num": 1,
"reclaimPolicy": "Delete"
},
{
"targetName": "targete",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:targete.3",
"ips": [
{
"ip": "192.168.0.66",
"port": 3260
}
],
"serverId": "hblock_1"
}
],
"createTime": 1753324422341,
"num": 1,
"reclaimPolicy": "Retain"
}
]
}
}請求示例2
集群版:查詢iSCSI target名稱中包含target0,且關聯的卷名稱包含lun0的iSCSI target,且只列出第1個到第3個的查詢結果。
GET /rest/v1/block/target?filter=targetName:target0 and lunName:lun0&range=1-3 HTTP/1.1
Date: Thu, 24 Jul 2025 08:24:26 GMT
Authorization: HBlock userName:signature
Host: 192.168.0.64:1443響應示例2
HTTP/1.1 200 OK
x-hblock-request-id: d820500731e04a03a2477fb09e2fd3fe
Connection: keep-alive
Content-Length: 1942
Date: Thu, 24 Jul 2025 08:24:26 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"targets": [
{
"targetName": "target0",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target0.1",
"ips": [
{
"ip": "192.168.0.67",
"port": 3260
}
],
"serverId": "hblock_3",
"allowlist": {
"initiator": [
{
"IPs": [
"1.1.1.1"
]
}
]
}
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target0.2",
"ips": [
{
"ip": "192.168.0.64",
"port": 3260
}
],
"serverId": "hblock_2",
"allowlist": {
"initiator": [
{
"IPs": [
"1.1.1.1"
]
}
]
}
}
],
"createTime": 1752111608672,
"serverIds": [
"hblock_2",
"hblock_3"
],
"num": 2,
"reclaimPolicy": "Delete"
},
{
"targetName": "target01",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target01.3",
"ips": [
{
"ip": "192.168.0.65",
"port": 3260
}
],
"serverId": "hblock_1"
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target01.4",
"ips": [
{
"ip": "192.168.0.67",
"port": 3260
}
],
"serverId": "hblock_3",
"allowlist": {
"target": [
{
"IPs": [
"192.168.0.67"
]
}
]
}
}
],
"createTime": 1752111636790,
"serverIds": [
"hblock_1",
"hblock_3"
],
"num": 2,
"reclaimPolicy": "Delete"
},
{
"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"
]
}
]
}
}
],
"chap": {
"name": "chap-test",
"status": "Disabled"
},
"createTime": 1752111720420,
"serverIds": [
"hblock_1",
"hblock_3"
],
"num": 2,
"reclaimPolicy": "Delete"
}
]
}
}