此操作用来批量查询iSCSI Target。
请求语法
GET /rest/v1/block/target?filter=filter&range=i-j HTTP/1.1
Date: date
Host: ip:port
Authorization: authorization
请求参数
参数 | 描述 | 是否必须 |
---|---|---|
filter | 查询的过滤条件。可以选择多个查询,如果是或的关系,使用or将查询条件分隔开;如果是与的关系,使用and将查询条件分隔开。 支持的过滤条件类型包括:
| 否 |
range | 查询iSCSI Target的范围,格式为i-j,i和j为正整数,0 < j-i < 1000。按照Target名称进行排序,返回第i到第j的Target。 如果输入的查询范围超过iSCSI Target的总个数,返回的结果为空,如果未指定range,则返回所有符合条件的iSCSI Target。 | 否 |
响应结果
名称 | 描述 |
---|---|
targetName | iSCSI Target名称。 |
maxSessions | iSCSI Target下每个IQN允许建立的最大会话数。 |
iSCSITargets | iSCSI Target属性集合。包含:iqn、ips、targetPortalIP、serverId。 类型:数组 |
iqn | iSCSI Target IQN。 |
ips | iSCSI Target的IP属性集合,包含:ip、port。 类型:数组 |
ip | iSCSI Target的IP。 |
port | iSCSI Target的端口号。 |
targetPortalIP.ips | iSCSI目标门户IP属性集合,包含:ip、port。 类型:数组 |
ip | iSCSI目标门户IP。
说明 如果未配置,不返回该项。 |
port | iSCSI目标门户端口号。
说明 如果未配置,不返回该项。 |
targetPortalIP.status | iSCSI目标门户IP状态:
说明 如果未配置,不返回该项。 |
serverId | iSCSI Target的IQN所在的服务器ID。 |
chap.name | CHAP认证名称。 |
chap.status | CHAP认证状态:
|
createTime | 创建iSCSI Target的时间,unix时间戳(UTC),精确到毫秒。 |
serverIds | iSCSI Target对应的服务器ID(仅集群版支持)。 |
num | Target所在的服务器数量(仅集群版支持)。 |
reclaimPolicy | iSCSI Target的回收策略:
|
status | iSCSI Target的状态:
仅iSCSI Target处于删除中会返回此项。 |
请求示例1
单机版:查询iSCSI Target名称中包含target,且关联的卷名称包含lun的iSCSI Target,且只列出第1个到第100个的查询结果。
GET /rest/v1/block/target?filter=targetName:target and lunName:lun&range=1-100 HTTP/1.1
Date: Thu, 28 Nov 2024 08:50:51 GMT
Authorization: HBlock userName:signature
Host: 192.168.0.32:1443
响应示例1
HTTP/1.1 200 OK
x-hblock-request-id: 109f3dbea7f147c5b4b0b006a01def65
Connection: keep-alive
Content-Length: 1262
Date: Thu, 28 Nov 2024 08:50:51 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.32",
"port": 3260
}
],
"targetPortalIP": {
"ips": [
{
"ip": "10.1.1.10",
"port": 5000
}
],
"status": "Disabled"
},
"serverId": "hblock_1"
}
],
"createTime": 1729751771424,
"num": 1,
"reclaimPolicy": "Retain"
},
{
"targetName": "targetb",
"maxSessions": 3,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:targetb.2",
"ips": [
{
"ip": "192.168.0.32",
"port": 3260
}
],
"targetPortalIP": {
"ips": [
{
"ip": "10.1.1.10",
"port": 5000
}
],
"status": "Disabled"
},
"serverId": "hblock_1"
}
],
"createTime": 1729751837717,
"num": 1,
"reclaimPolicy": "Retain"
},
{
"targetName": "targetc1",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:targetc1.3",
"ips": [
{
"ip": "192.168.0.32",
"port": 3260
}
],
"targetPortalIP": {
"ips": [
{
"ip": "10.1.1.10",
"port": 5000
}
],
"status": "Disabled"
},
"serverId": "hblock_1"
}
],
"createTime": 1729751942031,
"num": 1,
"reclaimPolicy": "Retain"
},
{
"targetName": "targetwry1",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:targetwry1.4",
"ips": [
{
"ip": "192.168.0.32",
"port": 3260
}
],
"targetPortalIP": {
"ips": [
{
"ip": "10.1.1.10",
"port": 5000
}
],
"status": "Disabled"
},
"serverId": "hblock_1"
}
],
"createTime": 1730274298224,
"num": 1,
"reclaimPolicy": "Retain"
}
]
}
}
请求示例2
集群版:查询iSCSI Target名称中包含target0,且关联的卷名称包含lun0的iSCSI Target,且只列出第1个到第100个的查询结果。
GET /rest/v1/block/target?filter=targetName:target0 and lunName:lun0&range=1-100 HTTP/1.1
Date: Fri, 29 Nov 2024 11:41:22 GMT
Authorization: HBlock userName:signature
Host: 192.168.0.192:1443
响应示例2
HTTP/1.1 200 OK
x-hblock-request-id: 2fe3309a0e7c4171bde34ad4923222d0
Connection: keep-alive
Content-Length: 1774
Date: Fri, 29 Nov 2024 11:41:22 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"targets": [
{
"targetName": "target01",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target01.3",
"ips": [
{
"ip": "192.168.0.117",
"port": 3260
}
],
"serverId": "hblock_2"
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target01.4",
"ips": [
{
"ip": "192.168.0.102",
"port": 3260
}
],
"targetPortalIP": {
"ips": [
{
"ip": "10.0.1.10",
"port": 3223
}
],
"status": "Disabled"
},
"serverId": "hblock_3"
}
],
"chap": {
"name": "test",
"status": "Disabled"
},
"createTime": 1732591782678,
"serverIds": [
"hblock_2",
"hblock_3"
],
"num": 2,
"reclaimPolicy": "Delete"
},
{
"targetName": "target02",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target02.5",
"ips": [
{
"ip": "192.168.0.192",
"port": 3260
}
],
"serverId": "hblock_1"
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target02.6",
"ips": [
{
"ip": "192.168.0.117",
"port": 3260
}
],
"serverId": "hblock_2"
}
],
"createTime": 1732592183413,
"serverIds": [
"hblock_1",
"hblock_2"
],
"num": 2,
"reclaimPolicy": "Delete"
},
{
"targetName": "target03",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target03.7",
"ips": [
{
"ip": "192.168.0.192",
"port": 3260
}
],
"serverId": "hblock_1"
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target03.8",
"ips": [
{
"ip": "192.168.0.102",
"port": 3260
}
],
"targetPortalIP": {
"ips": [
{
"ip": "10.0.1.10",
"port": 3223
}
],
"status": "Disabled"
},
"serverId": "hblock_3"
}
],
"createTime": 1732592245821,
"serverIds": [
"hblock_1",
"hblock_3"
],
"num": 2,
"reclaimPolicy": "Delete"
},
{
"targetName": "target05",
"maxSessions": 1,
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target05.9",
"ips": [
{
"ip": "192.168.0.117",
"port": 3260
}
],
"serverId": "hblock_2"
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target05.10",
"ips": [
{
"ip": "192.168.0.192",
"port": 3260
}
],
"serverId": "hblock_1"
}
],
"createTime": 1732843975141,
"serverIds": [
"hblock_1",
"hblock_2"
],
"num": 2,
"reclaimPolicy": "Delete",
"status": "Deleting"
}
]
}
}