创建虚拟机自定义操作系统规范(CreateVmCustomSpecification)
API请求
URLs
POST zstack/v1/vm-custom-specificationsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "custom-specification-for-vm-1",
"description": "Test",
"platform": "Windows",
"hostname": "vm-1",
"rootPassword": "password",
"generateSID": true,
"domainMode": "Domain",
"domainName": "zsv.test",
"domainUsername": "administrator",
"domainPassword": "password",
"organization": "OU\u003dzsv,DC\u003dzsv,DC\u003dtest"
},
"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":"custom-specification-for-vm-1","description":"Test","platform":"Windows","hostname":"vm-1","rootPassword":"password","generateSID":true,"domainMode":"Domain","domainName":"zsv.test","domainUsername":"administrator","domainPassword":"password","organization":"OU=zsv,DC=zsv,DC=test"}}' \
http://localhost:8080/zstack/v1/vm-custom-specifications参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 4.10.18 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 4.10.18 | |
| platform | String | body(包含在params结构中) |
虚拟机操作系统平台类型 |
|
4.10.18 |
| hostname (可选) | String | body(包含在params结构中) |
主机名称 | 4.10.18 | |
| rootPassword (可选) | String | body(包含在params结构中) |
管理员密码 | 4.10.18 | |
| generateSID (可选) | Boolean | body(包含在params结构中) |
是否生成SID | 4.10.18 | |
| domainMode (可选) | String | body(包含在params结构中) |
加域模式 |
|
4.10.18 |
| domainName (可选) | String | body(包含在params结构中) |
域名称或工作组名称 | 4.10.18 | |
| domainUsername (可选) | String | body(包含在params结构中) |
域用户名 | 4.10.18 | |
| domainPassword (可选) | String | body(包含在params结构中) |
域用户密码 | 4.10.18 | |
| organization (可选) | String | body(包含在params结构中) |
组织单位 | 4.10.18 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 4.10.18 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 4.10.18 | |
| systemTags (可选) | List | body | 系统标签 | 4.10.18 | |
| userTags (可选) | List | body | 用户标签 | 4.10.18 |
API返回
返回示例
{
"inventory": {
"uuid": "ff0a9e874342368bb28daaf2c9b3cc00",
"vmInstanceUuid": "ff01ec80fd11327cba7519b66119d900",
"name": "custom-specification-for-vm-1",
"description": "Test",
"platform": "Windows",
"hostname": "vm-1",
"rootPassword": "password",
"generateSID": true,
"domainMode": "Domain",
"domainName": "zsv.test",
"domainUsername": "test",
"domainPassword": "password",
"organization": "OU\u003dzsv,DC\u003dzsv,DC\u003dtest"
}
}#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.18 |
| vmInstanceUuid | String | 虚拟机UUID | 4.10.18 |
| name | String | 资源名称 | 4.10.18 |
| description | String | 资源的详细描述 | 4.10.18 |
| platform | String | 虚拟机操作系统平台类型 | 4.10.18 |
| hostname | String | 主机名称 | 4.10.18 |
| generateSID | Boolean | 是否生成SID | 4.10.18 |
| domainName | String | 域名称或工作组名称 | 4.10.18 |
| domainUsername | String | 域用户名 | 4.10.18 |
| organization | String | 组织单位 | 4.10.18 |
| createDate | Timestamp | 创建时间 | 4.10.18 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.18 |
| domainMode | VmCustomSpecificationDomainMode | 详情参考domainMode | 4.10.18 |
#domainMode
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| WorkGroup | VmCustomSpecificationDomainMode | 工作组 | 4.10.18 |
| Domain | VmCustomSpecificationDomainMode | 域 | 4.10.18 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
CreateVmCustomSpecificationAction action = new CreateVmCustomSpecificationAction();
action.name = "custom-specification-for-vm-1";
action.description = "Test";
action.platform = "Windows";
action.hostname = "vm-1";
action.rootPassword = "password";
action.generateSID = true;
action.domainMode = "Domain";
action.domainName = "zsv.test";
action.domainUsername = "administrator";
action.domainPassword = "password";
action.organization = "OU=zsv,DC=zsv,DC=test";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmCustomSpecificationAction.Result res = action.call();Python SDK
action = CreateVmCustomSpecificationAction()
action.name = "custom-specification-for-vm-1"
action.description = "Test"
action.platform = "Windows"
action.hostname = "vm-1"
action.rootPassword = "password"
action.generateSID = true
action.domainMode = "Domain"
action.domainName = "zsv.test"
action.domainUsername = "administrator"
action.domainPassword = "password"
action.organization = "OU=zsv,DC=zsv,DC=test"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()