此操作用来创建iSCSI Target。
说明
HBlock上Target IQN的数量最多32766个。一个Target最多可以关联256个卷,但是一个卷只能被一个Target关联。
请求语法
单机版
POST /rest/v1/block/target HTTP/1.1
Date: date
Content-Type: application/json; charset=utf-8
Content-Length: length
Host: ip:port
Authorization: authorization
{
"targetName": targetName,
"maxSessions": value,
"reclaimPolicy": reclaimPolicy,
"chap": {
"name": name,
"password": password,
"status": status
}
}
集群版
POST /rest/v1/block/target HTTP/1.1
Date: date
Content-Type: application/json; charset=utf-8
Content-Length: length
Host: ip:port
Authorization: authorization
{
"targetName": targetName,
"maxSessions": value,
"reclaimPolicy": reclaimPolicy,
"chap": {
"name": name,
"password": password,
"status": status
},
"serverNumbers": value,
"server": [
"server_ID",…
]
}
请求参数
参数 | 描述 | 是否必须 |
---|---|---|
targetName | iSCSI Target名称。 类型:字符串 取值:长度范围是1~16,可以由小写字母、数字、句点(.)和短横线(-)组成,且仅支持以字母或数字开头。 | 是 |
maxSessions | iSCSI Target下每个IQN允许建立的最大会话数。 类型:整型 取值:取值范围是[0, 1024],默认值为1。0表示客户端无法发现该Target。 注意 如果多个客户端连接同一Target IQN,客户端可以同时读,但不能同时写。 | 否 |
reclaimPolicy | 指定iSCSI Target的回收策略。 类型:枚举 取值:
默认值为Retain。 说明 如果创建卷时指定不存在的iSCSI Target,那么同时创建iSCSI Target,新创建iSCSI Target的回收策略默认为Delete。 | 否 |
chap.name | CHAP名称。 类型:字符串 取值:长度范围是3~64,可以由字母、数字、句点(.)、短横线(-)、下划线(_)和冒号(:)组成,字母区分大小写,且仅支持以字母或数字开头。 | 否 |
chap.password | CHAP密码。 类型:字符串 取值:长度范围是12~16,必须包含大写字母、小写字母、数字、下划线(_)中的至少两种字符,字母区分大小写。 | 否 |
chap.status | 是否启用CHAP认证。 类型:枚举 取值:
注意 如果启用CHAP认证,name和password必须设置。 | 是 |
serverNumbers | Target所在的服务器数量(仅集群版支持)。 类型:整型 取值:[2, n],n为集群内服务器的数量。默认值是2。 | 否 |
server | 指定iSCSI Target对应的服务器ID(仅集群版支持)。 最多可以指定n个服务器ID,以英文逗号隔开。n为集群内服务器的数量。 | 否 |
响应结果
名称 | 描述 |
---|---|
iSCSITargets | iSCSI Target属性集合。包含:iqn、ips、 类型:数组 |
iqn | iSCSI Target IQN。 |
ips | iSCSI Target的IP属性集合,包含:ip、port。 类型:数组 |
ip | iSCSI Target的IP。 |
port | iSCSI Target的端口号。 |
请求示例1
单机版:创建一个名称为targete的Target。
POST /rest/v1/block/target HTTP/1.1
Date: Tue, 14 Feb 2023 07: 58: 44 GMT
Content-Type: application/json; charset=utf-8
Authorization: HBlock userName:signature
Content-Length: 155
Host: 192.168.0.32: 1443
{
"targetName": "targete",
"chap": {
"name": "test",
"password": "12345678901a",
"status": "Enabled"
}
}
响应示例1
HTTP/1.1 200 OK
x-hblock-request-id: 8c2a6566e6d84b5e82ac26387c6a50ac
Connection: keep-alive
Content-Length: 217
Date: Tue, 14 Feb 2023 07: 58: 44 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:targete.6",
"ips": [
{
"ip": "192.168.0.32",
"port": 3260
}
]
}
]
}
}
请求示例2
集群版:创建一个名称为target06的Target。
POST /rest/v1/block/target HTTP/1.1
Date: Thu, 28 Sep 2023 07: 39: 52 GMT
Content-Type: application/json; charset=utf-8
Authorization: HBlock userName:signature
Content-Length: 252
Host: 192.168.0.192: 1443
{
"targetName": "target06",
"maxSessions": 6,
"chap": {
"name": "test",
"password": "12345678901w",
"status": "Enabled"
},
"serverNumbers": 3,
"server": [
"hblock_1",
"hblock_2"
]
}
响应示例2
HTTP/1.1 200 OK
x-hblock-request-id: e1e127f0345c4b9ebc36d168998901a9
Connection: keep-alive
Content-Length: 303
Date: Thu, 28 Sep 2023 07: 39: 52 GMT
Content-Type: application/json;charset=utf-8
Server: HBlock
{
"data": {
"iSCSITargets": [
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target06.6",
"ips": [
{
"ip": "192.168.0.110",
"port": 3260
}
]
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target06.7",
"ips": [
{
"ip": "192.168.0.117",
"port": 3260
}
]
},
{
"iqn": "iqn.2012-08.cn.ctyunapi.oos:target06.8",
"ips": [
{
"ip": "192.168.0.102",
"port": 3260
}
]
}
]
}
}