创建裸金属实例(CreateBareMetal2Instance)
API请求
URLs
POST zstack/v1/baremetal2/bm-instancesHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "BM",
"description": "This is a bare metal instance",
"clusterUuid": "d42170a418c3371f82ac5f21d10feff4",
"chassisOfferingUuid": "b759701ddf47367eb55efea665eb3bd8",
"imageUuid": "529c9474896035f8bb8aa806bec5c28b"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"BM","description":"This is a bare metal instance","clusterUuid":"d42170a418c3371f82ac5f21d10feff4","chassisOfferingUuid":"b759701ddf47367eb55efea665eb3bd8","imageUuid":"529c9474896035f8bb8aa806bec5c28b"}}' \
http://localhost:8080/zstack/v1/baremetal2/bm-instances参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) | 资源名称 | 4.0.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 4.0.0 | |
| zoneUuid (可选) | String | body(包含在params结构中) | 区域UUID | 4.0.0 | |
| clusterUuid (可选) | String | body(包含在params结构中) | 集群UUID | 4.0.0 | |
| gatewayUuid (可选) | String | body(包含在params结构中) | 裸金属网关节点UUID | 4.0.0 | |
| chassisUuid (可选) | String | body(包含在params结构中) | 裸金属节点UUID | 4.0.0 | |
| chassisOfferingUuid (可选) | String | body(包含在params结构中) | 裸金属节点规格UUID | 4.0.0 | |
| imageUuid (可选) | String | body(包含在params结构中) | 镜像UUID | 4.0.0 | |
| primaryStorageUuidForRootVolume (可选) | String | body(包含在params结构中) | 根云盘所在主存储UUID | 4.0.0 | |
| primaryStorageUuidForDataVolume (可选) | String | body(包含在params结构中) | 数据盘所在主存储UUID | 4.0.0 | |
| dataDiskOfferingUuids (可选) | List | body(包含在params结构中) | 数据云盘规格UUID列表 | 4.0.0 | |
| rootVolumeSystemTags (可选) | List | body(包含在params结构中) | 根云盘系统标签 | 4.0.0 | |
| dataVolumeSystemTags (可选) | List | body(包含在params结构中) | 数据盘系统标签 | 4.0.0 | |
| gatewayAllocatorStrategy (可选) | String | body(包含在params结构中) | 裸金属网关节点分配策略 | 4.0.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 资源UUID | 4.0.0 | |
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 4.0.0 | |
| systemTags (可选) | List | body | 系统标签 | 4.0.0 | |
| userTags (可选) | List | body | 用户标签 | 4.0.0 | |
| chassisDiskUuid (可选) | String | body(包含在params结构中) | 本地系统盘UUID | 4.3.12 | |
| l3NetworkUuids (可选) | List | body(包含在params结构中) | 5.5.38 | ||
| defaultL3NetworkUuid (可选) | String | body(包含在params结构中) | 5.5.38 | ||
| vmNicParams (可选) | String | body(包含在params结构中) | 5.5.38 |
API返回
返回示例
{
"inventory": {
"chassisUuid": "abdb84a7186446828d679ca390400804",
"lastChassisUuid": "2e16e29ad4d94a348d3f633358792ebe",
"gatewayUuid": "8a2a62c0d26f46af9b835515ca26cf79",
"lastGatewayUuid": "bc627e89139043e292aea1d691740f58",
"chassisOfferingUuid": "b943087d48644fe7a9165d447b1197e6",
"status": "Connected",
"provisionType": "Remote",
"uuid": "870fde072c314db49fb6c91ca6f893f6",
"name": "BM-1",
"description": "This is a BareMetal2 Instance.",
"zoneUuid": "66bbd29bcd8d4313816dc6ed26e86c97",
"clusterUuid": "f3b09f2ac776470bb0710db497e13b6c",
"imageUuid": "1d499497394e443ba4d5f502d42ffff1",
"rootVolumeUuid": "f88731c18e58481e8d7c98158e8b2948",
"platform": "Linux",
"type": "baremetal2",
"memorySize": 8.589934592E9,
"cpuNum": 8.0,
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"state": "Running"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败,操作成功时该字段为null。 详情参考error | 4.0.0 |
| inventory | BareMetal2InstanceInventory | 详情参考inventory | 4.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如 SYS.1000、HOST.1001 | 5.3.20 |
| description | String | 错误的概要描述 | 5.3.20 |
| details | String | 错误的详细信息 | 5.3.20 |
| elaboration | String | 保留字段,默认为null | 5.3.20 |
| opaque | LinkedHashMap | 保留字段,默认为null | 5.3.20 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 5.3.20 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| chassisUuid | String | 裸金属节点UUID | 4.0.0 |
| lastChassisUuid | String | 上次所在裸金属节点UUID | 4.0.0 |
| gatewayUuid | String | 裸金属网关节点UUID | 4.0.0 |
| lastGatewayUuid | String | 上次所在裸金属网关节点UUID | 4.0.0 |
| chassisOfferingUuid | String | 裸金属节点规格UUID | 4.0.0 |
| gatewayAllocatorStrategy | String | 裸金属网关节点分配策略 | 4.0.0 |
| status | String | 连接状态 | 4.0.0 |
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| name | String | 资源名称 | 4.0.0 |
| description | String | 资源的详细描述 | 4.0.0 |
| zoneUuid | String | 区域UUID | 4.0.0 |
| clusterUuid | String | 集群UUID | 4.0.0 |
| imageUuid | String | 镜像UUID | 4.0.0 |
| rootVolumeUuid | String | 根云盘UUID | 4.0.0 |
| platform | String | 平台类型 | 4.0.0 |
| defaultL3NetworkUuid | String | 默认网络UUID | 4.0.0 |
| type | String | 类型 | 4.0.0 |
| hypervisorType | String | 虚拟化类型 | 4.0.0 |
| memorySize | Long | 内存容量 | 4.0.0 |
| cpuNum | Integer | CPU核数 | 4.0.0 |
| cpuSpeed | Long | CPU速率 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
| state | String | 运行状态 | 4.0.0 |
| provisionNic | BareMetal2InstanceProvisionNicInventory | 详情参考provisionNic | 4.0.0 |
| vmNics | List | 详情参考vmNics | 4.0.0 |
| allVolumes | List | 详情参考allVolumes | 4.0.0 |
#provisionNic
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.0.0 |
| networkUuid | String | 裸金属部署网络UUID | 4.0.0 |
| mac | String | MAC地址 | 4.0.0 |
| ip | String | IP地址 | 4.0.0 |
| netmask | String | 子网掩码 | 4.0.0 |
| gateway | String | 网关地址 | 4.0.0 |
| metadata | String | 4.0.0 | |
| createDate | Timestamp | 创建时间 | 4.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.0.0 |
#vmNics
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| vmInstanceUuid | String | 云主机UUID | 0.6 |
| l3NetworkUuid | String | 三层网络UUID | 0.6 |
| ip | String | IP地址 | 0.6 |
| mac | String | MAC地址 | 0.6 |
| hypervisorType | String | 虚拟化类型 | 0.6 |
| netmask | String | 子网掩码 | 0.6 |
| gateway | String | 网关 | 0.6 |
| metaData | String | 0.6 | |
| ipVersion | Integer | IP地址版本 | 0.6 |
| deviceId | Integer | 设备ID | 0.6 |
| type | String | 网卡类型 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| usedIps | List | 详情参考usedIps | 0.6 |
#usedIps
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| ipRangeUuid | String | IP段UUID | 0.6 |
| l3NetworkUuid | String | 三层网络UUID | 0.6 |
| ipVersion | Integer | IP协议号 | 3.1 |
| ip | String | IP地址 | 0.6 |
| netmask | String | 网络掩码 | 0.6 |
| gateway | String | 网关地址 | 0.6 |
| usedFor | String | 0.6 | |
| ipInLong | long | 0.6 | |
| vmNicUuid | String | 云主机网卡UUID | 3.1 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
#allVolumes
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| primaryStorageUuid | String | 主存储UUID | 0.6 |
| vmInstanceUuid | String | 云主机UUID | 0.6 |
| diskOfferingUuid | String | 云盘规格UUID | 0.6 |
| rootImageUuid | String | 云盘根镜像UUID | 0.6 |
| installPath | String | 云盘在主存储上的路径 | 0.6 |
| type | String | 云盘类型,数据云盘/根云盘 | 0.6 |
| format | String | 云盘格式 | 0.6 |
| size | Long | 云盘大小 | 0.6 |
| actualSize | Long | 云盘真实大小 | 0.6 |
| deviceId | Integer | 0.6 | |
| state | String | 云盘是否开启 | 0.6 |
| status | String | 云盘状态 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| isShareable | Boolean | 是否共享云盘 | 0.6 |
| volumeQos | String | 云盘Qos,格式如total=1048576 | 3.2.0 |
SDK示例
Java SDK
CreateBareMetal2InstanceAction action = new CreateBareMetal2InstanceAction();
action.name = "BM";
action.description = "This is a bare metal instance";
action.clusterUuid = "d42170a418c3371f82ac5f21d10feff4";
action.chassisOfferingUuid = "b759701ddf47367eb55efea665eb3bd8";
action.imageUuid = "529c9474896035f8bb8aa806bec5c28b";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateBareMetal2InstanceAction.Result res = action.call();Python SDK
action = CreateBareMetal2InstanceAction()
action.name = "BM"
action.description = "This is a bare metal instance"
action.clusterUuid = "d42170a418c3371f82ac5f21d10feff4"
action.chassisOfferingUuid = "b759701ddf47367eb55efea665eb3bd8"
action.imageUuid = "529c9474896035f8bb8aa806bec5c28b"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()