创建裸机实例(CreateBaremetalInstance)
API请求
URLs
POST zstack/v1/baremetal/instances
Headers
Authorization: OAuth the-session-uuid
Body
{
"params": {
"name": "BM-1",
"description": "This is a baremetal instance.",
"chassisUuid": "b79a4de35d2b346c96ac0093f2aadef1",
"imageUuid": "2f4cf15ce5c2345999550bd13195feaf",
"templateUuid": "7fffea7efdae39968d51ef5686c09365",
"username": "root",
"password": "password",
"nicCfgs": {
"6c:b3:11:1b:0b:1e": "fa8f784c641a3193bb070b90b2ac9e66",
"6c:b3:11:1b:0b:1f": "ee081a7ea13e312d8191926076fba22c"
},
"bondingCfgs": {
"120342ecdb913830b88553ba982edb78": "23b04081ead93f4bb6be6443755e46a5"
},
"customConfigurations": {
"keyboard": "en_US",
"hostname": "localhost"
},
"strategy": "InstantStart"
},
"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-1","description":"This is a baremetal instance.","chassisUuid":"b79a4de35d2b346c96ac0093f2aadef1","imageUuid":"2f4cf15ce5c2345999550bd13195feaf","templateUuid":"7fffea7efdae39968d51ef5686c09365","username":"root","password":"password","nicCfgs":{"6c:b3:11:1b:0b:1e":"fa8f784c641a3193bb070b90b2ac9e66","6c:b3:11:1b:0b:1f":"ee081a7ea13e312d8191926076fba22c"},"bondingCfgs":{"120342ecdb913830b88553ba982edb78":"23b04081ead93f4bb6be6443755e46a5"},"customConfigurations":{"keyboard":"en_US","hostname":"localhost"},"strategy":"InstantStart"}}' http://localhost:8080/zstack/v1/baremetal/instances
参数列表
名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
---|---|---|---|---|---|
name | String | body(包含在params结构中) | 资源名称 | 2.6.0 | |
description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 2.6.0 | |
chassisUuid | String | body(包含在params结构中) | 裸机设备UUID | 2.6.0 | |
imageUuid | String | body(包含在params结构中) | 镜像UUID | 2.6.0 | |
templateUuid (可选) | String | body(包含在params结构中) | 预配置模板UUID | 3.3.0 | |
username (可选) | String | body(包含在params结构中) | 系统用户 | 3.3.0 | |
password | String | body(包含在params结构中) | 系统密码 | 2.6.0 | |
nicCfgs (可选) | Map | body(包含在params结构中) | 裸机网络配置 | 2.6.0 | |
bondingCfgs (可选) | Map | body(包含在params结构中) | 网卡绑定配置 | 3.3.0 | |
customConfigurations (可选) | Map | body(包含在params结构中) | 自定义变量 | 3.3.0 | |
strategy (可选) | String | body(包含在params结构中) | 裸机实例创建策略 |
|
2.6.0 |
resourceUuid (可选) | String | body(包含在params结构中) | 资源UUID。若指定,则裸机实例会以该字段值作为UUID。 | 2.6.0 | |
systemTags (可选) | List | body | 系统标签 | 2.6.0 | |
userTags (可选) | List | body | 用户标签 | 2.6.0 |
Note:
- ZStack Cloud创建裸机实例时支持指定裸金属主机静态IP,SystemTags增加staticIp选项,使用
staticIp参数来传递 SystemTag。
- 选项格式为:
staticIp::{%s}::{%s} 其中第一个%s是三层网络UUID,第二个是所指定的IP地址
- 例如:
staticIp::f00d593dff2e4bd58473388ac411ade2::192.168.0.10
- 选项格式为:
- ZStack Cloud创建裸机实例时支持裸金属主机覆盖安装,SystemTags增加forceInstall选项,使用
forceInstall参数来传递 SystemTag。
- 如果没有这个TAG,则系统安装过程中如果发现目标磁盘中存在已有分区,则安装过程暂停,避免覆盖磁盘数据;
- 如果有这个TAG,则自动清理已有分区,覆盖安装。
API返回
返回示例
{
"inventory": {
"uuid": "1dc13c821a713f7fbfa7dd754f100a73",
"name": "BM-1",
"description": "This is a baremetal instance.",
"zoneUuid": "0f67724b4dc5397ea39751fda57c4ce6",
"clusterUuid": "7921d51dba31317e8c09d50e44abd010",
"chassisUuid": "5183b18300e43aa784a643b86a9772b7",
"imageUuid": "a39b3870f3ae393cadcc3b4cfb454653",
"platform": "Linux",
"state": "Created",
"status": "Unprovisioned",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"bmNics": [
{
"uuid": "006915f4766c32ee8b09bf951dd43264",
"baremetalInstanceUuid": "1dc13c821a713f7fbfa7dd754f100a73",
"l3NetworkUuid": "1fa935a68b4e312aa482df27b3b759a5",
"mac": "6c:b3:11:1b:0b:1e",
"ip": "192.168.0.10",
"netmask": "255.255.255.0",
"gateway": "192.168.0.1",
"pxe": false
}
]
}
}
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.6.0 |
inventory | BaremetalInstanceInventory | 详情参考inventory | 2.6.0 |
#error
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 2.6.0 |
description | String | 错误的概要描述 | 2.6.0 |
details | String | 错误的详细信息 | 2.6.0 |
elaboration | String | 保留字段,默认为null | 2.6.0 |
opaque | LinkedHashMap | 保留字段,默认为null | 2.6.0 |
cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 2.6.0 |
#inventory
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
uuid | String | 资源的UUID,唯一标示该资源 | 2.6.0 |
name | String | 资源名称 | 2.6.0 |
description | String | 资源的详细描述 | 2.6.0 |
zoneUuid | String | 区域UUID | 2.6.0 |
clusterUuid | String | 集群UUID | 2.6.0 |
pxeServerUuid | String | 3.1.1 | |
chassisUuid | String | 裸机设备UUID | 2.6.0 |
imageUuid | String | 镜像UUID | 2.6.0 |
platform | String | 系统平台 | 2.6.0 |
state | String | 2.6.0 | |
status | String | 2.6.0 | |
createDate | Timestamp | 创建时间 | 2.6.0 |
lastOpDate | Timestamp | 最后一次修改时间 | 2.6.0 |
bmNics | List | 详情参考bmNics | 2.6.0 |
#bmNics
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
uuid | String | 资源的UUID,唯一标示该资源 | 2.6.0 |
baremetalInstanceUuid | String | 裸机实例UUID | 2.6.0 |
l3NetworkUuid | String | 三层网络UUID | 2.6.0 |
mac | String | MAC地址 | 2.6.0 |
ip | String | IP地址 | 2.6.0 |
netmask | String | 子网掩码 | 2.6.0 |
gateway | String | 网关 | 2.6.0 |
metadata | String | 2.6.0 | |
pxe | Boolean | 是否PXE启动网卡 | 2.6.0 |
createDate | Timestamp | 创建时间 | 2.6.0 |
lastOpDate | Timestamp | 最后一次修改时间 | 2.6.0 |
SDK示例
Java
SDK
CreateBaremetalInstanceAction action = new CreateBaremetalInstanceAction();
action.name = "BM-1";
action.description = "This is a baremetal instance.";
action.chassisUuid = "b79a4de35d2b346c96ac0093f2aadef1";
action.imageUuid = "2f4cf15ce5c2345999550bd13195feaf";
action.templateUuid = "7fffea7efdae39968d51ef5686c09365";
action.username = "root";
action.password = "password";
action.nicCfgs = [6c:b3:11:1b:0b:1e:fa8f784c641a3193bb070b90b2ac9e66, 6c:b3:11:1b:0b:1f:ee081a7ea13e312d8191926076fba22c];
action.bondingCfgs = [120342ecdb913830b88553ba982edb78:23b04081ead93f4bb6be6443755e46a5];
action.customConfigurations = [keyboard:en_US, hostname:localhost];
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateBaremetalInstanceAction.Result res = action.call();
Python
SDK
CreateBaremetalInstanceAction action = CreateBaremetalInstanceAction()
action.name = "BM-1"
action.description = "This is a baremetal instance."
action.chassisUuid = "b79a4de35d2b346c96ac0093f2aadef1"
action.imageUuid = "2f4cf15ce5c2345999550bd13195feaf"
action.templateUuid = "7fffea7efdae39968d51ef5686c09365"
action.username = "root"
action.password = "password"
action.nicCfgs = [6c:b3:11:1b:0b:1e:fa8f784c641a3193bb070b90b2ac9e66, 6c:b3:11:1b:0b:1f:ee081a7ea13e312d8191926076fba22c]
action.bondingCfgs = [120342ecdb913830b88553ba982edb78:23b04081ead93f4bb6be6443755e46a5]
action.customConfigurations = [keyboard:en_US, hostname:localhost]
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateBaremetalInstanceAction.Result res = action.call()