创建主机Kernel适配器
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "zs-kernel",
"description": "test-description",
"hostUuid": "ac64f7d9591b34b5a9286d7124e9787c",
"l2NetworkUuid": "c68967a38bf132bf96f7ca42cdc5c47b",
"l3NetworkUuid": "1c9547c6bd89392e8c0f50efa83ac990",
"requiredIp": "172.16.1.1",
"netmask": "255.255.255.0",
"trafficTypes": [
"Management"
]
},
"systemTags": [],
"userTags": []
}上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"zs-kernel","description":"test-description","hostUuid":"ac64f7d9591b34b5a9286d7124e9787c","l2NetworkUuid":"c68967a38bf132bf96f7ca42cdc5c47b","l3NetworkUuid":"1c9547c6bd89392e8c0f50efa83ac990","requiredIp":"172.16.1.1","netmask":"255.255.255.0","trafficTypes":["Management"]}}' http://localhost:8080/zstack/v1/l2-networks/kernel-interfaces参数列表
名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
name | String | body(包含在params结构中) | 资源名称 |
| 4.1.0 |
description (可选) | String | body(包含在params结构中) | 资源的详细描述 |
| 4.1.0 |
hostUuid | String | body(包含在params结构中) | 主机UUID |
| 4.1.0 |
l2NetworkUuid | String | body(包含在params结构中) | 端口组分布式交换机UUID |
| 4.1.0 |
l3NetworkUuid | String | body(包含在params结构中) | 分布式端口组UUID |
| 4.1.0 |
requiredIp (可选) | String | body(包含在params结构中) | 请求的IP |
| 4.1.0 |
netmask (可选) | String | body(包含在params结构中) | 网络掩码 |
| 4.1.0 |
trafficTypes (可选) | List | body(包含在params结构中) | 流量类型 |
| 4.1.0 |
resourceUuid (可选) | String | body(包含在params结构中) | 资源UUID |
| 4.1.0 |
tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 |
| 4.1.0 |
systemTags (可选) | List | body | 系统标签 |
| 4.1.0 |
userTags (可选) | List | body | 用户标签 |
| 4.1.0 |
API返回
返回示例
{
"inventory": {
"uuid": "748beaeb70273060a8b599d871a195e6",
"name": "test-kernel",
"description": "test-kernel",
"hostUuid": "3a620091153d3027af5df7c27a0f8fd8",
"l2NetworkUuid": "f66b2fcb35ae3779a69447cf56a153e3",
"l3NetworkUuid": "c2372a1dd7ce338d80ce1de8c658e9a6",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 4.1.0 | |
| inventory | HostKernelInterfaceInventory | 详情参考inventory | 4.1.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 4.1.0 |
inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.1.0 |
| name | String | 资源名称 | 4.1.0 |
| description | String | 资源的详细描述 | 4.1.0 |
| hostUuid | String | 主机UUID | 4.1.0 |
| l2PortGroupUuid | String | 端口组UUID | 4.1.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.1.0 |
| usedIps | List | IP配置 | 4.1.0 |
| trafficTypes | List | 流量类型 | 4.1.0 |
| createDate | Timestamp | 创建时间 | 4.1.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.1.0 |
error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 4.1.0 |
| description | String | 错误的概要描述 | 4.1.0 |
| details | String | 错误的详细信息 | 4.1.0 |
| elaboration | String | 保留字段,默认为null | 4.1.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 4.1.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 4.1.0 |
SDK示例
Java SDK
CreateHostKernelInterfaceAction action = new CreateHostKernelInterfaceAction();
action.name = "zs-kernel";
action.description = "test-description";
action.hostUuid = "ac64f7d9591b34b5a9286d7124e9787c";
action.l2NetworkUuid = "c68967a38bf132bf96f7ca42cdc5c47b";
action.l3NetworkUuid = "1c9547c6bd89392e8c0f50efa83ac990";
action.requiredIp = "172.16.1.1";
action.netmask = "255.255.255.0";
action.trafficTypes = asList("Management");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateHostKernelInterfaceAction.Result res = action.call();Python SDK
CreateHostKernelInterfaceAction action = CreateHostKernelInterfaceAction()
action.name = "zs-kernel"
action.description = "test-description"
action.hostUuid = "ac64f7d9591b34b5a9286d7124e9787c"
action.l2NetworkUuid = "c68967a38bf132bf96f7ca42cdc5c47b"
action.l3NetworkUuid = "1c9547c6bd89392e8c0f50efa83ac990"
action.requiredIp = "172.16.1.1"
action.netmask = "255.255.255.0"
action.trafficTypes = [Management]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateHostKernelInterfaceAction.Result res = action.call()