POST zstack/v1/hosts/kvm
Authorization: OAuth the-session-uuid
{ "params": { "username": "userName", "password": "password", "sshPort": 22, "name": "newHost", "managementIp": "127.0.0.1", "clusterUuid": "449c63f16f9144528d99315f903be36e" }, "systemTags": [], "userTags": [] }
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"username":"userName","password":"password","sshPort":"22","name":"newHost","managementIp":"127.0.0.1","clusterUuid":"9adf394ca46432afb1218d220bf2925e"}}' \ http://localhost:8080/zstack/v1/hosts/kvm
名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
---|---|---|---|---|---|
username | String | body(包含在params结构中) | ssh用户名 | 0.6 | |
password | String | body(包含在params结构中) | ssh密码 | 0.6 | |
sshPort (可选) | int | body(包含在params结构中) | ssh端口号 | 0.6 | |
name | String | body(包含在params结构中) | 资源名称 | 0.6 | |
description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 0.6 | |
managementIp | String | body(包含在params结构中) | 主机管理节点IP | 0.6 | |
clusterUuid | String | body(包含在params结构中) | 集群UUID | 0.6 | |
resourceUuid (可选) | String | body(包含在params结构中) | 资源UUID | 0.6 | |
systemTags (可选) | List | body | 系统标签 | 0.6 | |
userTags (可选) | List | body | 用户标签 | 0.6 |
pageTableExtensionDisabled
pageTableExtensionDisabled
{ "inventory": { "zoneUuid": "d4160c59319c4642832e666514364a79", "name": "example", "uuid": "479e88bab7a647e3b066a724c8bb3b82", "clusterUuid": "42ade59801804602b9986b42fd103d1c", "description": "example", "managementIp": "192.168.0.1", "hypervisorType": "KVM", "state": "Enabled", "status": "Connected", "totalCpuCapacity": 4.0, "availableCpuCapacity": 2.0, "totalMemoryCapacity": 4.0, "availableMemoryCapacity": 4.0 } }
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
inventory | HostInventory | 详情参考inventory | 0.6 |
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
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 |
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
zoneUuid | String | 数据中心UUID | 0.6 |
name | String | 资源名称 | 0.6 |
uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
clusterUuid | String | 集群UUID | 0.6 |
description | String | 资源的详细描述 | 0.6 |
managementIp | String | 0.6 | |
hypervisorType | String | 0.6 | |
state | String | 0.6 | |
status | String | 0.6 | |
totalCpuCapacity | Long | 0.6 | |
availableCpuCapacity | Long | 0.6 | |
cpuSockets | Integer | 0.6 | |
totalMemoryCapacity | Long | 0.6 | |
availableMemoryCapacity | Long | 0.6 | |
cpuNum | Integer | 0.6 | |
createDate | Timestamp | 创建时间 | 0.6 |
lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
AddKVMHostAction action = new AddKVMHostAction(); action.username = "userName"; action.password = "password"; action.sshPort = 22; action.name = "newHost"; action.managementIp = "127.0.0.1"; action.clusterUuid = "03de4c2f2b5445b7a3ab5ba44930c4e8"; action.sessionId = "5354944d50634bed8088567b5d551e6f"; AddKVMHostAction.Result res = action.call();
AddKVMHostAction action = AddKVMHostAction() action.username = "userName" action.password = "password" action.sshPort = 22 action.name = "newHost" action.managementIp = "127.0.0.1" action.clusterUuid = "9fa355cc5434466cba6fb478b8559dad" action.sessionId = "d3770b6e43874065a1ff3cf127857e32" AddKVMHostAction.Result res = action.call()
URLs
DELETE zstack/v1/hosts/{uuid}?deleteMode={deleteMode}
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth 999c480f7f344c3b803c3d74b82b7145" \ -X DELETE http://localhost:8080/zstack/v1/hosts/bb2e5125ac2c4b3680463d7aeaf57773?deleteMode=Permissive
名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
---|---|---|---|---|---|
uuid | String | url | 资源的UUID,唯一标示该资源 | 0.6 | |
deleteMode (可选) | String | body | 删除模式(Permissive 或者 Enforcing,默认 Permissive) | 0.6 | |
systemTags (可选) | List | body | 系统标签 | 0.6 | |
userTags (可选) | List | body | 用户标签 | 0.6 |
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
DeleteHostAction action = new DeleteHostAction(); action.uuid = "2d4b91d9831d4630bf113ea75f78cb7a"; action.deleteMode = "Permissive"; action.sessionId = "923c9089a5fd4ea5b9fbfc1dec5802e2"; DeleteHostAction.Result res = action.call();
Python SDK
DeleteHostAction action = DeleteHostAction() action.uuid = "f62a37111c154ec9afeaeb2700ebcfe6" action.deleteMode = "Permissive" action.sessionId = "2aa7f575d8654712ba985f4a36594f0a" DeleteHostAction.Result res = action.call()
GET zstack/v1/hosts GET zstack/v1/hosts/{uuid}
Authorization: OAuth the-session-uuid
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth 99a86d711f154752b52a7de2b3c43a63" \ -X GET http://localhost:8080/zstack/v1/hosts?q=uuid=66547f0fc9fd45d98f6b8482488f2993
curl -H "Content-Type: application/json;charset=UTF-8" \ -H "Authorization: OAuth bd46777b8a8c4616a64f0cdbcf1bf98e" \ -X GET http://localhost:8080/zstack/v1/hosts/bb582f21cfad4f61a2ab1ec062131b4a
可查询字段
运行CLI命令行工具,输入QueryHost
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
{ "inventories": [ { "zoneUuid": "37649b12f572303a883c19c4c7af0856", "name": "example", "uuid": "f7bae73b9874344b8766dfcdda48ad6e", "clusterUuid": "d59c027b81fe3bbc9d78ef45f574febb", "description": "example", "managementIp": "192.168.0.1", "hypervisorType": "KVM", "state": "Enabled", "status": "Connected", "totalCpuCapacity": 4.0, "availableCpuCapacity": 2.0, "cpuSockets": 4.0, "totalMemoryCapacity": 1840414720, "availableMemoryCapacity": 1840414720, "cpuNum": 4.0 } ] }
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
inventories | List | 详情参考inventories | 0.6 |
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
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 |
名字 | 类型 | 描述 | 起始版本 |
---|---|---|---|
zoneUuid | String | 数据中心UUID | 0.6 |
name | String | 资源名称 | 0.6 |
uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
clusterUuid | String | 集群UUID | 0.6 |
description | String | 资源的详细描述 | 0.6 |
managementIp | String | 0.6 | |
hypervisorType | String | 0.6 | |
state | String | 主机状态,包括:
| 0.6 |
status | String |
| 0.6 |
totalCpuCapacity | Long | 0.6 | |
availableCpuCapacity | Long | 0.6 | |
cpuSockets | Integer | 0.6 | |
totalMemoryCapacity | Long | 0.6 | |
availableMemoryCapacity | Long | 0.6 | |
cpuNum | Integer | 0.6 | |
createDate | Timestamp | 创建时间 | 0.6 |
lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
QueryHostAction action = new QueryHostAction(); action.conditions = asList("uuid=fb0510cd5bf04565be44c43da20169c7"); action.sessionId = "d69767ca64854cfb99960282fcdb8aed"; QueryHostAction.Result res = action.call();
QueryHostAction action = QueryHostAction() action.conditions = ["uuid=2ddc05f8f46b4d5ab40053fdb72ae69d"] action.sessionId = "96b183220af446c39d7cf2674761d85e" QueryHostAction.Result res = action.call()
学习路径
ZStack Cloud 产品学习路径
快速梳理文档,点击相应文本链接,快速跳转到相应文档的页面,学习 ZStack Cloud 产品。
业务咨询:
400-962-2212 转 1售后咨询:
400-962-2212 转 2其他(漏洞提交、投诉举报等)
400-962-2212 转 3业务咨询:
400-962-2212 转 1ZStack学院:
training@zstack.io业务咨询:
400-962-2212 转 1售后咨询:
400-962-2212 转 2其他(漏洞提交、投诉举报等)
400-962-2212 转 3业务咨询:
400-962-2212 转 1售后咨询:
400-962-2212 转 2其他(漏洞提交、投诉举报等)
400-962-2212 转 3业务咨询:
400-962-2212 转 1商务联系:
channel@zstack.io业务咨询:
400-962-2212 转 1商务联系:
channel@zstack.io下载链接已发送至您的邮箱。
如未收到,请查看您的垃圾邮件、订阅邮件、广告邮件。 当您收到电子邮件后,请点击 URL 链接,以完成下载。感谢您使用 ZStack 产品和服务。
成功提交申请。
我们将安排工作人员尽快与您取得联系。感谢您使用 ZStack 产品和服务。
信息提交成功。
我们将安排工作人员尽快与您取得联系,请保持电话畅通。感谢您使用 ZStack 产品和服务。
商务咨询:
400-962-2212 转 1售后咨询:
400-962-2212 转 2商务联系:
sales@zstack.io成功提交申请。
我们将安排工作人员尽快与您取得联系。感谢您使用 ZStack 产品和服务。