开发手册
云资源池
版权声明
版权所有©上海云轴信息科技有限公司 2018。保留一切权利。
非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,并不得以任何形式传播。
商标说明
ZStack商标和其他云轴商标均为上海云轴信息科技有限公司的商标。
本文档提及的其他所有商标或注册商标,由各自的所有人拥有。
注意
您购买的产品、服务或特性等应受上海云轴公司商业合同和条款的约束,本文档中描述的全部或部分产品、服务或特性可能不在您的购买或使用范围之内。除非合同另有约定,上海云轴公司对本文档内容不做任何明示或暗示的声明或保证。
由于产品版本升级或其他原因,本文档内容会不定期进行更新。除非另有约定,本文档仅作为使用指导,本文档中的所有陈述、信息和建议不构成任何明示或暗示的担保。
引言
产品版本
目前与本文档相对应的产品版本为:ZStack 2.3.1
读者对象
本文档详述了ZStack 2.3.1 RESTful API的使用规范,并提供所有API的详细定义。本文档主要适用于以下读者:
架构设计师
开发工程师
测试工程师
项目实施人员
对ZStack有兴趣研究的相关人员
版本更新
2.3.1
2018/04/03主要更新:
网络拓扑
新版菜单导航、新版首页
ZWatch:全新监控报警系统
ZStack定制版ISO新增:基于CentOS 7.4深度定制版本
亲和组
增强vCenter接管功能:接管vCenter云盘、基于vCenter云路由网络提供网络服务
一个云主机加载多个ISO
多种策略创建云主机
一个二层网络可用于创建多个三层网络
操作日志/审计全新改版
HTTPS安全访问UI管理界面
内部访问业务流量的负载均衡
优化自定义UI
多个场景新增进度条、操作助手和帮助文档,优化UI交互
优化部分业务逻辑
2.3.0
2018/02/08主要更新:
专有网络VPC
混合云灾备(混合云版支持)
大屏监控
用户自定义UI
ImageStore类型镜像服务器支持Ceph类型主存储
支持vSwitch
支持vCenter资源同步
ESXi云主机支持扁平网络
云主机更换操作系统
跨NFS存储数据迁移
虚拟IP支持QoS
支持AD认证
云主机自定义MAC地址
强化浏览器上传镜像功能
新增云盘镜像资源
数据云盘扩容
数据云盘规格支持QoS
停止NeverStop状态的云主机
开放云路由公网IP,并支持同一虚拟IP多网络服务复用
支持USB设备透传,强化外接设备透传功能
增加VDI SPICE流量优化选项
支持修改已设置的存储网络
支持设置VXLAN对普通账户的配额
支持ImageStore类型镜像服务器间的数据同步
管理节点数据库自动备份到远程服务器
多个场景新增进度条、操作助手和帮助文档,优化UI交互
优化部分业务逻辑
2.2
2017/10/16主要更新:
公有网络创建云主机
自定义DHCP模式
新增系统网络
云主机根云盘扩容
浏览器添加镜像(目前支持ImageStore类型镜像服务器)
管理节点高可用:多网络配置
跨Ceph存储数据迁移
增强Ceph存储功能
增强VDI功能
LDAP自定义过滤规则
增强裸机管理
单集群支持多类型主存储(目前支持本地存储+NFS/SMP类型)
更换License支持本地上传
共享存储指定存储网络,增强云主机高可用
多个场景新增进度条、操作助手和帮助文档,优化UI交互
优化部分业务逻辑
2.1
2017/08/14主要更新:
VDI
裸机管理
GPU透传
智能报警
集群挂载多个主存储
新版定时器
静态路由
User Data导入
云路由加载多个公有网络
增量升级
优化部分业务逻辑
系列索引
ZStack 2.3.1 开发手册系列索引如下:
《ZStack 2.3.1 开发手册 云资源池》
《ZStack 2.3.1 开发手册 硬件设施》
《ZStack 2.3.1 开发手册 网络资源》
《ZStack 2.3.1 开发手册 网络服务》
《ZStack 2.3.1 开发手册 vCenter》
《ZStack 2.3.1 开发手册 平台运维》
《ZStack 2.3.1 开发手册 平台管理》
《ZStack 2.3.1 开发手册 设置》
《ZStack 2.3.1 开发手册 系统全局相关》
API规范概述
ZStack 2.3.1提供原生RESTful支持。您可以通过REST定义的架构设计原则和约束条件,并使用支持HTTP的编程语言进行开发。
HTTP方法 (HTTP Verbs)
当前API支持如下操作资源的方法:
|方法名|描述| |---|--| |GET| 获取资源信息。
所有的查询API以及读API均使用该方法。
| |POST| 创建一个资源。
| |PUT|修改一个资源。- 所有对资源的修改操作,以及类RPC调用的操作,例如启动虚拟机,均使用该方法。
| |DELETE|删除一个资源。|
Parent topic: API规范概述
传参方式
URL、Query String、HTTP body三种方式均可用于传参。每种方式可以单独使用,也可以混合使用,具体使用哪种传参方式由具体API决定。
URL传参
当对某具体资源进行操作时,资源的UUID通过编码到URL的方式进行传参。
例如启动一个UUID为 f97143d60f1042c9badd9a1336d3c105的虚拟机,URL格式为:
zstack/v1/vm-instances/f97143d60f1042c9badd9a1336d3c105/actions
这里UUID编码到URL路径当中。
Query String传参
所有使用HTTP GET方法的API均使用Query String传参。
例如查询所有状态为Running的虚拟机, URL格式为:
zstack/v1/vm-instances?condition=state=Running
HTTP Body传参
当使用POST方法创建一个资源,或PUT方法修改一个资源时,除通过URL传参的部分外,剩余参数均通过HTTP Body传参。
例如在指定物理机上启动一个虚拟机:
``` PUT zstack/v1/vm-instances/f97143d60f1042c9badd9a1336d3c105/actions
{ "startVmInstance": { "hostUuid": "8aef7e3a53b34eedaa05027a919156d9" } } ```
这里虚拟机的UUID通过URL传参,参数hostUuid则通过HTTP Body传递。
Parent topic: API规范概述
HTTP Headers
当前API使用如下自定义HTTP Headers:
Authorization
除了少数API外(例如登录API),使用ZStack API前都需要一个会话(session),在调用API时通过Authorization HTTP Header传递会话UUID。该Header的格式为:
Authorization: OAuth 会话UUID
举例:
Authorization: OAuth 34cbfddd470a47d8bdb0727cd2182618
Note: OAuth和会话UUID之间用空格分隔。
X-Job-UUID
对于异步API,可以通过X-Job-UUID HTTP Header来指定该API Job的UUID,例如:
X-Job-UUID: d825b1a26f4e474b8c59306081920ff2
如果未指定该HTTP Header,ZStack会自动为API Job生成一个UUID。
Note:
X-Job-UUID必须为一个v4版本的UUID(即随机UUID)字符串去掉连接符-。ZStack会验证X-Job-UUID格式的合法性,并对非法的字符串返回一个400 Bad Request的错误。
X-Web-Hook
对于异步API,可以通过X-Web-Hook HTTP Header指定一个回调URL用于接收API 返回。通过使用回调URL的方法,调用者可以避免使用轮询去查询一个异步API的执行结果。举例:
X-Web-Hook: http://localhost:5000/api-callback
X-Job-Success
当使用了X-Web-Hook
回调的方式获取异步API结果时,ZStack推送给回调URL的HTTP Post请求中会包含X-Job-Success
HTTP Header指明该异步API的执行结果是成功还是失败。例如:
X-Job-Success: true
当值为true时执行成功,为false时执行失败。
Parent topic: API规范概述
HTTP返回码 (HTTP Status Code)
ZStack使用如下返回码:
|返回码|意义| |---|--| |200|API执行成功。| |202|API请求已被ZStack接受,用户需要通过轮询或Web Hook的方式获取API结果。该返回码只在调用异步API时出现。| |400|API请求未包含必要的参数或包含了非法的参数。具体信息可以从HTTP Response Body获得。| |404|URL不存在,通常是指定了错误的API URL。如果访问的URL是异步API返回的轮询地址,表示该轮询地址已经过期。| |405|API调用使用了错误的HTTP方法,例如在创建一个资源的时候用了GET方法而不是POST方法。| |500| ZStack RESTful终端遭遇了一个内部错误。| |503|API所执行的操作引发了一个错误,例如资源不足无法创建虚拟机。错误的具体信息可以从HTTP Response Body。|
Parent topic: API规范概述
API种类
ZStack的API分为同步API和异步API两种:
同步API
所有使用GET方法的API都是同步API,调用方收到的HTTP Response中直接包含了API的结果。例如:
``` GET zstack/v1/zones/f3fa7671894a40f6a73f5bfc7d90c126
{ "inventory": { "uuid": "f3fa7671894a40f6a73f5bfc7d90c126", "name": "zone1", "description": "test", "state": "Enabled", "type": "zstack", "createDate": "Jan 6, 2017 3:51:16 AM", "lastOpDate": "Jan 6, 2017 3:51:16 AM" } } ```
异步API
除了登录相关的API外,所有不使用GET方法的API都为异步API。用户调用一个异步API成功后会收到202返回码以及 Body中包含的一个轮询地址(location字段),用户需要周期性的GET该轮询地址以获得API的执行结果。例如:
``` Status Code: 202
Body:
{ "location": "http://localhost:8989/v1/api-jobs/967a26b7431c49c0b1d50d709ef1aef3" } ```
通常情况下GET一个轮询地址可以得到四种返回:
202返回码表示该API仍在处理中,用户需要继续轮询。
200返回码表示API执行成功,Body中包含API结果。
503返回码表示API执行失败,Body中包含错误码。
404返回码,则表示轮询地址已经过期,产生这种结果的原因可能是用户访问了一个错误的轮询地址,或者太久没有访问该轮询地址(例如超过2天没有访问),该轮询地址已经被删除。
异步API也可以用Web Hook的方式获得结果,具体方法见后面章节。
Parent topic: API规范概述
API操作
跟所有的RESTful API类似,绝大多数ZStack API执行的是CRUD(Create, Read, Update, Delete)操作,以及类RPC操作。
创建资源
所有资源的创建都使用POST方法,参数通过HTTP Body传递,例如创建一个虚拟机:
``` POST zstack/v1/vm-instances
Authorization: OAuth 0c234e29a2ad4ff4b0d97d4f3b47c6cf
{ "params": { "l3NetworkUuids": ["37a701c7fe4a40758da15593aedd8aff"], "defaultL3NetworkUuid": "37a701c7fe4a40758da15593aedd8aff", "dataDiskOfferingUuids": [], "name": "TestVm", "description": "Test", "systemTags": [], "instanceOfferingUuid": "dd53f94b58924510b0122e40799a4114", "type": "UserVm", "imageUuid": "cc7b56780879409f98c1f992b75a12b0" } } ```
查询资源
资源的查询使用GET方法,查询条件通过Query String传参,例如查询集群cluster1中名字不等于 web-vm的虚拟机:
``` GET zstack/v1/vm-instances?condition=name!=web-vm&condition=cluster.name=cluster1
Authorization: OAuth 0c234e29a2ad4ff4b0d97d4f3b47c6cf ```
如果已知资源的UUID,要直接获取该资源的信息,直接使用GET方法不加任何查询条件,例如:
``` GET zstack/v1/vm-instances/56f0fd314a2647ffb4f9565f6d05858e
Authorization: OAuth 0c234e29a2ad4ff4b0d97d4f3b47c6cf ```
返回UUID为56f0fd314a2647ffb4f9565f6d05858e虚拟机的信息。
删除资源
删除资源使用DELETE方法,被删除资源的UUID编码在URL中,例如:
``` DELETE zstack/v1/vm-instances/56f0fd314a2647ffb4f9565f6d05858e
Authorization: OAuth 0c234e29a2ad4ff4b0d97d4f3b47c6cf ```
删除UUID为56f0fd314a2647ffb4f9565f6d05858e的虚拟机。
修改资源与类RPC操作
但由于IaaS本身业务的性质,一部分操作更类似于RPC(远程调用)而非CRUD操作,例如启动虚拟机。根据RESTful API的一些较佳实践,ZStack将这些操作都归为资源的actions子资源,例如启动虚拟机、 停止虚拟机都是对虚拟机的actions子资源进行操作。举个例子:
启动虚拟机:
``` PUT zstack/v1/vm-instances/d46841bd4ebd47f8bf0bed85c3bdf0db/actions
{ "startVmInstance": {} } ```
停止虚拟机:
``` PUT zstack/v1/vm-instances/d46841bd4ebd47f8bf0bed85c3bdf0db/actions
{ "stopVmInstance": {} } ```
在上面的例子中,两个操作都访问的是相同的URL/v1/vminstances/d46841bd4ebd47f8bf0bed85c3bdf0db/actions, 具体的操作类型由包含在Body中的字段名表示,例如stopVmInstance,如果该API包含额外参数,则包含在操作字段名对应的map中。
资源操作的具体字段名和例子参考每个API的详细文档。
Parent topic: API规范概述
基本流程示例
在下例中,我们会创建一个Zone,以展示API使用的基本流程:
登录
使用API的第一步是登录以获取一个Session UUID,以供后续API调用使用。
``` PUT zstack/v1/accounts/login
body:
{ "logInByAccount": { "password": "b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86", "accountName": "admin" } } ```
这里的密码是用sha512哈希后的结果。
API返回如下:
``` status code: 200
body:
{ "inventory": { "uuid": "00d038b699b74e76a01705918d48d939", "accountUuid": "36c27e8ff05c4780bf6d2fa65700f22e", "userUuid": "36c27e8ff05c4780bf6d2fa65700f22e", "expiredDate": "Jan 1, 2017 11:31:06 AM", "createDate": "Jan 1, 2017 9:31:06 AM" } } ```
返回内容中包含账户UUID等其他字段,我们需要的session UUID包含在字段uuid中:00d038b699b74e76a01705918d48d939。
创建Zone
``` POST zstack/v1/zones
headers:
Authorization: OAuth 00d038b699b74e76a01705918d48d939
body:
{ "params": { "name": "Zone1", "description": "Test" } } ```
由于创建Zone操作是一个异步API,API返回不是直接的结果,而是一个轮询地址:
``` status code: 202
body:
{ "location": "http://localhost:8989/v1/api-jobs/d0345d3ddcae485f8170572b15a2b581" } ```
用户需要周期性的轮询API结果:
``` GET http://localhost:8989/v1/api-jobs/d0345d3ddcae485f8170572b15a2b581
Authorization: OAuth 00d038b699b74e76a01705918d48d939 ```
如果API还未执行完成,上述GET操作得到的仍然是202返回码和上述轮询地址。当操作完成时,得到的结果如下:
``` status code: 200
body:
{ "inventory": { "uuid": "f52fe55b64094ceb99b3893a238c4931", "name": "Zone1", "description": "Test", "state": "Enabled", "type": "zstack", "createDate": "Jan 1, 2017 9:31:07 AM", "lastOpDate": "Jan 1, 2017 9:31:07 AM" } } ```
查询Zone
要获取创建的Zone的信息,可以用GET查询:
``` GET zstack/v1/zones/f52fe55b64094ceb99b3893a238c4931
Authorization: OAuth 00d038b699b74e76a01705918d48d939 ```
返回:
``` status code: 200
body:
{ "inventory": { "uuid": "f52fe55b64094ceb99b3893a238c4931", "name": "Zone1", "description": "Test", "state": "Enabled", "type": "zstack", "createDate": "Jan 1, 2017 9:31:07 AM", "lastOpDate": "Jan 1, 2017 9:31:07 AM" } } ```
登出
当所有API调用完毕,我们需要对已登录的session进行登出操作:
DELETE zstack/v1/accounts/sessions/00d038b699b74e76a01705918d48d939
返回
status code: 200
Parent topic: API规范概述
Webhook
对于异步API使用轮询的方式查询操作结果是一种低效的方式,为此ZStack提供Webhook的方式主动推送异步API结果给调用者。
要使用Webhook功能,调用者只需在HTTP Headers中指定X-Job-UUID和X-Web-Hook即可。以上面创建Zone为例,使用Webhook的API版本为:
``` POST zstack/v1/zones
headers:
Authorization: OAuth 00d038b699b74e76a01705918d48d939 X-Job-UUID: d0345d3ddcae485f8170572b15a2b581 X-Web-Hook: http://127.0.0.1:8989/rest-webhook
body:
{ "params": { "name": "Zone1", "description": "Test" } } ```
API返回仍然是202返回码和一个轮询地址,但调用者无需再轮询。API执行成功后,结果会被推送到
http://127.0.0.1:8989/rest-webhook
``` POST http://127.0.0.1:8989/rest-webhook
headers:
X-Job-Success: true X-Job-UUID: d0345d3ddcae485f8170572b15a2b581
body:
{ "inventory": { "uuid": "f52fe55b64094ceb99b3893a238c4931", "name": "Zone1", "description": "Test", "state": "Enabled", "type": "zstack", "createDate": "Jan 1, 2017 9:31:07 AM", "lastOpDate": "Jan 1, 2017 9:31:07 AM" } } ```
推送的结果之中,X-Job-Success指明了API执行成功与否,X-Job-UUID包含值跟API调用时的X-Job-UUID相同,调用者可以对应结果和API。
Parent topic: API规范概述
查询API
用户可以用GET方法对一个资源进行查询,并且可以像MySQL一样指定多个查询条件、排序方式、选择字段、以及进行跨表查询等等。
支持超过400万个单项查询条件,以及400万阶乘的组合查询条件。
单表查询
例如:
GET zstack/v1/vm-instances?q=name=vm1
查询名字为vm1的虚拟机。
例如:
GET zstack/v1/vm-instances?q=name=vm1&q=state=Running
查询名字为vm1并且状态为Running的虚拟机。
这两个例子都是对虚拟机资源本身查询,反应到数据库层面还属于单表查询。
跨表查询
我们可以通过.进行跨表查询。
例如:
GET zstack/v1/vm-instances?q=vmNics.ip=192.168.10.100
查询IP地址为192.168.10.100的虚拟机,这里对虚拟机和网卡两张表进行了跨表查询。
例如:
GET zstack/v1/vm-instances?q=host.managementIp=10.10.20.3
查询IP为10.10.20.3上运行的所有虚拟机。这里对虚拟机和物理机两张表进行了跨表查询。
所有资源的查询API都支持下列参数
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |q (可选)|List|query|见查询条件。省略该字段将返回所有记录,返回记录数的上限受限于limit字段| |0.6| |limit (可选)|Integer|query|较多返回的记录数,类似MySQL的limit,默认值1000| |0.6| |start (可选)|Integer|query|起始查询记录位置,类似MySQL的offset。跟limit配合使用可以实现分页| |0.6| |count (可选)|Boolean|query|计数查询,相当于MySQL中的count()函数。当设置成true时,API只返回的是满足查询条件的记录数| |0.6| |groupBy (可选)|String|query|以字段分组,相当于MySQL中的group by关键字。例如groupBy=type| |1.9| |replyWithCount (可选)|Boolean|query|见分页查询| |0.6| |sort (可选)|String|query|以字段排序,等同于MySQL中的sort by关键字,例如sort=+ip。必须跟+或者-配合使用,+表示升序,-表示降序,后面跟排序字段名|`+`字段名,`-`字段名|0.6| |sortDirection (可选)|String|query|字段排序方向,必须跟sortBy配合使用|ascdesc|0.6| |fields (可选)|List|query|指定返回的字段,等同于MySQL中的select字段功能。例如fields=name,uuid,则只返回满足条件记录的name和uuid字段| |0.6|
查询条件
的查询条件类似于MySQL数据库。
例如:
uuid=bfa67f956afb430890aa49db14b85153 totalCapacity>2000 vmInstanceUuid not null
Note:
字段名、查询操作符、匹配值三者之间不能有任何空格。
例如uuid = 25506342d1384c07b7342373a57475b9就是一个错误的查询条件,必须写为uuid=25506342d1384c07b7342373a57475b9。
多个查询条件之间是与关系。总共支持10个查询操作符:
=: 等于,例如:
vmInstanceUuid=c4981689088b40f98d2ade2548c323da
!=: 不等于,例如:
vmInstanceUuid!=c4981689088b40f98d2ade2548c323da
>: 大于
<: 小于
>=: 大于等于
<=: 小于等于
?=: in操作符,测试字段值是否在一个集合。集合中的值以,分隔。例如测试uuid是否属于某个集合:
uuid?=25506342d1384c07b7342373a57475b9,bc58d68090ac42358c0cb0fe72e3287f
!?=: not int操作符,测试字段值是否不属于一个集合。集合中的值以,分隔,例如测试name是否不等于VM1和VM2:
name!?=VM1,VM2
~=: 字符串模糊匹配,相当于MySQL中的like操作。使用%匹配一个或多个字符,使用_匹配一个字符。 例如查询一个名字是以IntelCore开头的:
name~=IntelCore%
或者查询一个名字是以IntelCore开头,以7结尾,中间模糊匹配一个字符:
name~=IntelCore_7
这样名字是IntelCoreI7,IntelCoreM7的记录都会匹配上。
!~=: 模糊匹配非操作。查询一个字段不能模糊匹配到某个字符串,匹配条件与~=相同。
is null: 字段为null:
name is null
not null: 字段不为null:
name not null
分页查询
start、limit、replyWithCount三个字段可以配合使用实现分页查询。
start指定起始查询位置。
limit指定查询返回的较大记录数。
replyWithCount被设置成true后,查询返回中会包含满足查询条件的记录总数,跟start值比较就可以得知还需几次分页。
例如:
总共有1000记录满足查询条件,使用如下组合:
start=0 limit=100 replyWithCount=true
则API返回将包含头100条记录,以及total字段等于1000,表示总共满足条件的记录为1000。
获取资源可查询字段
由于支持的查询条件数非常巨大,我们无法在文档中枚举所有的查询条件。
用户可以使用命令行工具-cli的自动补全功能来查看一个资源可查询的字段以及可跨表查询的字段。
以查询虚拟机为例,在-cli里输入
QueryVmInstance
并按Tab键补全,可以看到提示页面:```
systemTag= userTag= allocatorStrategy= clusterUuid= cpuNum= cpuSpeed= createDate= defaultL3NetworkUuid= description= groupBy= hostUuid= hypervisorType= imageUuid= instanceOfferingUuid= lastHostUuid= lastOpDate= memorySize= name= platform= rootVolumeUuid= state= type= uuid= zoneUuid=
[Parameters:] count= fields= limit= replyWithCount= sortBy= sortDirection= start= timeout=
```>>>QueryVmInstance [Query Conditions:] allVolumes. cluster. host. image. instanceOffering. rootVolume. vmNics. zone.
这里中间行:
__systemTag__= __userTag__= allocatorStrategy= clusterUuid= cpuNum= cpuSpeed= createDate= defaultL3NetworkUuid= description= groupBy= hostUuid= hypervisorType= imageUuid= instanceOfferingUuid= lastHostUuid= lastOpDate= memorySize= name= platform= rootVolumeUuid= state= type= uuid= zoneUuid=
除__systemTag__和__userTag__两个特殊查询条件外,其余均为虚拟机表的原生字段,用户可以在API的查询条件里面指定它们,并且可以在fields参数中指定这些字段来过滤其它不希望API返回的字段。
例如:
GET zstack/v1/vm-instances?q=cpuNum>5
返回CPU数量多于5的虚拟机。
GET zstack/v1/vm-instances?q=hypervisorType=KVM&fields=uuid&fields=name
返回虚拟化类型为KVM的虚拟机,由于在fields指定了uuid和name两个字段,API返回中只会包含虚拟机的name和uuid。
Note:
只有资源的原生字段可以被fields选取,__userTag__、__systemTag__以及下面讲到的跨表字段均不能出现在fields参数中。
提示的第一行:
```
allVolumes. cluster. host. image. instanceOffering. rootVolume. vmNics. zone. ```
指明了虚拟机资源可以跟哪些资源做跨表查询,例如:allVolumes代表云盘,cluster代表集群,vmNics代表网卡等。
如需查看这些资源的具体字段,只需输入资源名加.号,并按Tab键补全。
例如:
```
vmNics.systemTag= vmNics.userTag= vmNics.createDate= vmNics.deviceId= vmNics.gateway= vmNics.ip= vmNics.l3NetworkUuid= vmNics.lastOpDate= vmNics.mac= vmNics.metaData= vmNics.netmask= vmNics.uuid= vmNics.vmInstanceUuid=
```这里我们输入了资源vmNics并用.号表示我们要做一个跨表查询,Tab键为我们补全了vmNics资源的原生字段以及可跨表查询的其它资源。
例如vmNics.ip表示网卡的原生字段ip:
>>>QueryVmInstance vmNics. [Query Conditions:] vmNics.eip. vmNics.l3Network. vmNics.loadBalancerListener. vmNics.portForwarding. vmNics.securityGroup. vmNics.vmInstance.
GET zstack/v1/vm-instances?q=vmNics.ip=192.168.0.100
进行了一个跨表查询,条件是网卡表的**ip**字段,返回的结果是**ip**为*192.168.0.100*的虚拟机。 - 网卡资源同样可以跟其它资源进行跨表查询,例如**vmNics.eip**。 将网卡表和EIP表进行跨表: ``` GET zstack/v1/vm-instances?q=vmNics.eip.ip=192.168.0.100 ``` 进行了跨3表查询,返回的是EIP为*192.168.0.100*的虚拟机。
通过资源间连续跨表,一个资源几乎跟系统中多个有逻辑关系的资源进行跨表,例如:
```
zone.cluster.l2Network.l3Network.systemTag= zone.cluster.l2Network.l3Network.userTag= zone.cluster.l2Network.l3Network.createDate= zone.cluster.l2Network.l3Network.description= zone.cluster.l2Network.l3Network.dnsDomain= zone.cluster.l2Network.l3Network.l2NetworkUuid= zone.cluster.l2Network.l3Network.lastOpDate= zone.cluster.l2Network.l3Network.name= zone.cluster.l2Network.l3Network.state= zone.cluster.l2Network.l3Network.system= zone.cluster.l2Network.l3Network.type= zone.cluster.l2Network.l3Network.uuid= zone.cluster.l2Network.l3Network.zoneUuid= ```
分别跟zone, cluster, l2Network, l3Network多个资源进行跨表。
Note:
由于一个资源的逻辑关系存在环路,例如以虚拟机为主体可以跟网卡进行跨表,例如
QueryVmInstance vmNics.
,同时以网卡为查询主体也可以跟虚拟机进行跨表QueryVmNic vmInstance.
,这样就会存在环路路径。例如
QueryVmInstance vmNics.vmInstance.name=vm1
通过跨表查询了name=vm1的虚拟机,它的实际效果跟QueryVmInstance name=vm1
完全等同。这里的跨表是无意义的,只会生产复杂的SQL语句导致低效的数据库查询。在使用中应该避免这种环路跨表查询。>>>QueryVmInstance zone.cluster.l2Network.l3Network. [Query Conditions:] zone.cluster.l2Network.l3Network.ipRanges. zone.cluster.l2Network.l3Network.l2Network. zone.cluster.l2Network.l3Network.networkServices. zone.cluster.l2Network.l3Network.serviceProvider. zone.cluster.l2Network.l3Network.vmNic. zone.cluster.l2Network.l3Network.zone.
__systemTag__和__userTag__是两个特殊的查询条件,允许用户通过tag查询资源。
例如:
QueryVmInstance __systemTag__=staticIp:10.10.1.20
查询具有staticIp:10.10.1.20这个tag的虚拟机。
Parent topic: API规范概述
云主机相关接口
创建云主机(CreateVmInstance)
创建一个新的云主机。
API请求
URLs
POST zstack/v1/vm-instances
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "vm1", "instanceOfferingUuid": "ae97ced44efc3314b8f7798972b4ba1a", "imageUuid": "da119f7906513eccabf271991c35a65e", "l3NetworkUuids": [ "cc0e4c5e77df3af68e59668e7f9e06c5" ], "dataDiskOfferingUuids": [ "19d22d051b063d379a2816daaf431838", "905d94a6abb5398fa1995f6398e3f6fc" ], "clusterUuid": "a0468dc645223f67bd0f2ab95276bbae", "description": "this is a vm", "strategy": "InstantStart" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"vm1","instanceOfferingUuid":"ae97ced44efc3314b8f7798972b4ba1a","imageUuid":"da119f7906513eccabf271991c35a65e","l3NetworkUuids":["cc0e4c5e77df3af68e59668e7f9e06c5"],"dataDiskOfferingUuids":["19d22d051b063d379a2816daaf431838","905d94a6abb5398fa1995f6398e3f6fc"],"clusterUuid":"a0468dc645223f67bd0f2ab95276bbae","description":"this is a vm","strategy":"InstantStart"}}' \ http://localhost:8080/zstack/v1/vm-instances
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|云主机名称| |0.6| |instanceOfferingUuid|String|body(包含在params结构中)|计算规格UUID- 指定云主机的CPU、内存等参数。
| |0.6| |imageUuid|String|body(包含在params结构中)|镜像UUID- 云主机的根云盘会从该字段指定的镜像创建。
| |0.6| |l3NetworkUuids|List|body(包含在params结构中)|三层网络UUID列表- 可指定一个或多个三层网络,云主机会在每个三层网络上创建一个网卡。
| |0.6| |type (可选)|String|body(包含在params结构中)|云主机类型- 保留字段,无需指定。
| - UserVm - ApplianceVm
|0.6| |rootDiskOfferingUuid (可选)|String|body(包含在params结构中)|根云盘规格UUID- 如果imageUuid字段指定的镜像类型是ISO,该字段必须指定以确定需要创建的根云盘大小。 - 如果镜像类型是非ISO,该字段无需指定。
| |0.6| |dataDiskOfferingUuids (可选)|List|body(包含在params结构中)|云盘规格UUID列表- 可指定一个或多个云盘规格UUID(UUID可以重复)为云主机创建一个或多个数据云盘。
| |0.6| |zoneUuid (可选)|String|body(包含在params结构中)|区域UUID- 若指定,云主机会在指定区域创建。
| |0.6| |clusterUuid (可选)|String|body(包含在params结构中)|集群UUID- 若指定,云主机会在指定集群创建,该字段优先级高于zoneUuid。
| |0.6| |hostUuid (可选)|String|body(包含在params结构中)|物理机UUID- 若指定,云主机会在指定物理机创建,该字段优先级高于zoneUuid和clusterUuid。
| |0.6| |primaryStorageUuidForRootVolume (可选)|String|body(包含在params结构中)|主存储UUID- 若指定,云主机的根云盘会在指定主存储创建。
| |1.8| |description (可选)|String|body(包含在params结构中)|云主机的详细描述| |0.6| |defaultL3NetworkUuid (可选)|String|body(包含在params结构中)|默认三层网络UUID- 当l3NetworkUuids指定了多个三层网络时,该字段指定提供默认路由的三层网络。 - 若不指定,l3NetworkUuids
的第一个网络被选为默认网络。
| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|资源UUID- 若指定,云主机会使用该字段值作为UUID。
| |0.6| |systemTags (可选)|List|body|云主机系统标签| |0.6| |userTags (可选)|List|body|云主机用户标签| |0.6| |strategy (可选)|String|body(包含在params结构中)|云主机创建策略- 创建后立刻启动 - 创建后不启动
| |0.6|
Note:
从ZStack 2.2开始,支持亲和组功能,SystemTags增加affinityGroup选项。
选项格式为:
affinityGroupUuid::UUID
例如:
affinityGroupUuid::5fd71606d5af451d981413f35367a8d6
API返回
返回示例
{ "inventory": { "uuid": "6efab7159c6932429c6b0e7e0b64b660", "name": "Test-VM", "description": "web server VM", "zoneUuid": "d10bd7a9565138efaf6171db8e18fa7d", "clusterUuid": "692c71639d873bf6a356cd8e285d0d9c", "imageUuid": "28061e65e48037eda71b53a0732bf087", "hostUuid": "f877177de7bd377e811bc6313878b2b1", "lastHostUuid": "a3ccdc90a600334f994c69aee4270ac5", "instanceOfferingUuid": "9a874241f867333ca0bf0ab2134f8515", "rootVolumeUuid": "f52d7c94d69d3bbb97d36a270fe910c3", "platform": "Linux", "defaultL3NetworkUuid": "2ac1b70fdb0f38769a29c6ebd0262cca", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "Nov 14, 2017 10:20:57 PM", "lastOpDate": "Nov 14, 2017 10:20:57 PM", "state": "Running", "vmNics": [ { "uuid": "0dfbb8a297e9349ea8799c4ce48c6d10", "vmInstanceUuid": "6efab7159c6932429c6b0e7e0b64b660", "usedIpUuid": "39b57596a8ba35289bd9f40efceeae03", "l3NetworkUuid": "2ac1b70fdb0f38769a29c6ebd0262cca", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "Nov 14, 2017 10:20:57 PM", "lastOpDate": "Nov 14, 2017 10:20:57 PM" } ], "allVolumes": [ { "uuid": "f52d7c94d69d3bbb97d36a270fe910c3", "name": "Root-Volume-For-VM-6efab7159c6932429c6b0e7e0b64b660", "primaryStorageUuid": "4ed5bbb150a034b5917e7e6c9c4b8170", "vmInstanceUuid": "6efab7159c6932429c6b0e7e0b64b660", "diskOfferingUuid": "0521187274d73f5b936c22b145384c74", "rootImageUuid": "28061e65e48037eda71b53a0732bf087", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-f52d7c94d69d3bbb97d36a270fe910c3/f52d7c94d69d3bbb97d36a270fe910c3.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Nov 14, 2017 10:20:57 PM", "lastOpDate": "Nov 14, 2017 10:20:57 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String|上一次运行云主机的物理机UUID|0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String|云主机运行平台|0.6| |defaultL3NetworkUuid|String|默认三层网络UUID|0.6| |type|String|云主机类型|0.6| |hypervisorType|String|云主机的hypervisor类型|0.6| |memorySize|Long|内存大小|0.6| |cpuNum|Integer|cpu数量|0.6| |cpuSpeed|Long|cpu主频|0.6| |allocatorStrategy|String|分配策略|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String|云主机的可用状态|0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#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| |netmask|String|子网掩码|0.6| |gateway|String|网关|0.6| |metaData|String|内部使用的保留域|0.6| |deviceId|Integer|设备ID- 标识网卡在客户操作系统(guest operating system)以太网设备中顺序的整形数字。 - 例如, 0通常代表eth0,1通常代表eth1。
|0.6| |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|设备ID|0.6| |state|String|云盘的可用状态|0.6| |status|String|云盘的连接状态|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |isShareable|Boolean|云盘是否共享|0.6|
SDK示例
Java SDK
CreateVmInstanceAction action = new CreateVmInstanceAction(); action.name = "vm1"; action.instanceOfferingUuid = "ae97ced44efc3314b8f7798972b4ba1a"; action.imageUuid = "da119f7906513eccabf271991c35a65e"; action.l3NetworkUuids = asList("cc0e4c5e77df3af68e59668e7f9e06c5"); action.dataDiskOfferingUuids = asList("19d22d051b063d379a2816daaf431838","905d94a6abb5398fa1995f6398e3f6fc"); action.clusterUuid = "a0468dc645223f67bd0f2ab95276bbae"; action.description = "this is a vm"; action.strategy = "InstantStart"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; CreateVmInstanceAction.Result res = action.call();
Python SDK
CreateVmInstanceAction action = CreateVmInstanceAction() action.name = "vm1" action.instanceOfferingUuid = "ae97ced44efc3314b8f7798972b4ba1a" action.imageUuid = "da119f7906513eccabf271991c35a65e" action.l3NetworkUuids = [cc0e4c5e77df3af68e59668e7f9e06c5] action.dataDiskOfferingUuids = [19d22d051b063d379a2816daaf431838, 905d94a6abb5398fa1995f6398e3f6fc] action.clusterUuid = "a0468dc645223f67bd0f2ab95276bbae" action.description = "this is a vm" action.strategy = "InstantStart" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" CreateVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
删除云主机(DestroyVmInstance)
删除一个云主机。
API请求
URLs
DELETE zstack/v1/vm-instances/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: 8d618c25ba3b4eb7bc6dda7e47d1b6b4" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/5e22e2b1c4ab40739cd0b7717368dfa7
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DestroyVmInstanceAction action = new DestroyVmInstanceAction(); action.uuid = "c0b82973fbed42a09f3a30ce142fb168"; action.deleteMode = "Permissive"; action.sessionId = "97ddb4b10e34452c90d8591927cf3de5"; DestroyVmInstanceAction.Result res = action.call();
Python SDK
DestroyVmInstanceAction action = DestroyVmInstanceAction() action.uuid = "0de3629902f1449d86256934552d5b3d" action.deleteMode = "Permissive" action.sessionId = "931c9e7e586c4b5fa44ed1155985ac1a" DestroyVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
恢复已删除云主机(RecoverVmInstance)
恢复一个处于Destroyed状态的云主机。恢复后云主机处于Stopped状态并且没有IP地址。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "recoverVmInstance": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"recoverVmInstance":{}}' \ http://localhost:8080/zstack/v1/vm-instances/0eb6f6f88ff93da48cfc5bca0dbd5c18/actions
参数列表
|名字|类型|位置|描述|可选值|起始版| |--|--|--|--|---|---| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "4440f52fa4344c0d96bee2c64abc63b0", "name": "Test-VM", "description": "web server VM", "zoneUuid": "09116d61ae67474fa98800ffd6cbddf8", "clusterUuid": "843410c7167b40fcbebfe900fcabc682", "imageUuid": "cd5cf6a07eee44b3a73aee38a8c53340", "hostUuid": "1ec1a7512b49473bb986047d724a88ba", "lastHostUuid": "18ce8c8a99b844be9e0519f36d305c0c", "instanceOfferingUuid": "2e8bb415edaa47f9aeda8b1544abfc96", "rootVolumeUuid": "ce738bcdd08244b387e91f1d055b626c", "platform": "Linux", "defaultL3NetworkUuid": "2065a1b27b3c45888f4a618aa8665887", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:48 PM", "lastOpDate": "May 11, 2017 1:22:48 PM", "state": "Stopped", "vmNics": [ { "uuid": "b463c5618d1a4f81920ed26ed2b4c2bf", "vmInstanceUuid": "4440f52fa4344c0d96bee2c64abc63b0", "l3NetworkUuid": "2065a1b27b3c45888f4a618aa8665887", "mac": "00:0c:29:bd:99:fc", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:48 PM", "lastOpDate": "May 11, 2017 1:22:48 PM" } ], "allVolumes": [ { "uuid": "ce738bcdd08244b387e91f1d055b626c", "name": "Root-Volume-For-VM-4440f52fa4344c0d96bee2c64abc63b0", "primaryStorageUuid": "1710c016fefa49738c276a0b7eaff4b9", "vmInstanceUuid": "4440f52fa4344c0d96bee2c64abc63b0", "diskOfferingUuid": "31d054e6c05d4deabc6b610c88d32525", "rootImageUuid": "cd5cf6a07eee44b3a73aee38a8c53340", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-ce738bcdd08244b387e91f1d055b626c/ce738bcdd08244b387e91f1d055b626c.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:48 PM", "lastOpDate": "May 11, 2017 1:22:48 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
RecoverVmInstanceAction action = new RecoverVmInstanceAction(); action.uuid = "526fac8545fb4aa0aa2c78209378d63f"; action.sessionId = "a52aa10c9d5d445cb44593e21c3895f3"; RecoverVmInstanceAction.Result res = action.call();
Python SDK
RecoverVmInstanceAction action = RecoverVmInstanceAction() action.uuid = "d0b44ed4139f4a7fa50951b99c9b2fd3" action.sessionId = "078d6751ce124bd5a1fb00015116db8b" RecoverVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
彻底删除云主机(ExpungeVmInstance)
彻底删除一个处于Destroyed状态的云主机。该操作会从数据库里面删除云主机并在主存储上删除该云主机的根云盘。该操作一旦执行就不可恢复。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "expungeVmInstance": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"expungeVmInstance":{}}' \ http://localhost:8080/zstack/v1/vm-instances/e57788f713963e98a99a9f6b0bd8482c/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
ExpungeVmInstanceAction action = new ExpungeVmInstanceAction(); action.uuid = "f3b0b9538e6a49a88e189ba2c42b728e"; action.sessionId = "332f2d77997446fbaef62df0411b2635"; ExpungeVmInstanceAction.Result res = action.call();
Python SDK
ExpungeVmInstanceAction action = ExpungeVmInstanceAction() action.uuid = "1cc86ac86211480485a251a48bc1928e" action.sessionId = "6af024d8e8bf44709b42ffa623e96073" ExpungeVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
查询云主机(QueryVmInstance)
API请求
URLs
GET zstack/v1/vm-instances GET zstack/v1/vm-instances/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 06771ba1b893402bb4c715b7acf3606e" \ -X GET http://localhost:8080/zstack/v1/vm-instances?q=name=vm1&q=vmNics.ip=192.168.20.100
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 95c7b190063f423ea6b305f054af8bf5" \ -X GET http://localhost:8080/zstack/v1/vm-instances/3b9c1b2bca5848459881bfad378540b5
可查询字段
运行zstack-cli命令行工具,输入QueryVmInstance
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{ "inventories": [ { "uuid": "bece18afd5af4a8cbcc87496aa3ae8a8", "name": "Test-VM", "description": "web server VM", "zoneUuid": "c0e8b8f5d43f454d8feccc0e1e5cf119", "clusterUuid": "e54efff1e153434395450e1dffa646df", "imageUuid": "21185daf4c3e46718be48005cbd7893d", "hostUuid": "474924e1b9c743119cb892e4223598d2", "lastHostUuid": "d059fbc6f21e44f1a9c5d84ee22c6913", "instanceOfferingUuid": "83c3e86180354d4e800104b9393842f7", "rootVolumeUuid": "b24130cd01b14e2ca1ee1e46fb0011bb", "platform": "Linux", "defaultL3NetworkUuid": "3d875625d62944069cd042aacf64b940", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:23:02 PM", "lastOpDate": "May 11, 2017 1:23:02 PM", "state": "Running", "vmNics": [ { "uuid": "e4c2726154ba431d9b7d3fab19d5a969", "vmInstanceUuid": "bece18afd5af4a8cbcc87496aa3ae8a8", "usedIpUuid": "41be2de0c7e64c519e5ccc6f739f6094", "l3NetworkUuid": "3d875625d62944069cd042aacf64b940", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:23:02 PM", "lastOpDate": "May 11, 2017 1:23:02 PM" } ], "allVolumes": [ { "uuid": "b24130cd01b14e2ca1ee1e46fb0011bb", "name": "Root-Volume-For-VM-bece18afd5af4a8cbcc87496aa3ae8a8", "primaryStorageUuid": "2fc0cd0b063543089d0c13b9fe37e706", "vmInstanceUuid": "bece18afd5af4a8cbcc87496aa3ae8a8", "diskOfferingUuid": "9cea3663fd2f4aa58232ad72ef7a423c", "rootImageUuid": "21185daf4c3e46718be48005cbd7893d", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-b24130cd01b14e2ca1ee1e46fb0011bb/b24130cd01b14e2ca1ee1e46fb0011bb.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:23:02 PM", "lastOpDate": "May 11, 2017 1:23:02 PM" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
QueryVmInstanceAction action = new QueryVmInstanceAction(); action.conditions = asList("name=vm1","vmNics.ip=192.168.20.100"); action.sessionId = "1a2f35770a8e4e53b4bfb9d0d7ae7e50"; QueryVmInstanceAction.Result res = action.call();
Python SDK
QueryVmInstanceAction action = QueryVmInstanceAction() action.conditions = ["name=vm1","vmNics.ip=192.168.20.100"] action.sessionId = "0dd4f4ec663f4502ba3fedda9d0ebc1b" QueryVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
启动云主机(StartVmInstance)
启动一个云主机。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "startVmInstance": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"startVmInstance":{}}' \ http://localhost:8080/zstack/v1/vm-instances/647db3dbf974372ead60d4ba1c9efac3/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |clusterUuid (可选)|String|body(包含在startVmInstance结构中)|集群UUID。若指定,云主机将在该集群启动| |0.6| |hostUuid (可选)|String|body(包含在startVmInstance结构中)|物理机UUID。若指定,云主机将在该物理机启动。该字段覆盖clusterUuid字段| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "869bb57a87374cc694d2334990c5a233", "name": "Test-VM", "description": "web server VM", "zoneUuid": "7c92e2b8744a460982dc796bff00ad37", "clusterUuid": "59bdb546d799411181fae0c012f37284", "imageUuid": "2faafd261d684300a55e00491afb5cff", "hostUuid": "dab2aa9174eb4a2b984dff9687bbaef6", "lastHostUuid": "f3c7eeaa835e49348182e291d117b025", "instanceOfferingUuid": "384931068eb84400b72184681d051336", "rootVolumeUuid": "70dff72f254a43c3b37673f9c79853a5", "platform": "Linux", "defaultL3NetworkUuid": "b2169bdf7c2a410d82cd701fcfc31118", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:43 PM", "lastOpDate": "May 11, 2017 1:22:43 PM", "state": "Running", "vmNics": [ { "uuid": "131852fc640d424baa44bc6542744b9b", "vmInstanceUuid": "869bb57a87374cc694d2334990c5a233", "usedIpUuid": "df902be468df49af8aced6c2ea73f6dc", "l3NetworkUuid": "b2169bdf7c2a410d82cd701fcfc31118", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:43 PM", "lastOpDate": "May 11, 2017 1:22:43 PM" } ], "allVolumes": [ { "uuid": "70dff72f254a43c3b37673f9c79853a5", "name": "Root-Volume-For-VM-869bb57a87374cc694d2334990c5a233", "primaryStorageUuid": "02b0217cc0264901b8f9cf9afb1ff3ee", "vmInstanceUuid": "869bb57a87374cc694d2334990c5a233", "diskOfferingUuid": "a3a1409ecc2f4acaa6453595d82e02e7", "rootImageUuid": "2faafd261d684300a55e00491afb5cff", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-70dff72f254a43c3b37673f9c79853a5/70dff72f254a43c3b37673f9c79853a5.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:43 PM", "lastOpDate": "May 11, 2017 1:22:43 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
StartVmInstanceAction action = new StartVmInstanceAction(); action.uuid = "22771459f2184f2f96c8da84b7e660d8"; action.sessionId = "a6beddb0aa754b4b992d92dc13ff0c2c"; StartVmInstanceAction.Result res = action.call();
Python SDK
StartVmInstanceAction action = StartVmInstanceAction() action.uuid = "b2b7503e1fdd482594700cf35715122a" action.sessionId = "207b50ceb1b64ea48a7446b92932d4cb" StartVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
停止云主机(StopVmInstance)
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "stopVmInstance": { "type": "grace" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"stopVmInstance":{"type":"grace"}}' \ http://localhost:8080/zstack/v1/vm-instances/5e2f112ee1ef3467933e1006b639b023/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |type (可选)|String|body(包含在stopVmInstance结构中)|停止云主机的方式。- grace:优雅关机,需要云主机里安装了相关ACPI驱动; - cold:冷关机,相当于直接断电
| - grace - cold
|0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6| |stopHA (可选)|String|body(包含在stopVmInstance结构中)|彻底关闭HA云主机| |2.2|
API返回
返回示例
{ "inventory": { "uuid": "e418f27c6df649e1812bbff68b5d175e", "name": "Test-VM", "description": "web server VM", "zoneUuid": "177c3a1f0a894d809b820907983bf6c4", "clusterUuid": "f0309957444e455d8faecbc7b7effeac", "imageUuid": "6d18d7d55229468b83cc43aafb8b294c", "hostUuid": "d0f1bd8f052546a09fd4cccac59e1052", "lastHostUuid": "3a4164b06d8344cfa0979f8c9037d9fa", "instanceOfferingUuid": "b44220cafa1542f8b72f18ef191c235a", "rootVolumeUuid": "ffdf9ca437224ddf8bc8f8cbdd41cda7", "platform": "Linux", "defaultL3NetworkUuid": "e3a859fec60e491aaf43461ccd7e96aa", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:51 PM", "lastOpDate": "May 11, 2017 1:22:51 PM", "state": "Stopped", "vmNics": [ { "uuid": "e8f195baa4334814bfcf98d67d849538", "vmInstanceUuid": "e418f27c6df649e1812bbff68b5d175e", "usedIpUuid": "30b22ae625ea48af90fe9fa9fa71be06", "l3NetworkUuid": "e3a859fec60e491aaf43461ccd7e96aa", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:51 PM", "lastOpDate": "May 11, 2017 1:22:51 PM" } ], "allVolumes": [ { "uuid": "ffdf9ca437224ddf8bc8f8cbdd41cda7", "name": "Root-Volume-For-VM-e418f27c6df649e1812bbff68b5d175e", "primaryStorageUuid": "07d026e9cd1a49be99149fce27ec69c3", "vmInstanceUuid": "e418f27c6df649e1812bbff68b5d175e", "diskOfferingUuid": "359c702c8fab4220af80fc5d3c5508b5", "rootImageUuid": "6d18d7d55229468b83cc43aafb8b294c", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-ffdf9ca437224ddf8bc8f8cbdd41cda7/ffdf9ca437224ddf8bc8f8cbdd41cda7.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:51 PM", "lastOpDate": "May 11, 2017 1:22:51 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
StopVmInstanceAction action = new StopVmInstanceAction(); action.uuid = "b3edccc737664a24b6b8be3a249b87fb"; action.type = "grace"; action.sessionId = "7f36a5bff7ae49c185302dca91470133"; StopVmInstanceAction.Result res = action.call();
Python SDK
StopVmInstanceAction action = StopVmInstanceAction() action.uuid = "a6162b0be4104d069ab42f708d7da150" action.type = "grace" action.sessionId = "d369764a2e29479c9e70f86a3b4662e3" StopVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
重启云主机(RebootVmInstance)
重启一个云主机。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "rebootVmInstance": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"rebootVmInstance":{}}' \ http://localhost:8080/zstack/v1/vm-instances/5bae2edd13e73805a552df9a2aa8d4c9/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "4c81ab25882c4251850ea369a06e267a", "name": "Test-VM", "description": "web server VM", "zoneUuid": "a2fe21376e754d6bb3f6e8b781730e5b", "clusterUuid": "1f1b25e36e7341678aae2c256fc357f9", "imageUuid": "27dcc6b3ad714b09bd81b74bda54d51d", "hostUuid": "569f630330bc44a1bfded303747f7530", "lastHostUuid": "2c23ba0fc8de41e2a3ab2ee19cc5fa2a", "instanceOfferingUuid": "f58fa35dcea44a69ab1e1c4c82e9caaa", "rootVolumeUuid": "ca550f27d9c54ca8839e01f61f27d8de", "platform": "Linux", "defaultL3NetworkUuid": "ba24379458954aa4bd867ccacacb4c13", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:45 PM", "lastOpDate": "May 11, 2017 1:22:45 PM", "state": "Running", "vmNics": [ { "uuid": "a9354a686afa4061a1ec2bdc61539794", "vmInstanceUuid": "4c81ab25882c4251850ea369a06e267a", "usedIpUuid": "07b81e59fafc4227a49dc59992546612", "l3NetworkUuid": "ba24379458954aa4bd867ccacacb4c13", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:45 PM", "lastOpDate": "May 11, 2017 1:22:45 PM" } ], "allVolumes": [ { "uuid": "ca550f27d9c54ca8839e01f61f27d8de", "name": "Root-Volume-For-VM-4c81ab25882c4251850ea369a06e267a", "primaryStorageUuid": "7f102409b25c4a2a851acbad2cbbc040", "vmInstanceUuid": "4c81ab25882c4251850ea369a06e267a", "diskOfferingUuid": "4b4d4afaa81b496e86431a37d6b07258", "rootImageUuid": "27dcc6b3ad714b09bd81b74bda54d51d", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-ca550f27d9c54ca8839e01f61f27d8de/ca550f27d9c54ca8839e01f61f27d8de.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:45 PM", "lastOpDate": "May 11, 2017 1:22:45 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
RebootVmInstanceAction action = new RebootVmInstanceAction(); action.uuid = "69a8c3323e404923ac413a913b03e1c6"; action.sessionId = "6c8bbc1f21c64176b782ac60e6ee39da"; RebootVmInstanceAction.Result res = action.call();
Python SDK
RebootVmInstanceAction action = RebootVmInstanceAction() action.uuid = "f2dfa73793d048148a951f59cee38e65" action.sessionId = "656c2f3efb3844efb6fad3f37e2fb6b8" RebootVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
暂停云主机(PauseVmInstance)
暂停一个云主机,云主机状态仍然存在内存里面,稍后可以恢复。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "pauseVmInstance": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"pauseVmInstance":{}}' \ http://localhost:8080/zstack/v1/vm-instances/b7defb2dd07a38a8af7b98737a92080d/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "5224e72fe75143a69862a7eab5520347", "name": "Test-VM", "description": "web server VM", "zoneUuid": "ece1c6bdefd54f6dadb64e8eefe7cbe4", "clusterUuid": "161557a393b7411ebdd6d40e3d48bbeb", "imageUuid": "9a711ee030254175a5d133da41686c08", "hostUuid": "77b72c3d5aec40b8a15fc2d7fb39860e", "lastHostUuid": "8ca642e463d84537b468dc32e79ed620", "instanceOfferingUuid": "e8d50392947f4b2c85680c7a72253fcd", "rootVolumeUuid": "c504d4d0a1044d3f95a26ce3dc39e107", "platform": "Linux", "defaultL3NetworkUuid": "43b5659069af4524a4e3eebf84aeddd1", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:23:04 PM", "lastOpDate": "May 11, 2017 1:23:04 PM", "state": "Running", "vmNics": [ { "uuid": "07f326b48f42442fbd39efa2557db194", "vmInstanceUuid": "5224e72fe75143a69862a7eab5520347", "usedIpUuid": "1085d693e9a8479a99b2b3e3f18cb726", "l3NetworkUuid": "43b5659069af4524a4e3eebf84aeddd1", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:23:04 PM", "lastOpDate": "May 11, 2017 1:23:04 PM" } ], "allVolumes": [ { "uuid": "c504d4d0a1044d3f95a26ce3dc39e107", "name": "Root-Volume-For-VM-5224e72fe75143a69862a7eab5520347", "primaryStorageUuid": "d1dd44633c124974aac0c97d7074b3f6", "vmInstanceUuid": "5224e72fe75143a69862a7eab5520347", "diskOfferingUuid": "ebb6ea5a2ba14f46b5fe5d59457979d0", "rootImageUuid": "9a711ee030254175a5d133da41686c08", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-c504d4d0a1044d3f95a26ce3dc39e107/c504d4d0a1044d3f95a26ce3dc39e107.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:23:04 PM", "lastOpDate": "May 11, 2017 1:23:04 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
PauseVmInstanceAction action = new PauseVmInstanceAction(); action.uuid = "4d525113c59c4e91bfa890d524cfee0b"; action.sessionId = "715443ea455b425f89759275d9dc1078"; PauseVmInstanceAction.Result res = action.call();
Python SDK
PauseVmInstanceAction action = PauseVmInstanceAction() action.uuid = "f0760df45b8d4573888f3f64c50a46d7" action.sessionId = "9083c2afd08b4a64a90f4b5cefc64d04" PauseVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
恢复暂停的云主机(ResumeVmInstance)
恢复一个被暂停的云主机,云主机从内存中恢复运行。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "resumeVmInstance": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"resumeVmInstance":{}}' \ http://localhost:8080/zstack/v1/vm-instances/ab9bacf8136c3c55ac77dae5f6d6f503/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "0edea9533d8b40d088142690079aab54", "name": "Test-VM", "description": "web server VM", "zoneUuid": "3ac1787f20e649a2a048ed872606d9b9", "clusterUuid": "f81f87664421484b9741c306be27a78d", "imageUuid": "48c35c077dbe4150b4c2d7cf286ea6fc", "hostUuid": "856a341eb6714fcb93c63cc2a69e71b4", "lastHostUuid": "75140dd534054382ab943d5616444c55", "instanceOfferingUuid": "9a25b44144dd43949aff2b56782e83c4", "rootVolumeUuid": "6d47df60169c40718977a8e7100a2de9", "platform": "Linux", "defaultL3NetworkUuid": "4a776437ef074b39bb0f80f7588a5a00", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:34 PM", "lastOpDate": "May 11, 2017 1:22:34 PM", "state": "Running", "vmNics": [ { "uuid": "b1054dbd2676487798b4c245b5c6d021", "vmInstanceUuid": "0edea9533d8b40d088142690079aab54", "usedIpUuid": "257530d21e95436fbf54d8b9cd697369", "l3NetworkUuid": "4a776437ef074b39bb0f80f7588a5a00", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:34 PM", "lastOpDate": "May 11, 2017 1:22:34 PM" } ], "allVolumes": [ { "uuid": "6d47df60169c40718977a8e7100a2de9", "name": "Root-Volume-For-VM-0edea9533d8b40d088142690079aab54", "primaryStorageUuid": "8e08798c1e90426783e37baa69f1234e", "vmInstanceUuid": "0edea9533d8b40d088142690079aab54", "diskOfferingUuid": "3ca00e5a2b764353bba54287e5f5ffac", "rootImageUuid": "48c35c077dbe4150b4c2d7cf286ea6fc", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-6d47df60169c40718977a8e7100a2de9/6d47df60169c40718977a8e7100a2de9.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:34 PM", "lastOpDate": "May 11, 2017 1:22:34 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
ResumeVmInstanceAction action = new ResumeVmInstanceAction(); action.uuid = "c1304094962b4254b4d36c6e2744c2d5"; action.sessionId = "45e29136a13c49108df2fc7671c72431"; ResumeVmInstanceAction.Result res = action.call();
Python SDK
ResumeVmInstanceAction action = ResumeVmInstanceAction() action.uuid = "24876a8330574db78649efaf8bce7e62" action.sessionId = "10f42b569887433fabdbb82672d32269" ResumeVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
重置云主机(ReimageVmInstance)
将一个云主机的根云盘重置为最初状态。该API只对从非ISO创建出的云主机有效。
Warning: 执行该API后,云主机根云盘重置成最初创建的状态,意味着所有后续写入的数据都会被丢失,该操作不可逆!
API请求
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "reimageVmInstance": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"reimageVmInstance":{}}' \ http://localhost:8080/zstack/v1/vm-instances/f38615d717a438c39eca3b8b560a00ef/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "02e38dad722747d0bdffb3961bd79eea", "name": "Test-VM", "description": "web server VM", "zoneUuid": "c19ee28239b24b1db182e6e19ca794f5", "clusterUuid": "62b14077a5f94e8592f352fe8aa15c9c", "imageUuid": "5d54ff86cec344488ddec356dfc37e5b", "hostUuid": "c7941ae057464ea6902d642ad2533482", "lastHostUuid": "0ddb5483be4a45e2b046248a583c85cb", "instanceOfferingUuid": "e20853ce9f8f4490a31bc95087dc97b5", "rootVolumeUuid": "cd56311ff0ab471ea5c3d33764b89261", "platform": "Linux", "defaultL3NetworkUuid": "3b439cc3c89a4664adbd032ae4490d67", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:49 PM", "lastOpDate": "May 11, 2017 1:22:49 PM", "state": "Running", "vmNics": [ { "uuid": "24cd963ef365498f90e8647adf82256b", "vmInstanceUuid": "02e38dad722747d0bdffb3961bd79eea", "usedIpUuid": "0daee724e1b04af5967dab70a2202450", "l3NetworkUuid": "3b439cc3c89a4664adbd032ae4490d67", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:49 PM", "lastOpDate": "May 11, 2017 1:22:49 PM" } ], "allVolumes": [ { "uuid": "cd56311ff0ab471ea5c3d33764b89261", "name": "Root-Volume-For-VM-02e38dad722747d0bdffb3961bd79eea", "primaryStorageUuid": "3737cc05e3bd4161bc45b66e84a28ddc", "vmInstanceUuid": "02e38dad722747d0bdffb3961bd79eea", "diskOfferingUuid": "06514fb2d74a4158bf9660a599844b16", "rootImageUuid": "5d54ff86cec344488ddec356dfc37e5b", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-cd56311ff0ab471ea5c3d33764b89261/cd56311ff0ab471ea5c3d33764b89261.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:49 PM", "lastOpDate": "May 11, 2017 1:22:49 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
ReimageVmInstanceAction action = new ReimageVmInstanceAction(); action.vmInstanceUuid = "b733a61173bc4a85974a5a1391b62d12"; action.sessionId = "04d122b7e2934964af3c2af59130e600"; ReimageVmInstanceAction.Result res = action.call();
Python SDK
ReimageVmInstanceAction action = ReimageVmInstanceAction() action.vmInstanceUuid = "9ef51a211ed14d839807bfe2e2822f1a" action.sessionId = "a8ccdcd85e2e4314b6a4a5379b5a9df9" ReimageVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
热迁移云主机(MigrateVm)
将云主机热迁移至另一个物理机。
API请求
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "migrateVm": { "hostUuid": "7571fb72e52b3fcab1a6992e7eef4cce", "migrateFromDestination": false }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"migrateVm":{"hostUuid":"7571fb72e52b3fcab1a6992e7eef4cce","migrateFromDestination":false}}' \ http://localhost:8080/zstack/v1/vm-instances/c53c9b6235703b8ab96c1cc35859242d/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |hostUuid (可选)|String|body(包含在migrateVm结构中)|物理机UUID| |0.6| |migrateFromDestination (可选)|Boolean|body(包含在migrateVm结构中)|从迁移目的物理机器发起迁移命令| |2.3| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "6a3b3b10539b4d40a5b6e57cef5b0717", "name": "Test-VM", "description": "web server VM", "zoneUuid": "05ac7afdd3ea40bf89ddbe3716f4e0e2", "clusterUuid": "35379842f5d94eb599b1bc96c956e373", "imageUuid": "10b5dc2d1a6c447e9d4e70cc459f71ec", "hostUuid": "c165fde695024eca93667e242c7f1293", "lastHostUuid": "78cd869fa5f645e6978ea90c8eeb9284", "instanceOfferingUuid": "a0958bde8d3543cfa2842bfc1bc8a6f6", "rootVolumeUuid": "a7333ce29c2f4f17bc0477d92c72eb65", "platform": "Linux", "defaultL3NetworkUuid": "bd8efb8c9a7540ad9a233b03b87943c2", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:35 PM", "lastOpDate": "May 11, 2017 1:22:35 PM", "state": "Running", "vmNics": [ { "uuid": "d3190167eb8e4302af615006f40c41f7", "vmInstanceUuid": "6a3b3b10539b4d40a5b6e57cef5b0717", "usedIpUuid": "38e1556b5e894d67a4387ec0316b1430", "l3NetworkUuid": "bd8efb8c9a7540ad9a233b03b87943c2", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:35 PM", "lastOpDate": "May 11, 2017 1:22:35 PM" } ], "allVolumes": [ { "uuid": "a7333ce29c2f4f17bc0477d92c72eb65", "name": "Root-Volume-For-VM-6a3b3b10539b4d40a5b6e57cef5b0717", "primaryStorageUuid": "f73b7ea5283e4d41abd97d9477f94309", "vmInstanceUuid": "6a3b3b10539b4d40a5b6e57cef5b0717", "diskOfferingUuid": "712d99bc2bfa424b8ea30b8289d736bd", "rootImageUuid": "10b5dc2d1a6c447e9d4e70cc459f71ec", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/\ vol-a7333ce29c2f4f17bc0477d92c72eb65/a7333ce29c2f4f17bc0477d92c72eb65.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:35 PM", "lastOpDate": "May 11, 2017 1:22:35 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
MigrateVmAction action = new MigrateVmAction(); action.vmInstanceUuid = "354f801b7d194cf4a0d2dd5b5defbc69"; action.hostUuid = "6a29b3ae340f4748bbb03e755f65b0c3"; action.migrateFromDestination = false; action.sessionId = "1bfd2986b4a349829372fcb53a472cc2"; MigrateVmAction.Result res = action.call();
Python SDK
MigrateVmAction action = MigrateVmAction() action.vmInstanceUuid = "4aa10201ab5f4fafbfc87d8a6d7bc44f" action.hostUuid = "a3884b86303a4a4ba3b3df4534bed949" action.migrateFromDestination = false action.sessionId = "4882c0d895a140e48bbe8655d5263e7f" MigrateVmAction.Result res = action.call()
Parent topic: 云主机相关接口
查询共享磁盘所挂载的云主机(QueryShareableVolumeVmInstanceRef)
查询共享磁盘所挂载的云主机
API请求
URLs
GET zstack/v1/volumes/vm-instances/refs
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 9f5a9540d63e4ade922c141078b95af9" \ -X GET http://localhost:8080/zstack/v1/volumes/vm-instances/refs?q=0c917562d5954544b37bf5e0ed0735a6&q=cddc1c17e94a43b5b50e1df53e076d11&q=2&q=Jan 22, 2017 2:41:37 PM&q=Jan 22, 2017 2:43:18 PM
可查询字段
运行zstack-cli命令行工具,输入QueryShareableVolumeVmInstanceRef
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
QueryShareableVolumeVmInstanceRefAction action = new QueryShareableVolumeVmInstanceRefAction(); action.conditions = asList("0c917562d5954544b37bf5e0ed0735a6","cddc1c17e94a43b5b50e1df53e076d11","2","Jan 22, 2017 2:41:37 PM","Jan 22, 2017 2:43:18 PM"); action.sessionId = "9fa1cf123ab04b1691ea509bf48c9071"; QueryShareableVolumeVmInstanceRefAction.Result res = action.call();
Python SDK
QueryShareableVolumeVmInstanceRefAction action = QueryShareableVolumeVmInstanceRefAction() action.conditions = ["0c917562d5954544b37bf5e0ed0735a6","cddc1c17e94a43b5b50e1df53e076d11","2","Jan 22, 2017 2:41:37 PM","Jan 22, 2017 2:43:18 PM"] action.sessionId = "730ddea9ae3246a0ad483f7b6e3bb49f" QueryShareableVolumeVmInstanceRefAction.Result res = action.call()
Parent topic: 云主机相关接口
获取可热迁移的物理机列表(GetVmMigrationCandidateHosts)
获取一个云主机可以热迁移的物理机列表。
API请求
URLs
GET zstack/v1/vm-instances/{vmInstanceUuid}/migration-target-hosts
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth cf673ad3be454b49b24c4405f67531f0" \ -X GET http://localhost:8080/zstack/v1/vm-instances/98995eddf4854acc8b80da119fee81d5/migration-target-hosts
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
``` { "inventories": [ { "zoneUuid": "09ba44cadab94a1a95ab0b5216ace46a", "name": "example", "uuid": "25a4d0f25f5649ae847e81869384f155", "clusterUuid": "d96488a7d4524609a66983de7eb1bc6c", "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, "createDate": "May 11, 2017 1:22:56 PM", "lastOpDate": "May 11, 2017 1:22:56 PM" } ] }
```
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |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| |totalMemoryCapacity|Long| |0.6| |availableMemoryCapacity|Long| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
GetVmMigrationCandidateHostsAction action = new GetVmMigrationCandidateHostsAction(); action.vmInstanceUuid = "9949593f81604daeb21159f1e0525c4a"; action.sessionId = "fb98227d4c434087861e9157db2eb5f7"; GetVmMigrationCandidateHostsAction.Result res = action.call();
Python SDK
GetVmMigrationCandidateHostsAction action = GetVmMigrationCandidateHostsAction() action.vmInstanceUuid = "8b530774005349c8b57b122b89d262d2" action.sessionId = "a15e9d90559c4ed6b12e0ef05f77c493" GetVmMigrationCandidateHostsAction.Result res = action.call()
Parent topic: 云主机相关接口
获取可选择的主存储(GetCandidatePrimaryStoragesForCreatingVm)
获取创建云主机可选择的主存储。用户可通过指定云主机参数,来获取当前参数下可选择的主存储。
API请求
URLs
GET zstack/v1/vm-instances/candidate-storages
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/vm-instances/candidate-storages?imageUuid=5f977e1354aa300bb27e0584d52bb09a&l3NetworkUuids=0276c5ffc04731d6b671c972272bd10a&dataDiskOfferingUuids=0b2b7ff196113ed79dad6bf815a6033e&dataDiskOfferingUuids=cfad76f5d345387d9215773fcd5389c5&clusterUuid=90fac86c000b335396f995bef052fb41
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |imageUuid|String|query|镜像UUID| |2.1| |l3NetworkUuids|List|query|三层网络UUID| |2.1| |rootDiskOfferingUuid (可选)|String|query|根云盘使用的云盘规格UUID,镜像类型为ISO时可选且必选| |2.1| |dataDiskOfferingUuids (可选)|List|query|数据云盘使用的云盘规格UUID| |2.1| |zoneUuid (可选)|String|query|区域UUID| |2.1| |clusterUuid (可选)|String|query|集群UUID| |2.1| |defaultL3NetworkUuid (可选)|String|query|默认三层网络UUID| |2.1| |systemTags (可选)|List|query|系统标签| |2.1| |userTags (可选)|List|query|用户标签| |2.1|
API返回
返回示例
{ "rootVolumePrimaryStorages": [ { "uuid": "971ff3d5e8864cf691a8251022f400e2", "name": "example", "url": "/zstack_ps", "description": "example", "totalCapacity": 3.221225472E11, "availableCapacity": 2.147483648E11, "totalPhysicalCapacity": 3.221225472E11, "availablePhysicalCapacity": 2.147483648E11, "type": "LocalStorage", "state": "Enabled", "status": "Connected", "createDate": "Nov 9, 2017 9:38:50 PM", "lastOpDate": "Nov 9, 2017 9:38:50 PM", "attachedClusterUuids": [ "1332f8ffa99844c6ae7286ca15bb6846" ] } ], "dataVolumePrimaryStorages": { "c1e5bafa00ce49368600670b9d724e7b": [ { "uuid": "f9e90cd9878a4184b3951196e054b978", "name": "example", "url": "/opt/zstack/nfsprimarystorage/prim-f9e90cd9878a4184b3951196e054b978", "description": "example", "totalCapacity": 3.221225472E11, "availableCapacity": 2.147483648E11, "totalPhysicalCapacity": 3.221225472E11, "availablePhysicalCapacity": 2.147483648E11, "type": "NFS", "state": "Enabled", "status": "Connected", "createDate": "Nov 9, 2017 9:38:50 PM", "lastOpDate": "Nov 9, 2017 9:38:50 PM", "attachedClusterUuids": [ "b73387b8d0264553829b72b86e5c57f5" ] } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |dataVolumePrimaryStorages|Map|数据云盘可选主存储,分别对应每一个数据云盘规格|2.1| |success|boolean|操作是否成功|2.1| |rootVolumePrimaryStorages|List|详情参考rootVolumePrimaryStorages|2.1| |error|ErrorCode|详情参考error|2.1|
#rootVolumePrimaryStorages
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.1| |zoneUuid|String|区域UUID|2.1| |name|String|资源名称|2.1| |url|String| |2.1| |description|String|资源的详细描述|2.1| |totalCapacity|Long| |2.1| |availableCapacity|Long| |2.1| |totalPhysicalCapacity|Long| |2.1| |availablePhysicalCapacity|Long| |2.1| |systemUsedCapacity|Long| |2.1| |type|String| |2.1| |state|String| |2.1| |status|String| |2.1| |mountPath|String| |2.1| |createDate|Timestamp|创建时间|2.1| |lastOpDate|Timestamp|最后一次修改时间|2.1| |attachedClusterUuids|List| |2.1|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.1| |description|String|错误的概要描述|2.1| |details|String|错误的详细信息|2.1| |elaboration|String|保留字段,默认为null|2.1| |opaque|LinkedHashMap|保留字段,默认为null|2.1| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.1|
SDK示例
Java SDK
GetCandidatePrimaryStoragesForCreatingVmAction action = new GetCandidatePrimaryStoragesForCreatingVmAction(); action.imageUuid = "5f977e1354aa300bb27e0584d52bb09a"; action.l3NetworkUuids = asList("0276c5ffc04731d6b671c972272bd10a"); action.dataDiskOfferingUuids = asList("0b2b7ff196113ed79dad6bf815a6033e","cfad76f5d345387d9215773fcd5389c5"); action.clusterUuid = "90fac86c000b335396f995bef052fb41"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; GetCandidatePrimaryStoragesForCreatingVmAction.Result res = action.call();
Python SDK
GetCandidatePrimaryStoragesForCreatingVmAction action = GetCandidatePrimaryStoragesForCreatingVmAction() action.imageUuid = "5f977e1354aa300bb27e0584d52bb09a" action.l3NetworkUuids = [0276c5ffc04731d6b671c972272bd10a] action.dataDiskOfferingUuids = [0b2b7ff196113ed79dad6bf815a6033e, cfad76f5d345387d9215773fcd5389c5] action.clusterUuid = "90fac86c000b335396f995bef052fb41" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" GetCandidatePrimaryStoragesForCreatingVmAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机可加载ISO列表(GetCandidateIsoForAttachingVm)
获取一个云主机以加载的ISO列表。
API请求
URLs
GET zstack/v1/vm-instances/{vmInstanceUuid}/iso-candidates
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth fe731654cc114cc3b0cc1cb0bd437f77" \ -X GET http://localhost:8080/zstack/v1/vm-instances/1f65bf61248341708265de7d759828b2/iso-candidates
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "inventories": [ { "uuid": "154c6715c5994bfd8c822fd6fc5792f8", "name": "TinyLinux", "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "qcow2", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "154c6715c5994bfd8c822fd6fc5792f8", "backupStorageUuid": "e7eed90ff5fd4448b3bee5e029c96636", "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd", "status": "Ready" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
GetCandidateIsoForAttachingVmAction action = new GetCandidateIsoForAttachingVmAction(); action.vmInstanceUuid = "9602b2514d61444ebab065a9282851b1"; action.sessionId = "4d6f70aefa1141c7b54b3a1bb1c16e2b"; GetCandidateIsoForAttachingVmAction.Result res = action.call();
Python SDK
GetCandidateIsoForAttachingVmAction action = GetCandidateIsoForAttachingVmAction() action.vmInstanceUuid = "1844fc9ceac541a7947079b6ce3bd077" action.sessionId = "4e6c014978924a2d82177eed81bdd3d6" GetCandidateIsoForAttachingVmAction.Result res = action.call()
Parent topic: 云主机相关接口
获取ISO可加载云主机列表(GetCandidateVmForAttachingIso)
获取一个ISO可以加载到的云主机列表。
API请求
URLs
GET zstack/v1/images/iso/{isoUuid}/vm-candidates
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 54ca471114824451b5b3e4cc22f9a927" \ -X GET http://localhost:8080/zstack/v1/images/iso/3e5e142462c54736b1880b43d49edeba/vm-candidates
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |isoUuid|String|url|ISO UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "inventories": [ { "uuid": "fc6021eb916a455ebec9a11e0d63cbd0", "name": "Test-VM", "description": "web server VM", "zoneUuid": "088cd768f8c04f5696623e84a0656f53", "clusterUuid": "2d2f27bb1e174e2f953f1aa94be188fb", "imageUuid": "97c7cb267cc543139a9c0d11087921ac", "hostUuid": "a6f86394d503450e8a7de13d1a51d1b2", "lastHostUuid": "a2983f9581e44e69b5009da177543894", "instanceOfferingUuid": "3b75115a3e74456aa22b5bd60c2bf1f3", "rootVolumeUuid": "34579777fb8b490589cfcffc78b0d14f", "platform": "Linux", "defaultL3NetworkUuid": "5328503961ad4559aedb71e329d7859b", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:29 PM", "lastOpDate": "May 11, 2017 1:22:29 PM", "state": "Stopped", "vmNics": [ { "uuid": "752777914cf24dfc8bcae3cf8b6b0fdd", "vmInstanceUuid": "fc6021eb916a455ebec9a11e0d63cbd0", "usedIpUuid": "1ce7fe9ea7e64563af1fab01cb96757f", "l3NetworkUuid": "5328503961ad4559aedb71e329d7859b", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:29 PM", "lastOpDate": "May 11, 2017 1:22:29 PM" } ], "allVolumes": [ { "uuid": "34579777fb8b490589cfcffc78b0d14f", "name": "Root-Volume-For-VM-fc6021eb916a455ebec9a11e0d63cbd0", "primaryStorageUuid": "3fe1f3f04b2148df8f10fc95fe487a24", "vmInstanceUuid": "fc6021eb916a455ebec9a11e0d63cbd0", "diskOfferingUuid": "0f5be2b8331f4e359aaebfd84af41acd", "rootImageUuid": "97c7cb267cc543139a9c0d11087921ac", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-34579777fb8b490589cfcffc78b0d14f/34579777fb8b490589cfcffc78b0d14f.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:29 PM", "lastOpDate": "May 11, 2017 1:22:29 PM" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
GetCandidateVmForAttachingIsoAction action = new GetCandidateVmForAttachingIsoAction(); action.isoUuid = "c7824c614de74f908bc7d82e6f16ebe7"; action.sessionId = "24b72cf532ce4e87be824b510dfe8289"; GetCandidateVmForAttachingIsoAction.Result res = action.call();
Python SDK
GetCandidateVmForAttachingIsoAction action = GetCandidateVmForAttachingIsoAction() action.isoUuid = "3916247f217c44de99603f16ebe141bd" action.sessionId = "a43eacd5ff59473f844257917e0b705c" GetCandidateVmForAttachingIsoAction.Result res = action.call()
Parent topic: 云主机相关接口
加载ISO到云主机(AttachIsoToVmInstance)
加载一个ISO镜像到Running或Stopped的云主机。
API请求
URLs
POST zstack/v1/vm-instances/{vmInstanceUuid}/iso/{isoUuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST http://localhost:8080/zstack/v1/vm-instances/b1105c5dd00f323d99aa182dee237628/iso/8f36a77ab76e3425a571a7f75fca2d69
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |isoUuid|String|url|ISO UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "7105b03e09794680b7ba1027f812c987", "name": "Test-VM", "description": "web server VM", "zoneUuid": "8fa381c6f74d4e6fb45fa83536dcd5b8", "clusterUuid": "e3ec6c0da6dd48318e4e714a653de68d", "imageUuid": "d74932c666774571a9fa1dfa648eb1be", "hostUuid": "7eae91b419e444dcb5964557048e8b98", "lastHostUuid": "d6e533fdf3704b77bb2417fdeaf49812", "instanceOfferingUuid": "5d92054212bc468bb1789c3343ed6472", "rootVolumeUuid": "2b0f6bb1aaf44768ad94b8fe2b747f5e", "platform": "Linux", "defaultL3NetworkUuid": "c9527ab637ed43d6a82ef64eaaebc7d4", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:23:01 PM", "lastOpDate": "May 11, 2017 1:23:01 PM", "state": "Running", "vmNics": [ { "uuid": "f20b08a8c81b42959c6b33f34d012cfa", "vmInstanceUuid": "7105b03e09794680b7ba1027f812c987", "usedIpUuid": "1338d1697352464383dbdc9ba89311a6", "l3NetworkUuid": "c9527ab637ed43d6a82ef64eaaebc7d4", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:23:01 PM", "lastOpDate": "May 11, 2017 1:23:01 PM" } ], "allVolumes": [ { "uuid": "2b0f6bb1aaf44768ad94b8fe2b747f5e", "name": "Root-Volume-For-VM-7105b03e09794680b7ba1027f812c987", "primaryStorageUuid": "5ceb65417c3a4e94a375f19bda2470b9", "vmInstanceUuid": "7105b03e09794680b7ba1027f812c987", "diskOfferingUuid": "d6caadf062514f2b8073faefd52fad46", "rootImageUuid": "d74932c666774571a9fa1dfa648eb1be", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/\ vol-2b0f6bb1aaf44768ad94b8fe2b747f5e/2b0f6bb1aaf44768ad94b8fe2b747f5e.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:23:01 PM", "lastOpDate": "May 11, 2017 1:23:01 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
AttachIsoToVmInstanceAction action = new AttachIsoToVmInstanceAction(); action.vmInstanceUuid = "6f18cd9b9c1d4a6a860bf08775572904"; action.isoUuid = "32ff7e18cd844e32a1b0225544ac9539"; action.sessionId = "d495ba4961e14d438c5e3ebb9c0f5996"; AttachIsoToVmInstanceAction.Result res = action.call();
Python SDK
AttachIsoToVmInstanceAction action = AttachIsoToVmInstanceAction() action.vmInstanceUuid = "12819ba2af514022b355d474fe254fae" action.isoUuid = "c907863d2fc84b729bececdab2de5c31" action.sessionId = "b3acb29da25f4bfaa9a6960b8be9c2ca" AttachIsoToVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
卸载云主机上的ISO(DetachIsoFromVmInstance)
如果云主机上挂载有ISO,卸载它。
API请求
URLs
DELETE zstack/v1/vm-instances/{vmInstanceUuid}/iso
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 402a9d5c22174d18b54daf3b989e1c59" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/ee0d9801bd604235b2a20a87fe50c7a4/iso?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6| |isoUuid (可选)|String|body| | |2.3|
API返回
返回示例
{ "inventory": { "uuid": "feeab6de554d4d4eaf17fb691e8dda63", "name": "Test-VM", "description": "web server VM", "zoneUuid": "790456d7616e49fcb345e80b58563ba9", "clusterUuid": "97be6da0b24a46c794f18b9fad27aedd", "imageUuid": "10138844a79b4c17874716d8c0384e64", "hostUuid": "1ab51988599d4ad59f22e19a51698376", "lastHostUuid": "795af9ee7fe94d5e9e26bdd5f1b053bd", "instanceOfferingUuid": "ae0b7d8be34f440bb8dea05be7084b9c", "rootVolumeUuid": "e972fa012e354927a5626db480f5ae90", "platform": "Linux", "defaultL3NetworkUuid": "a7d6601a0d4a456b935c21c89749ef53", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:23:05 PM", "lastOpDate": "May 11, 2017 1:23:05 PM", "state": "Running", "vmNics": [ { "uuid": "1f58b86cd1a34de89c8c12c70821a807", "vmInstanceUuid": "feeab6de554d4d4eaf17fb691e8dda63", "usedIpUuid": "29daa0345667492985c1a818afccff5e", "l3NetworkUuid": "a7d6601a0d4a456b935c21c89749ef53", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:23:05 PM", "lastOpDate": "May 11, 2017 1:23:05 PM" } ], "allVolumes": [ { "uuid": "e972fa012e354927a5626db480f5ae90", "name": "Root-Volume-For-VM-feeab6de554d4d4eaf17fb691e8dda63", "primaryStorageUuid": "5e0d432a99424092be0d6acf075d7ab8", "vmInstanceUuid": "feeab6de554d4d4eaf17fb691e8dda63", "diskOfferingUuid": "c0f9032c3f514e66aa18bd6452da9514", "rootImageUuid": "10138844a79b4c17874716d8c0384e64", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-e972fa012e354927a5626db480f5ae90/e972fa012e354927a5626db480f5ae90.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:23:05 PM", "lastOpDate": "May 11, 2017 1:23:05 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
``` DetachIsoFromVmInstanceAction action = new DetachIsoFromVmInstanceAction(); action.vmInstanceUuid = "381bac8e696b4702aae2cfa5cdf8ae04"; action.sessionId = "4796188f38784439a721f2ef35a0d0d3"; DetachIsoFromVmInstanceAction.Result res = action.call();
```
Python SDK
DetachIsoFromVmInstanceAction action = DetachIsoFromVmInstanceAction() action.vmInstanceUuid = "7cc1f3997d1745698276cbc26262f556" action.sessionId = "1e1f179e29df418c9656aa5a006818cb" DetachIsoFromVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机可加载云盘列表(GetVmAttachableDataVolume)
获取一个云主机可以加载的云盘列表。
API请求
URLs
GET zstack/v1/vm-instances/{vmInstanceUuid}/data-volume-candidates
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth cce1d38a40f1410ba1f4c4d466b19f29" \ -X GET http://localhost:8080/zstack/v1/vm-instances/1e56eb544ac746d0ac275894d8e46cf7/data-volume-candidates
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "inventories": [ { "actualSize": 0, "createDate": "Feb 11, 2018 3:16:43 PM", "description": "", "diskOfferingUuid": "7342651134824ae4b0b8ccf2c3d6ff80", "format": "raw", "installPath": "ceph://pool-0dae37a4ed4845f9bd0b1135e39e32f1/265455ab64634a108c62b887e46cdb86", "isShareable": true, "lastOpDate": "Mar 13, 2018 3:45:20 PM", "name": "host-lc-2", "primaryStorageUuid": "3fb1fe025dd843a088f63638d759faaa", "size": 21474836480, "state": "Enabled", "status": "Ready", "type": "Data", "uuid": "265455ab64634a108c62b887e46cdb86" }, ], "success": true }
SDK示例
Java SDK
GetVmAttachableDataVolumeAction action = new GetVmAttachableDataVolumeAction(); action.vmInstanceUuid = "c754b7c60a0d487ba321c747e8864319"; action.sessionId = "d67ef888a4964f328bf754183a1b66c1"; GetVmAttachableDataVolumeAction.Result res = action.call();
Python SDK
GetVmAttachableDataVolumeAction action = GetVmAttachableDataVolumeAction() action.vmInstanceUuid = "d0f7a36665ae4875a6124e9babf7c4c9" action.sessionId = "974281316f914ffea0a48c2b9e1569d1" GetVmAttachableDataVolumeAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机可加载L3网络列表(GetVmAttachableL3Network)
获取一个云主机可加载三层网络列表。
API请求
URLs
GET zstack/v1/vm-instances/{vmInstanceUuid}/l3-networks-candidates
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: 26f05abbc21441dc921a573eda1fed6b" \ -X GET http://localhost:8080/zstack/v1/vm-instances/16bf0d8cb1e346568e4cfba52c70a9c2/l3-networks-candidates
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "inventories": [ { "uuid": "d2f77ca69b1448d3b8e063c3d551cf1b", "name": "private L3", "type": "L3BasicNetwork", "zoneUuid": "67a6601dc8dd476ebca371123ff03f14", "l2NetworkUuid": "94bdffb080b346e7a3ac2f44f574cc4a", "state": "Enabled", "createDate": "Apr 24, 2017 7:11:08 PM", "lastOpDate": "Apr 24, 2017 7:11:08 PM", "ipRanges": [ { "uuid": "e15972969ac64d1ea01c0c228d969bcc", "l3NetworkUuid": "d2f77ca69b1448d3b8e063c3d551cf1b", "name": "ip range", "startIp": "192.168.0.10", "endIp": "192.168.0.100", "netmask": "255.255.255.0", "gateway": "192.168.0.1", "createDate": "Apr 24, 2017 7:11:08 PM", "lastOpDate": "Apr 24, 2017 7:11:08 PM" } ], "networkServices": [ { "l3NetworkUuid": "d2f77ca69b1448d3b8e063c3d551cf1b", "networkServiceProviderUuid": "a493b6286d6e43f89e06062b7a4ad182", "networkServiceType": "DHCP" }, { "l3NetworkUuid": "d2f77ca69b1448d3b8e063c3d551cf1b", "networkServiceProviderUuid": "a493b6286d6e43f89e06062b7a4ad182", "networkServiceType": "DNS" }, { "l3NetworkUuid": "d2f77ca69b1448d3b8e063c3d551cf1b", "networkServiceProviderUuid": "a493b6286d6e43f89e06062b7a4ad182", "networkServiceType": "SNAT" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |type|String| |0.6| |zoneUuid|String|区域UUID|0.6| |l2NetworkUuid|String|二层网络UUID|0.6| |state|String| |0.6| |dnsDomain|String| |0.6| |system|Boolean| |0.6| |category|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |dns|List| |0.6| |ipRanges|List|详情参考ipRanges|0.6| |networkServices|List|详情参考networkServices|0.6|
#ipRanges
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |startIp|String| |0.6| |endIp|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |networkCidr|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
#networkServices
|名字|类型|描述|起始版本| |--|--|--|----| |l3NetworkUuid|String|三层网络UUID|0.6| |networkServiceProviderUuid|String|网络服务提供模块UUID|0.6| |networkServiceType|String| |0.6|
SDK示例
Java SDK
GetVmAttachableL3NetworkAction action = new GetVmAttachableL3NetworkAction(); action.vmInstanceUuid = "eb2f2966162a47768578a0fb4016d75f"; action.sessionId = "9fe9dda1b076485baa9f3d49dacb0b3d"; GetVmAttachableL3NetworkAction.Result res = action.call();
Python SDK
GetVmAttachableL3NetworkAction action = GetVmAttachableL3NetworkAction() action.vmInstanceUuid = "2c39b050a8984491922aeadbbdd8ed48" action.sessionId = "006575fef83c43c68f7bfb9c05f6b05c" GetVmAttachableL3NetworkAction.Result res = action.call()
Parent topic: 云主机相关接口
加载L3网络到云主机(AttachL3NetworkToVm)
动态添加一个网络到Running或者Stopped的云主机。
API请求
URLs
POST zstack/v1/vm-instances/{vmInstanceUuid}/l3-networks/{l3NetworkUuid}
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{}}' \ http://localhost:8080/zstack/v1/vm-instances/f526e22f739838f4bcdfdd20f0ba8a73/l3-networks/00fab8159d1d3534802c588c2bd9a28b
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |l3NetworkUuid|String|url|三层网络UUID| |0.6| |staticIp (可选)|String|body(包含在params结构中)|指定分配给云主机的IP地址| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "b16b232d4b5740319da85be6a68e6a0a", "name": "Test-VM", "description": "web server VM", "zoneUuid": "333e739c6ff246708b23369f2915b959", "clusterUuid": "48571f1b6f8f4921af6c279c2bbf914f", "imageUuid": "86b2b5376fb64df7ba40b827d2162717", "hostUuid": "65d80ae7e7fa483fbd6996072ed3e187", "lastHostUuid": "4e7e63fce3474120b43877743ed89a64", "instanceOfferingUuid": "0dc751fd45d145fb8e2fadb4d47e40c5", "rootVolumeUuid": "bfe2e29518d242fe9b3da5aace6e6747", "platform": "Linux", "defaultL3NetworkUuid": "f134b88230ad4e88b1491ef04d7383a4", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:32 PM", "lastOpDate": "May 11, 2017 1:22:32 PM", "state": "Running", "vmNics": [ { "uuid": "082b1bd3742d4ec697fada681eab2d57", "vmInstanceUuid": "b16b232d4b5740319da85be6a68e6a0a", "usedIpUuid": "1551d5a5800840bab84af32700400795", "l3NetworkUuid": "f134b88230ad4e88b1491ef04d7383a4", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:32 PM", "lastOpDate": "May 11, 2017 1:22:32 PM" } ], "allVolumes": [ { "uuid": "bfe2e29518d242fe9b3da5aace6e6747", "name": "Root-Volume-For-VM-b16b232d4b5740319da85be6a68e6a0a", "primaryStorageUuid": "e98eeb1371514db29e324c23e6308d1c", "vmInstanceUuid": "b16b232d4b5740319da85be6a68e6a0a", "diskOfferingUuid": "7daeb82295a3485face5395d81c3899e", "rootImageUuid": "86b2b5376fb64df7ba40b827d2162717", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/\ vol-bfe2e29518d242fe9b3da5aace6e6747/bfe2e29518d242fe9b3da5aace6e6747.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:32 PM", "lastOpDate": "May 11, 2017 1:22:32 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
AttachL3NetworkToVmAction action = new AttachL3NetworkToVmAction(); action.vmInstanceUuid = "b8755237b07a4c85923ccc96ccc0d897"; action.l3NetworkUuid = "984008169505409dbbf2bbfee9c45ffe"; action.sessionId = "46b2a5b9b4fb44268f5eb186f69c1937"; AttachL3NetworkToVmAction.Result res = action.call();
Python SDK
AttachL3NetworkToVmAction action = AttachL3NetworkToVmAction() action.vmInstanceUuid = "aed2911fd48a4872858abe8f0bdadecf" action.l3NetworkUuid = "0664fc2951974e338ec6266c8afcc07c" action.sessionId = "0443d11232ae465db92eef1dcbc2a5d8" AttachL3NetworkToVmAction.Result res = action.call()
Parent topic: 云主机相关接口
从云主机卸载网络(DetachL3NetworkFromVm)
从Running或Stopped的云主机上卸载一个网络。
API请求
URLs
DELETE zstack/v1/vm-instances/nics/{vmNicUuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 54d954775dfb45bc8853485f81196cc1" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/\ nics/06147cc0c8214c1cbd9812e01c1cdcce?
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmNicUuid|String|url|云主机网卡UUID,该网卡所在网络会从云主机卸载掉| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "f6d76ee317df487da41b9e78d9c57e73", "name": "Test-VM", "description": "web server VM", "zoneUuid": "3950aa484c25429c937b5ab607eb766e", "clusterUuid": "2365ad371aa64d748fbe9906fb453337", "imageUuid": "b8d76787a9ea43a6b9f0f0dec4623f22", "hostUuid": "5bc096617bde491b99c72d4b0dd84775", "lastHostUuid": "ef213e5c14f24989a5e21eef6e0cdf57", "instanceOfferingUuid": "b7458bf8bba0486681ad789509e57e1b", "rootVolumeUuid": "dcbe00c781f84eb58089a895c51f8ad2", "platform": "Linux", "defaultL3NetworkUuid": "21a031eb6f90440ebd100028416440e9", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:59 PM", "lastOpDate": "May 11, 2017 1:22:59 PM", "state": "Running", "vmNics": [ { "uuid": "abe0204fd42f44bb892cc6db3d22106a", "vmInstanceUuid": "f6d76ee317df487da41b9e78d9c57e73", "usedIpUuid": "d698698d208f4f2a9a95d4ff7f4d2159", "l3NetworkUuid": "21a031eb6f90440ebd100028416440e9", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:59 PM", "lastOpDate": "May 11, 2017 1:22:59 PM" } ], "allVolumes": [ { "uuid": "dcbe00c781f84eb58089a895c51f8ad2", "name": "Root-Volume-For-VM-f6d76ee317df487da41b9e78d9c57e73", "primaryStorageUuid": "49385bf77ef945eba6f82f33878ae09b", "vmInstanceUuid": "f6d76ee317df487da41b9e78d9c57e73", "diskOfferingUuid": "0c4c08b499ca4546a3f67847bd6d954f", "rootImageUuid": "b8d76787a9ea43a6b9f0f0dec4623f22", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/\ vol-dcbe00c781f84eb58089a895c51f8ad2/dcbe00c781f84eb58089a895c51f8ad2.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:59 PM", "lastOpDate": "May 11, 2017 1:22:59 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
``` DetachL3NetworkFromVmAction action = new DetachL3NetworkFromVmAction(); action.vmNicUuid = "6d31c3fb6c0e4299a9b421eda472f95f"; action.sessionId = "a093606a38254c98806e194e9eb84d72"; DetachL3NetworkFromVmAction.Result res = action.call();
```
Python SDK
DetachL3NetworkFromVmAction action = DetachL3NetworkFromVmAction() action.vmNicUuid = "820807ea569441c98db65cf3b436741c" action.sessionId = "62cbb5f992b6489bbb73e93b9fc33edc" DetachL3NetworkFromVmAction.Result res = action.call()
Parent topic: 云主机相关接口
查询云主机网卡(QueryVmNic)
API请求
URLs
GET zstack/v1/vm-instances/nics GET zstack/v1/vm-instances/nics/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: 185cf639b8b64150a2aa22ec84e2517b" \ -X GET http://localhost:8080/zstack/v1/vm-instances/nics?q=ip=172.20.100.100
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: 2e9d7313cbb6495ebb3ee5d0d5d20fde" \ -X GET http://localhost:8080/zstack/v1/vm-instances/nics/7363f51baaab41538d5fe402a69d2529
可查询字段
运行zstack-cli命令行工具,输入QueryVmNic并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
QueryVmNicAction action = new QueryVmNicAction(); action.conditions = asList("ip=172.20.100.100"); action.sessionId = "ca4e59e18f014c21afcdde859b2fba3a"; QueryVmNicAction.Result res = action.call();
Python SDK
QueryVmNicAction action = QueryVmNicAction() action.conditions = ["ip=172.20.100.100"] action.sessionId = "8549e75dbbe548348ca2848692fb7fd8" QueryVmNicAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机网卡限速(SetNicQoS)
API请求
URLs
POST zstack/v1/vm-instances/{uuid}/QoS
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "outboundBandwidth": 819200.0, "inboundBandwidth": 819200.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setNicQos":{"outboundBandwidth":819200.0,"inboundBandwidth":819200.0}}' \ http://localhost:8080/zstack/v1/vm-instances/1d86edf8c2e73980b83005e946449c57/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机网卡UUID| |0.6| |outboundBandwidth (可选)|Long|body(包含在params结构中)|出流量带宽限制| |0.6| |inboundBandwidth (可选)|Long|body(包含在params结构中)|入流量带宽限制| |0.6| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body| | |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetNicQoSAction action = new SetNicQoSAction(); action.uuid = "00cc6445774649b488f6a03b023d6701"; action.outboundBandwidth = 819200.0; action.inboundBandwidth = 819200.0; action.sessionId = "d5a1b6a5424e4b1c8cc23f77e8ba6d58"; SetNicQoSAction.Result res = action.call();
Python SDK
SetNicQoSAction action = SetNicQoSAction() action.uuid = "71548ce2c00240a3a5b065080d47f399" action.outboundBandwidth = 819200.0 action.inboundBandwidth = 819200.0 action.sessionId = "a86b3caf907045b9a82e3a0cb0597330" SetNicQoSAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机网卡限速(GetNicQoS)
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/QoS
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 2715e1f9803745c79e73079012aea97e" \ -X GET http://localhost:8080/zstack/v1/vm-instances/e3594dc6c70e4d6f8488c4d7c69807e6/nic-QoS
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机网卡的UUID| |0.6| |systemTags (可选)|List|query| | |0.6| |userTags (可选)|List|query| | |0.6|
API返回
返回示例
{ "outboundBandwidth": 100000.0, "inboundBandwidth": 200000.0 }
|名字|类型|描述|起始版本| |--|--|--|----| |outboundBandwidth|long| |0.6| |inboundBandwidth|long| |0.6| |success|boolean| |0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。详情参考error|0.6|
#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
GetNicQoSAction action = new GetNicQoSAction(); action.uuid = "9d6e28b144a34b01807a5a9d83ba005c"; action.sessionId = "883ff8e0d0cd43ab91005df23ad062ee"; GetNicQoSAction.Result res = action.call();
Python SDK
GetNicQoSAction action = GetNicQoSAction() action.uuid = "c8d27e7c11f3462cb623068b0e64e39e" action.sessionId = "39f7aad9e84841ffbbe69d2cd1f37f57" GetNicQoSAction.Result res = action.call()
Parent topic: 云主机相关接口
取消云主机网卡限速(DeleteNicQoS)
API请求
URLs
DELETE zstack/v/vm-instances/{uuid}/QoS
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "direction": "example" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 2c879e6be1c64b079aec599845576657" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/9f9a2eb79c9b4fe5881b109033020899/nic-QoS?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机网卡的UUID| |0.6| |direction|String|body(包含在params结构中)|入方向还是出方向(in or out)|inout|0.6| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body| | |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteNicQoSAction action = new DeleteNicQoSAction(); action.uuid = "27b5b55e69284a8ea07871661de562a4"; action.direction = "example"; action.sessionId = "d83ac78201fc4ad38b17261bba4dc17b"; DeleteNicQoSAction.Result res = action.call();
Python SDK
``` DeleteNicQoSAction action = DeleteNicQoSAction() action.uuid = "efb14319aaf14069a1066f2b07a0e328" action.direction = "example" action.sessionId = "a0a6598343404cc38356abfc58877bd8" DeleteNicQoSAction.Result res = action.call()
```
Parent topic: 云主机相关接口
获取相互依赖的镜像和L3网络(GetInterdependentL3NetworksImages)
ZStack中一个三层网络属于一个区域,而镜像所在的镜像服务器可以加载到一个或多个区域。镜像服务器本身跟集群也存在依赖关系,例如Ceph的镜像服务器只能跟Ceph的主存储一起工作。由于这种依赖关系的存在,创建云主机的时候指定的三层网络和镜像可能并不能一起工作。用户可以通过该API获得镜像或三层网络的相互依赖。
当指定了l3NetworkUuids参数时,返回的是可以跟这些三层网络一起工作的镜像清单。
当指定了imageUuid参数时,返回的是可以跟该镜像一起工作的三层网络清单。
API请求
URLs
GET zstack/v1/images-l3networks/dependencies
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "zoneUuid": "55852cdc71ef4774a9dc1eaf85a29c42", "imageUuid": "012be26a00ac4e9583afb5ef9d8dc322" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth ecd5117a63cf444cb71bba734e7458c4" \ -X GET http://localhost:8080/zstack/v1/images-l3networks/dependencies?\ zoneUuid=55466c2e90ae46d88df91c4f72c3e304&imageUuid=40b1783bc2614500bf0926499bdc9b4a
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |zoneUuid|String|query|区域UUID。必须指定,以确定三层网络和镜像依赖关系。| |0.6| |l3NetworkUuids (可选)|List|query|三层网络UUID列表| |0.6| |imageUuid (可选)|String|query|镜像UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "inventories": [ { "uuid": "e177bad0286f4ee38ac29f0ad0e772e6", "name": "private L3", "type": "L3BasicNetwork", "zoneUuid": "0f8c102ff69a43b0afa89c2833ed42bc", "l2NetworkUuid": "c110e7bdffce47578351477ec0728685", "state": "Enabled", "createDate": "May 11, 2017 1:22:45 PM", "lastOpDate": "May 11, 2017 1:22:45 PM", "ipRanges": [ { "uuid": "703becbb056f426b8fe5997648fd7607", "l3NetworkUuid": "e177bad0286f4ee38ac29f0ad0e772e6", "name": "ip range", "startIp": "192.168.0.10", "endIp": "192.168.0.100", "netmask": "255.255.255.0", "gateway": "192.168.0.1", "createDate": "May 11, 2017 1:22:45 PM", "lastOpDate": "May 11, 2017 1:22:45 PM" } ], "networkServices": [ { "l3NetworkUuid": "e177bad0286f4ee38ac29f0ad0e772e6", "networkServiceProviderUuid": "294f4a419cc44d51b1fcbf7352fe6c0d", "networkServiceType": "DHCP" }, { "l3NetworkUuid": "e177bad0286f4ee38ac29f0ad0e772e6", "networkServiceProviderUuid": "294f4a419cc44d51b1fcbf7352fe6c0d", "networkServiceType": "DNS" }, { "l3NetworkUuid": "e177bad0286f4ee38ac29f0ad0e772e6", "networkServiceProviderUuid": "294f4a419cc44d51b1fcbf7352fe6c0d", "networkServiceType": "SNAT" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |inventories|List|若输入参数是l3NetworkUuids,为镜像清单;若输入参数是imageUuid,为三层网络清单|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetInterdependentL3NetworksImagesAction \ action = new GetInterdependentL3NetworksImagesAction(); action.zoneUuid = "e4f01bb336a04285a27c6107f6dfeb68"; action.imageUuid = "05ec09f400684e4ab552d74053fc002e"; action.sessionId = "833c8307f9c540058f1a3b0c9a369f89"; GetInterdependentL3NetworksImagesAction.Result res = action.call();
Python SDK
GetInterdependentL3NetworksImagesAction \ action = GetInterdependentL3NetworksImagesAction() action.zoneUuid = "9dff772313f64618896ce53c9d8a3594" action.imageUuid = "9e91392ee23f4427bc82e7a9734c4966" action.sessionId = "7713d16ef34c4ebdbe94a1b2261dcbeb" GetInterdependentL3NetworksImagesAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机SSH Key (SetVmSshKey)
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVmSshKey": { "SshKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaaV5YUvz9nx54+pvxI\ e5L5uQFHFQsvpwRdVRfMObIgWgcliB9vl4hMCPHXfaKqJD79jBpwJWpUBPebKF7vgevWqFJeU\ gR/LBHTfOnRrEjVsSzanaGGzfjbrwMHdZ5YJVhDTE376+OuXz1Wu5M1mwcarJpcanmqNgyz8Yh\ Yjc50xKDusDVvtpLKxdC6WvhR0+7gaDJKkukip1Up8doOUeNUe2cObJfMoOgi2lNrtKorGp1O7\ Nv+mdTflboYizgQOCFReiW/1ipPjX06OMZZ3Tsx3ZwBib5ocDpLV9CjONvnDBygWb30wydVoUS\ p1hKIzlWPkfyWHjxCf9pvLcHGUXZ root@10-0-98-199" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmSshKey":{"SshKey":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaaV5YUvz9nx54+pvxIe5L5uQFHFQsvpwRdVRfMObIgWgcliB9vl4hMCPHXfaKqJD79jBpwJWpUBPebKF7vgevWqFJeUgR/LBHTfOnRrEjVsSzanaGGzfjbrwMHdZ5YJVhDTE376+OuXz1Wu5M1mwcarJpcanmqNgyz8YhYjc50xKDusDVvtpLKxdC6WvhR0+7gaDJKkukip1Up8doOUeNUe2cObJfMoOgi2lNrtKorGp1O7Nv+mdTflboYizgQOCFReiW/1ipPjX06OMZZ3Tsx3ZwBib5ocDpLV9CjONvnDBygWb30wydVoUSp1hKIzlWPkfyWHjxCf9pvLcHGUXZ root@10-0-98-199"}}' \ http://localhost:8080/zstack/v1/vm-instances/6489aaa605a633a385c84e08f743234b/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |SshKey|String|body(包含在setVmSshKey结构中)| | |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "e3af39037e9840dea5cd71365d3676a8", "name": "Test-VM", "description": "web server VM", "zoneUuid": "0951585e1adb450f85bc575ea2210423", "clusterUuid": "d09c1ea28fdc432383ea1a8928027f76", "imageUuid": "f7ea291640334f20ba8afbd26533d956", "hostUuid": "f4a532dda2d54c75bb51037d41de7029", "lastHostUuid": "1bd861a18f834efa9fde3f107527f009", "instanceOfferingUuid": "7ff5b02dc3404e8baf2d994a9d0dfa2c", "rootVolumeUuid": "01387ca84e3a43fe93567a56868120d2", "platform": "Linux", "defaultL3NetworkUuid": "6923ac2e31e5409293acf5b8e730eb89", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:23:04 PM", "lastOpDate": "May 11, 2017 1:23:04 PM", "state": "Stopped", "vmNics": [ { "uuid": "d7f94ef35beb4aa8a16fcc3eb36ec82d", "vmInstanceUuid": "e3af39037e9840dea5cd71365d3676a8", "usedIpUuid": "da8533550c9144b1b21c2fd23beac8c7", "l3NetworkUuid": "6923ac2e31e5409293acf5b8e730eb89", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:23:04 PM", "lastOpDate": "May 11, 2017 1:23:04 PM" } ], "allVolumes": [ { "uuid": "01387ca84e3a43fe93567a56868120d2", "name": "Root-Volume-For-VM-e3af39037e9840dea5cd71365d3676a8", "primaryStorageUuid": "f0651a10d7c54bbab53222188c00258b", "vmInstanceUuid": "e3af39037e9840dea5cd71365d3676a8", "diskOfferingUuid": "1dac5cc0e081407b9b551e8b55f60a25", "rootImageUuid": "f7ea291640334f20ba8afbd26533d956", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/\ vol-01387ca84e3a43fe93567a56868120d2/01387ca84e3a43fe93567a56868120d2.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:23:04 PM", "lastOpDate": "May 11, 2017 1:23:04 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
SetVmSshKeyAction action = new SetVmSshKeyAction(); action.uuid = "29950a96104b4bac9ae0cb2f1207a3ca"; action.SshKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaaV5YUvz9nx\ 54+pvxIe5L5uQFHFQsvpwRdVRfMObIgWgcliB9vl4hMCPHXfaKqJD79jBpwJWpUBPebK\ F7vgevWqFJeUgR/LBHTfOnRrEjVsSzanaGGzfjbrwMHdZ5YJVhDTE376+OuXz1Wu5M1m\ wcarJpcanmqNgyz8YhYjc50xKDusDVvtpLKxdC6WvhR0+7gaDJKkukip1Up8doOUeNUe2\ cObJfMoOgi2lNrtKorGp1O7Nv+mdTflboYizgQOCFReiW/1ipPjX06OMZZ3Tsx3ZwBib5\ ocDpLV9CjONvnDBygWb30wydVoUSp1hKIzlWPkfyWHjxCf9pvLcHGUXZ root@10-0-98-199"; action.sessionId = "c461e0a37d104b3da532d027fdde304b"; SetVmSshKeyAction.Result res = action.call();
Python SDK
SetVmSshKeyAction action = SetVmSshKeyAction() action.uuid = "b40f07653f314e668a0674d42b670f90" action.SshKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaaV5YUvz9nx54+p\ vxIe5L5uQFHFQsvpwRdVRfMObIgWgcliB9vl4hMCPHXfaKqJD79jBpwJWpUBPebKF7vgevWq\ FJeUgR/LBHTfOnRrEjVsSzanaGGzfjbrwMHdZ5YJVhDTE376+OuXz1Wu5M1mwcarJpcanmqN\ gyz8YhYjc50xKDusDVvtpLKxdC6WvhR0+7gaDJKkukip1Up8doOUeNUe2cObJfMoOgi2lNrt\ KorGp1O7Nv+mdTflboYizgQOCFReiW/1ipPjX06OMZZ3Tsx3ZwBib5ocDpLV9CjONvnDBygWb\ 30wydVoUSp1hKIzlWPkfyWHjxCf9pvLcHGUXZ root@10-0-98-199" action.sessionId = "1011d275b52341c6826095a10aa78805" SetVmSshKeyAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机SSH Key (GetVmSshKey)
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/ssh-keys
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 9f358fd3fb0c451aa999d9fd5f21d675" \ -X GET http://localhost:8080/zstack/v1/vm-instances/905b14166587498982db9aa14aee50c1/ssh-keys
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "sshKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtgdrSt2i/4ayXoiR6qNd7dykOOcz205NVSUgw41GOZW3PdXa9WWMF1AP\ Htj8L2tYm3lKgIDSy1aQtpIEenu6L03BeqfPwepf2L89aZ/W4UPRpce9/bO4mSSJ6kvbZ7hFv+4KLUJCB9O7UrcFu7J/QwrkHNVNX1NsVUpq\ ebp3Ny8bxj0Wbr9ecqPKTclzygARRGz71iDQaEhLrQqy/Q8vr+/G1/uyAYfTnifCuuMTfh5DEsuKD1AEHMBVZEbJ4zupR4gywXnGRxHmEwE4\ 64scACxeFWVx2flIXkTK8f3W0KBLCJ8VtTd8KxvKQBu2jJ70avmXNOzb5IaBDS root@172-20-12-46" }
|名字|类型|描述|起始版本| |--|--|--|----| |sshKey|String|云主机SSH Key|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVmSshKeyAction action = new GetVmSshKeyAction(); action.uuid = "71e1defb50aa42128605fc702cc00137"; action.sessionId = "2f3fe0048fc6485f9123541a1244411f"; GetVmSshKeyAction.Result res = action.call();
Python SDK
GetVmSshKeyAction action = GetVmSshKeyAction() action.uuid = "c66da31c27004804b59f672002d4371c" action.sessionId = "2b883a9c99e942f295beab6761ff8657" GetVmSshKeyAction.Result res = action.call()
Parent topic: 云主机相关接口
删除云主机SSH Key(DeleteVmSshKey)
API请求
URLs
DELETE zstack/v1/vm-instances/{uuid}/ssh-keys
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: 2698b6ec6f4241e696c75416e8e31b48" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/add84c70ff0f4c98b897d6a3d7ba475c/ssh-keys
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid (可选)|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "1ea667c144cf431e9b1a9ca503947735", "name": "Test-VM", "description": "web server VM", "zoneUuid": "8de2e6726a4d412d9a8a445c5a85cfe4", "clusterUuid": "51900cf42e62496e90f61a9553f2dd44", "imageUuid": "309fa4ff1c1244dab6a350260e7c5838", "hostUuid": "64eeb6a53f534903b645f881e143140c", "lastHostUuid": "f11e3f8134a9473e8754580ab24e425e", "instanceOfferingUuid": "701ec48f6e084db4801ef0029cd8cee5", "rootVolumeUuid": "627b25aebb5143a9a98bb3cab47341cf", "platform": "Linux", "defaultL3NetworkUuid": "056f3dc6e1ec4a71b5bff6f0db3cc749", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "Apr 24, 2017 7:11:29 PM", "lastOpDate": "Apr 24, 2017 7:11:29 PM", "state": "Stopped", "vmNics": [ { "uuid": "33f03792d00c471e94b4cc42457a7e2a", "vmInstanceUuid": "1ea667c144cf431e9b1a9ca503947735", "usedIpUuid": "0dc93b05d54643b699a02427688a0871", "l3NetworkUuid": "056f3dc6e1ec4a71b5bff6f0db3cc749", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "Apr 24, 2017 7:11:29 PM", "lastOpDate": "Apr 24, 2017 7:11:29 PM" } ], "allVolumes": [ { "uuid": "627b25aebb5143a9a98bb3cab47341cf", "name": "Root-Volume-For-VM-1ea667c144cf431e9b1a9ca503947735", "primaryStorageUuid": "1337db63a9c1489381a30cfc3bbb9965", "vmInstanceUuid": "1ea667c144cf431e9b1a9ca503947735", "diskOfferingUuid": "02e831a9c4634cf898e65ef074fdacf0", "rootImageUuid": "309fa4ff1c1244dab6a350260e7c5838", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-627b25aebb5143a9a98bb3cab47341cf/627b25aebb5143a9a98bb3cab47341cf.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Apr 24, 2017 7:11:29 PM", "lastOpDate": "Apr 24, 2017 7:11:29 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
DeleteVmSshKeyAction action = new DeleteVmSshKeyAction(); action.uuid = "59ab1ff13ea947769b7522cd95311837"; action.sessionId = "ad1c38b4ce1343a28a06d3eb08ae1123"; DeleteVmSshKeyAction.Result res = action.call();
Python SDK
DeleteVmSshKeyAction action = DeleteVmSshKeyAction() action.uuid = "22b709aa71ec47a2a0e0f758b55e844e" action.sessionId = "f70cfa4d6dc04f2aa567621501247954" DeleteVmSshKeyAction.Result res = action.call()
Parent topic: 云主机相关接口
变更云主机密码(ChangeVmPassword)
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "changeVmPassword": { "password": "password", "account": "root" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"changeVmPassword":{"password":"password","account":"root"}}' \ http://localhost:8080/zstack/v1/vm-instances/6401e6a584b43fcfaebe401fd07f6f92/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |password|String|body(包含在changeVmPassword结构中)|密码| |0.6| |account|String|body(包含在changeVmPassword结构中)|账户| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
ChangeVmPasswordAction action = new ChangeVmPasswordAction(); action.uuid = "68bbdbf738884c3486f0fc0faf42c42c"; action.password = "password"; action.account = "root"; action.sessionId = "815834f2143b45c0a16fab615616795a"; ChangeVmPasswordAction.Result res = action.call();
Python SDK
ChangeVmPasswordAction action = ChangeVmPasswordAction() action.uuid = "39f2732b2c214fe29fb2fa82f748a4f6" action.password = "password" action.account = "root" action.sessionId = "fee2d467d9af4dc5b541a56a736cb457" ChangeVmPasswordAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机控制台密码(SetVmConsolePassword)
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVmConsolePassword": { "consolePassword": "password" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmConsolePassword":{"consolePassword":"password"}}' \ http://localhost:8080/zstack/v1/vm-instances/18a8034dbb483acbad9400916fe1e56c/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |consolePassword|String|body(包含在setVmConsolePassword结构中)|控制台密码,明文字符串| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "224ed4d494384a0ab2aa19002fa60640", "name": "Test-VM", "description": "web server VM", "zoneUuid": "e1137e3436ac4cf8bff171da725c5d87", "clusterUuid": "b1e81a8cebe142f5811c64b089429264", "imageUuid": "63ac41010a5e43adab3498900408cabf", "hostUuid": "7c2f9506f404419e88c9e27d6bb4bb7f", "lastHostUuid": "84d859bfc1974a6d99478f2a01627740", "instanceOfferingUuid": "70807aeae1574192a0c9eed642509505", "rootVolumeUuid": "aaa0691c4e2b4f7088e03e18ca1f5ff8", "platform": "Linux", "defaultL3NetworkUuid": "81af011f48e34903ad77d0f767dab633", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:23:02 PM", "lastOpDate": "May 11, 2017 1:23:02 PM", "state": "Running", "vmNics": [ { "uuid": "ebc7307113e64d5684102c5b057b3c65", "vmInstanceUuid": "224ed4d494384a0ab2aa19002fa60640", "usedIpUuid": "c9cf2dfe7a9a4eb69b78bc601b658c40", "l3NetworkUuid": "81af011f48e34903ad77d0f767dab633", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:23:02 PM", "lastOpDate": "May 11, 2017 1:23:02 PM" } ], "allVolumes": [ { "uuid": "aaa0691c4e2b4f7088e03e18ca1f5ff8", "name": "Root-Volume-For-VM-224ed4d494384a0ab2aa19002fa60640", "primaryStorageUuid": "aba0457d4c7e410db8a61ec27dbbfe88", "vmInstanceUuid": "224ed4d494384a0ab2aa19002fa60640", "diskOfferingUuid": "07e549e2340344178df39c7014fb404f", "rootImageUuid": "63ac41010a5e43adab3498900408cabf", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-aaa0691c4e2b4f7088e03e18ca1f5ff8/aaa0691c4e2b4f7088e03e18ca1f5ff8.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:23:02 PM", "lastOpDate": "May 11, 2017 1:23:02 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
SetVmConsolePasswordAction action = new SetVmConsolePasswordAction(); action.uuid = "6e935fb07f7042e4b446e9dfe4682fb8"; action.consolePassword = "password"; action.sessionId = "89efad1766a24f8aae2b9acf36144714"; SetVmConsolePasswordAction.Result res = action.call();
Python SDK
SetVmConsolePasswordAction action = SetVmConsolePasswordAction() action.uuid = "8180d69a46474d83be4d2f2018f20b9b" action.consolePassword = "password" action.sessionId = "d59425db0bf148029cb619264a09087b" SetVmConsolePasswordAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机控制台密码(GetVmConsolePassword)
获取一个云主机的控制台密码。
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/console-passwords
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 64bdb6ac8c3044d589ab6a0e96745fc2" \ -X GET http://localhost:8080/zstack/v1/vm-instances/3bc9f63f0de6492991c59bef96b27565/console-passwords
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "consolePassword": "password" }
|名字|类型|描述|起始版本| |--|--|--|----| |password|String|控制台密码|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVmConsolePasswordAction action = new GetVmConsolePasswordAction(); action.uuid = "b06703c5616e4c29ba4d080ea6b3d760"; action.sessionId = "4cf31da078ce44348e0d77af4269c756"; GetVmConsolePasswordAction.Result res = action.call();
Python SDK
GetVmConsolePasswordAction action = GetVmConsolePasswordAction() action.uuid = "73b0881a95c0456ca9d20f2896ea6b76" action.sessionId = "d568904f39914ffbaf6245aa3c949b37" GetVmConsolePasswordAction.Result res = action.call()
Parent topic: 云主机相关接口
删除云主机控制台密码(DeleteVmConsolePassword)
删除一个云主机的控制台密码。
API请求
URLs
DELETE zstack/v1/vm-instances/{uuid}/console-password
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 91e9a99b7b23405e9b841f5b20ab5645" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/971c0188520145f682c32079f83108ff/console-password?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "69217bbc6ec440ea9c4d0f30403ddab9", "name": "Test-VM", "description": "web server VM", "zoneUuid": "49b47c3d1358407581450d1bff8a619b", "clusterUuid": "7c500334d3af42b683103b3ab09b9527", "imageUuid": "d515053df20b466cb98104ef939f48bb", "hostUuid": "e3c12c2c157946a9adb28870eb2e1884", "lastHostUuid": "55be742a1c4442fc8cd2401baebde106", "instanceOfferingUuid": "f561cb2a365f484f9a93f87aaafa8d03", "rootVolumeUuid": "4e07afc3a7c3471797f2cda5b0655d74", "platform": "Linux", "defaultL3NetworkUuid": "6b7c934ecaec4ffabfc7a111d1c4a262", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:35 PM", "lastOpDate": "May 11, 2017 1:22:35 PM", "state": "Running", "vmNics": [ { "uuid": "e4cf2283c77d4183938f3d535523df0e", "vmInstanceUuid": "69217bbc6ec440ea9c4d0f30403ddab9", "usedIpUuid": "4ab173662e184155bdcc30d55ba83e99", "l3NetworkUuid": "6b7c934ecaec4ffabfc7a111d1c4a262", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:35 PM", "lastOpDate": "May 11, 2017 1:22:35 PM" } ], "allVolumes": [ { "uuid": "4e07afc3a7c3471797f2cda5b0655d74", "name": "Root-Volume-For-VM-69217bbc6ec440ea9c4d0f30403ddab9", "primaryStorageUuid": "9915c3b248d1407892e214eb67217caa", "vmInstanceUuid": "69217bbc6ec440ea9c4d0f30403ddab9", "diskOfferingUuid": "a819905e63774a7981bafc947b7fbbcb", "rootImageUuid": "d515053df20b466cb98104ef939f48bb", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/\ vol-4e07afc3a7c3471797f2cda5b0655d74/4e07afc3a7c3471797f2cda5b0655d74.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:35 PM", "lastOpDate": "May 11, 2017 1:22:35 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
``` DeleteVmConsolePasswordAction action = new DeleteVmConsolePasswordAction(); action.uuid = "ac34ea877bc24c0bb36e8d52d1046479"; action.sessionId = "dbd8f0f101bf4318bd44814c7f3b03da"; DeleteVmConsolePasswordAction.Result res = action.call();
```
Python SDK
DeleteVmConsolePasswordAction action = DeleteVmConsolePasswordAction() action.uuid = "9cefd9cf5c2a409f91ff902931eade7b" action.sessionId = "9514a4d5eacd4c4f9a5dccdcc7bd99e3" DeleteVmConsolePasswordAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机控制台地址和访问协议(GetVmConsoleAddress)
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/console-addresses
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 5c66c9a616334283b055d150680fff98" \ -X GET http://localhost:8080/zstack/v1/vm-instances/bf2211ae8eaf408b817d3a05c19e2226/console-addresses
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "hostIp": "192.168.10.100", "port": 5900.0, "protocol": "vnc" }
|名字|类型|描述|起始版本| |--|--|--|----| |hostIp|String|云主机运行物理机IP|0.6| |port|int|云主机控制台端口|0.6| |protocol|String|云主机控制台协议,vnc或spice|0.6| |success|boolean|操作是否成功|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。详情参考error|0.6|
#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
GetVmConsoleAddressAction action = new GetVmConsoleAddressAction(); action.uuid = "d6bb8b652c1445969b5c4227385956d3"; action.sessionId = "1c0ec00749234a96978591d641e0c64d"; GetVmConsoleAddressAction.Result res = action.call();
Python SDK
GetVmConsoleAddressAction action = GetVmConsoleAddressAction() action.uuid = "f6b7fe2da3ae4c929ad1c8ed14f37c8e" action.sessionId = "5f127b3df90245ed93ef9da531442fdc" GetVmConsoleAddressAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机Hostname(SetVmHostname)
设置云主机hostname。
Note: ZStack通过DHCP服务器配置云主机hostname,如果云主机本身采用静态hostname方式,该API配置的hostname不生效。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVmHostname": { "hostname": "vm1.zstack.org" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmHostname":{"hostname":"vm1.zstack.org"}}' \ http://localhost:8080/zstack/v1/vm-instances/0d71345add0230f2a893e7789a831b81/actions
参数列表
|名字|类型|位置|描述|可选值|起始版| |--|--|--|--|---|---| |uuid|String|url|云主机UUID| |0.6| |hostname|String|body(包含在setVmHostname结构中)|hostname,必须符合RFC 1123标准| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetVmHostnameAction action = new SetVmHostnameAction(); action.uuid = "ce11eb85ff0f417c9f1255f43e0bb124"; action.hostname = "vm1.zstack.org"; action.sessionId = "fc2d7aab6f0545029fa52fa068dabfbb"; SetVmHostnameAction.Result res = action.call();
Python SDK
SetVmHostnameAction action = SetVmHostnameAction() action.uuid = "7f11dce627ce4a0db39f20ce2e1afc57" action.hostname = "vm1.zstack.org" action.sessionId = "cb33487362ca41599fc2b43a119d8bc6" SetVmHostnameAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机Hostname(GetVmHostname)
获取云主机指定的Hostname。该Hostname是用户之前用SetVmHostname指定的。
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/hostnames
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: 0e3cbe22c03a43bc9b7b3ae76c57a0e7" \ -X GET http://localhost:8080/zstack/v1/vm-instances/c5c6665ccbe2444e9cfa393366cdb5d4/hostnames
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "hostname": "vm1.zstack.orgl" }
|名字|类型|描述|起始版| |--|--|--|---| |hostname|String|云主机hostname|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVmHostnameAction action = new GetVmHostnameAction(); action.uuid = "82c0f5918de14f65abe7ba5d37c28502"; action.sessionId = "24f9301f25784707a477483c5702c034"; GetVmHostnameAction.Result res = action.call();
Python SDK
GetVmHostnameAction action = GetVmHostnameAction() action.uuid = "5070e337b731448ca0698f83c7fc4c26" action.sessionId = "f13e0ed993134a8ea35a3d382a971b14" GetVmHostnameAction.Result res = action.call()
Parent topic: 云主机相关接口
删除云主机Hostname(DeleteVmHostname)
删除云主机的Hostname。
Note: 该删除操作仅仅是删除配置在数据库中以及DHCP服务器上的云主机hostname,无法改变云主机内部手动配置的hostname。
API请求
URLs
DELETE zstack/v1/vm-instances/{uuid}/hostnames
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth efe37b8868b54c6c93b9f83a04ffe27c" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/\ 55fefc89f98b49f99e96bb01765d42ed/hostnames?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteVmHostnameAction action = new DeleteVmHostnameAction(); action.uuid = "ab14af23812445e891695e0c9ef7b635"; action.deleteMode = "Permissive"; action.sessionId = "25d8bc148fcb4061b0aa340d1e4c68a8"; DeleteVmHostnameAction.Result res = action.call();
Python SDK
DeleteVmHostnameAction action = DeleteVmHostnameAction() action.uuid = "0f4ad3768b1e4e8bb1ec33646a3067de" action.deleteMode = "Permissive" action.sessionId = "fb18f70b6fc24b5f955817aaabbae4cc" DeleteVmHostnameAction.Result res = action.call()
Parent topic: 云主机相关接口
创建启动云主机的定时任务(CreateStartVmInstanceScheduler)
API请求
URLs
POST zstack/v1/vm-instances/{vmUuid}/schedulers/starting
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "schedulerName": "create-vm-scheduler", "schedulerDescription": "for test create vm scheduler", "type": "simple", "interval": 5.0, "repeatCount": 10.0, "startTime": 0.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: cf1274ab34e448cdb7f8aabd8461683e" \ -X POST -d '{"params":{"schedulerName":"create-vm-scheduler","schedulerDescription":\ "for test create vm scheduler","type":"simple","interval":5.0,"repeatCount":10.0,"startTime":0.0}}' \ http://localhost:8080/zstack/v1/vm-instances/0a8a39e89a104282b0ff78446515d7f1/schedulers/starting
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmUuid|String|url|云主机uuid| |0.6| |clusterUuid (可选)|String|body(包含在******params结构中)|集群UUID| |0.6| |hostUuid (可选)|String|body(包含在params结构中)|物理机UUID| |0.6| |schedulerName|String|body(包含在params结构中)|定时任务名称| |1.6| |schedulerDescription (可选)|String|body(包含在params结构中)|定时任务描述| |1.6| |type|String|body(包含在params结构中)|定时任务类型,simple或者cron|simplecron|1.6| |interval (可选)|Integer|body(包含在params结构中)|定时任务间隔,单位秒| |1.6| |repeatCount (可选)|Integer|body(包含在params结构中)|定时任务重复次数,仅针对simple类型的定时任务生效| |1.6| |startTime (可选)|Long|body(包含在params结构中)|定时任务启动时间,必须遵循unix timestamp格式,0为从立刻开始| |1.6| |cron (可选)|String|body(包含在params结构中)|cron表达式,需遵循Java Quartz组件cron格式标准| |1.6| |resourceUuid (可选)|String|body(包含在params**结构中)|用户可指定创建Scheduler所使用的uuid| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "3e27a74894fb47b5a3c86c2b44409ccb", "targetResourceUuid": "d596e0adcb2b49a8a9efd132f0e43a73", "schedulerName": "Test", "schedulerType": "simple", "repeatCount": 10.0, "startTime": "Apr 24, 2017 7:11:02 PM", "createDate": "Apr 24, 2017 7:11:02 PM", "lastOpDate": "Apr 24, 2017 7:11:02 PM", "jobClassName": "CreateVolumeSnapshotJob", "state": "Enabled" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|1.6| |inventory|SchedulerInventory|详情参考inventory|1.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |targetResourceUuid|String| |0.6| |schedulerName|String| |0.6| |schedulerJob|String| |0.6| |schedulerType|String| |0.6| |schedulerInterval|Integer| |0.6| |repeatCount|Integer| |0.6| |cronScheduler|String| |0.6| |startTime|Timestamp| |0.6| |stopTime|Timestamp| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6|
SDK示例
Java SDK
CreateStartVmInstanceSchedulerAction action = new CreateStartVmInstanceSchedulerAction(); action.vmUuid = "7d86597d42eb4e31b2497a06361f710b"; action.schedulerName = "create-vm-scheduler"; action.schedulerDescription = "for test create vm scheduler"; action.type = "simple"; action.interval = 5.0; action.repeatCount = 10.0; action.startTime = 0.0; action.sessionId = "a5e890d5bd78487f979861dee02aaafe"; CreateStartVmInstanceSchedulerAction.Result res = action.call();
Python SDK
CreateStartVmInstanceSchedulerAction action = CreateStartVmInstanceSchedulerAction() action.vmUuid = "26799d709f7e4794b33fb07cfd269373" action.schedulerName = "create-vm-scheduler" action.schedulerDescription = "for test create vm scheduler" action.type = "simple" action.interval = 5.0 action.repeatCount = 10.0 action.startTime = 0.0 action.sessionId = "d5fcddc65c454f6f85625f954d9507e5" CreateStartVmInstanceSchedulerAction.Result res = action.call()
Parent topic: 云主机相关接口
创建停止云主机的定时任务(CreateStopVmInstanceScheduler)
API请求
URLs
POST zstack/v1/vm-instances/{vmUuid}/schedulers/stopping
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "schedulerName": "vm-scheduler", "schedulerDescription": "for test stop vm scheduler", "type": "simple", "interval": 5.0, "repeatCount": 10.0, "startTime": 0.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth a19cb92d7c264d1d939b24b3d1cb07dc" \ -X POST http://localhost:8080/zstack/v1/vm-instances/09b1ee5bddea44a5bb56c471deae95d5/schedulers/stopping?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmUuid|String|url|云主机uuid| |0.6| |schedulerName|String|body(包含在params结构中)|定时任务名称| |1.6| |schedulerDescription (可选)|String|body(包含在params结构中)|定时任务描述| |1.6| |type|String|body(包含在params结构中)|定时任务类型,simple或者cron|simplecron|1.6| |interval (可选)|Integer|body(包含在params结构中)|定时任务间隔,单位秒| |1.6| |repeatCount (可选)|Integer|body(包含在params结构中)|定时任务重复次数,仅针对simple类型的定时任务生效| |1.6| |startTime (可选)|Long|body(包含在params结构中)|定时任务启动时间,必须遵循unix timestamp格式,0为从立刻开始| |1.6| |cron (可选)|String|body(包含在params结构中)|cron表达式,需遵循Java Quartz组件cron格式标准| |1.6| |resourceUuid (可选)|String|body(包含在params结构中)|用户可指定创建Scheduler所使用的uuid| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "1c1b66d878494610aab6833dde9c6c04", "targetResourceUuid": "f1dd6bd2ae484bd5b3375c7579756e48", "schedulerName": "Test", "schedulerType": "simple", "repeatCount": 10.0, "startTime": "May 11, 2017 1:22:53 PM", "createDate": "May 11, 2017 1:22:53 PM", "lastOpDate": "May 11, 2017 1:22:53 PM", "jobClassName": "StopVmInstanceJob", "state": "Enabled" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|1.6| |inventory|SchedulerInventory|详情参考inventory|1.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |targetResourceUuid|String| |0.6| |schedulerName|String| |0.6| |schedulerJob|String| |0.6| |schedulerType|String| |0.6| |schedulerInterval|Integer| |0.6| |repeatCount|Integer| |0.6| |cronScheduler|String| |0.6| |startTime|Timestamp| |0.6| |stopTime|Timestamp| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6|
SDK示例
Java SDK
CreateStopVmInstanceSchedulerAction action = new CreateStopVmInstanceSchedulerAction(); action.vmUuid = "12cd4882e5784a81967a314be5f10a55"; action.schedulerName = "vm-scheduler"; action.schedulerDescription = "for test stop vm scheduler"; action.type = "simple"; action.interval = 5.0; action.repeatCount = 10.0; action.startTime = 0.0; action.sessionId = "256f557f46ff499aad22d7b1776a7567"; CreateStopVmInstanceSchedulerAction.Result res = action.call();
Python SDK
CreateStopVmInstanceSchedulerAction action = CreateStopVmInstanceSchedulerAction() action.vmUuid = "3043caa47c6a4a0aa498f903ee5a3cbf" action.schedulerName = "vm-scheduler" action.schedulerDescription = "for test stop vm scheduler" action.type = "simple" action.interval = 5.0 action.repeatCount = 10.0 action.startTime = 0.0 action.sessionId = "3bdb1579024b433895943d4ff6278d15" CreateStopVmInstanceSchedulerAction.Result res = action.call()
Parent topic: 云主机相关接口
创建重启云主机的定时任务(CreateRebootVmInstanceScheduler)
API请求
URLs
POST zstack/v1/vm-instances/{vmUuid}/schedulers/rebooting
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "schedulerName": "vm-scheduler", "schedulerDescription": "for test restart vm scheduler", "type": "simple", "interval": 5.0, "repeatCount": 10.0, "startTime": 0.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth fa354b2ef2b34f109f268d264eee4d87" \ -X POST http://localhost:8080/zstack/v1/vm-instances/08eaedbeb14841c5bb8564663319fed9/\ schedulers/rebooting?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmUuid|String|url|云主机uuid| |0.6| |schedulerName|String|body(包含在params结构中)|定时任务名称| |1.6| |schedulerDescription (可选)|String|body(包含在params结构中)|定时任务描述| |1.6| |type|String|body(包含在params结构中)|定时任务类型,simple或者cron|simplecron|1.6| |interval (可选)|Integer|body(包含在params结构中)|定时任务间隔,单位秒| |1.6| |repeatCount (可选)|Integer|body(包含在params结构中)|定时任务重复次数,仅针对simple类型的定时任务生效| |1.6| |startTime (可选)|Long|body(包含在params结构中)|定时任务启动时间,必须遵循unix timestamp格式,0为从立刻开始| |1.6| |cron (可选)|String|body(包含在params结构中)|cron表达式,需遵循Java Quartz组件cron格式标准| |1.6| |resourceUuid (可选)|String|body(包含在params结构中)|用户可指定创建Scheduler所使用的uuid| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "2664ccec6e584e529ab6671d88f87763", "targetResourceUuid": "308a32f93a7842ce94bdab3220f75aeb", "schedulerName": "Test", "schedulerType": "simple", "repeatCount": 10.0, "startTime": "May 11, 2017 1:22:27 PM", "createDate": "May 11, 2017 1:22:27 PM", "lastOpDate": "May 11, 2017 1:22:27 PM", "jobClassName": "CreateVolumeSnapshotJob", "state": "Enabled" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|1.6| |inventory|SchedulerInventory|详情参考inventory|1.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |targetResourceUuid|String| |0.6| |schedulerName|String| |0.6| |schedulerJob|String| |0.6| |schedulerType|String| |0.6| |schedulerInterval|Integer| |0.6| |repeatCount|Integer| |0.6| |cronScheduler|String| |0.6| |startTime|Timestamp| |0.6| |stopTime|Timestamp| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6|
SDK示例
Java SDK
CreateRebootVmInstanceSchedulerAction action = new CreateRebootVmInstanceSchedulerAction(); action.vmUuid = "65f8b54efe254b8e8e5b427bfdadd1e6"; action.schedulerName = "vm-scheduler"; action.schedulerDescription = "for test restart vm scheduler"; action.type = "simple"; action.interval = 5.0; action.repeatCount = 10.0; action.startTime = 0.0; action.sessionId = "3cedf9bd8bbf424f860057259adfcdcf"; CreateRebootVmInstanceSchedulerAction.Result res = action.call();
Python SDK
CreateRebootVmInstanceSchedulerAction action = CreateRebootVmInstanceSchedulerAction() action.vmUuid = "1b0f699afaba45e1865f00bbaf026c6a" action.schedulerName = "vm-scheduler" action.schedulerDescription = "for test restart vm scheduler" action.type = "simple" action.interval = 5.0 action.repeatCount = 10.0 action.startTime = 0.0 action.sessionId = "22758ee34b2b4822a3253a8a56cee6cf" CreateRebootVmInstanceSchedulerAction.Result res = action.call()
Parent topic: 云主机相关接口
获得云主机启动设备列表(GetVmBootOrder)
获得一个云主机的启动设备列表。
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/boot-orders
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: 458995c072644d28b32b26f69e512c2c" \ -X GET http://localhost:8080/zstack/v1/vm-instances/426cff83f17d4a5aa7c752484d730f20/boot-orders
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "order": [ "HardDisk", "CdRom" ] }
|名字|类型|描述|起始版本| |--|--|--|----| |orders|List|启动设备列表|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVmBootOrderAction action = new GetVmBootOrderAction(); action.uuid = "914ab429715b40d59efa76c1ccfe64d8"; action.sessionId = "0472be4a6e2c4e7c9d7bcf3da2938313"; GetVmBootOrderAction.Result res = action.call();
Python SDK
GetVmBootOrderAction action = GetVmBootOrderAction() action.uuid = "cba88e6e561049c8b7beaeccf4d46279" action.sessionId = "bd37fd5e33e847d4bef4bb536d6410ea" GetVmBootOrderAction.Result res = action.call()
Parent topic: 云主机相关接口
指定云主机启动设备(SetVmBootOrder)
指定一个云主机的启动设备。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVmBootOrder": { "bootOrder": [ "CdRom", "HardDisk" ] }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmBootOrder":{"bootOrder":["CdRom","HardDisk"]}}' \ http://localhost:8080/zstack/v1/vm-instances/f757785b3980305095c89eb2b4e1b785/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |bootOrder (可选)|List|body(包含在setVmBootOrder结构中)|启动设备。CdRom:光驱,HardDisk:云盘。若该字段不指定,则表示使用系统默认启动设备顺序(HardDisk, CdRom)| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "1cc82b80247242d79f4aa3eea1d69676", "name": "Test-VM", "description": "web server VM", "zoneUuid": "265a55cc7add47abb9dbea0dde70a738", "clusterUuid": "61865e0aebed4a89b33b7186e1bfb564", "imageUuid": "670d243f8f854ec99907e6f8343eac7e", "hostUuid": "87678374b35e474dbb13d3bbf33bc846", "lastHostUuid": "eb96b43e9c9e4fceadf6e4cec6f28bcc", "instanceOfferingUuid": "d9a077d6676b4b11a300085b1fc2e771", "rootVolumeUuid": "b0112bc4520a4d05b7bb8aba5f4b9903", "platform": "Linux", "defaultL3NetworkUuid": "8b874a098df64aa89fef08c0fe955777", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:46 PM", "lastOpDate": "May 11, 2017 1:22:46 PM", "state": "Stopped", "vmNics": [ { "uuid": "62d187d4430345b0aa051d410e0a8b8e", "vmInstanceUuid": "1cc82b80247242d79f4aa3eea1d69676", "usedIpUuid": "b413e0e2395b45a994172d1f8a2d6508", "l3NetworkUuid": "8b874a098df64aa89fef08c0fe955777", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:46 PM", "lastOpDate": "May 11, 2017 1:22:46 PM" } ], "allVolumes": [ { "uuid": "b0112bc4520a4d05b7bb8aba5f4b9903", "name": "Root-Volume-For-VM-1cc82b80247242d79f4aa3eea1d69676", "primaryStorageUuid": "c0243b5f795e4d2a897a564bcff55d06", "vmInstanceUuid": "1cc82b80247242d79f4aa3eea1d69676", "diskOfferingUuid": "cbf17026efec4492a978a10b8adcc4c5", "rootImageUuid": "670d243f8f854ec99907e6f8343eac7e", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-b0112bc4520a4d05b7bb8aba5f4b9903/b0112bc4520a4d05b7bb8aba5f4b9903.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:46 PM", "lastOpDate": "May 11, 2017 1:22:46 PM" } ] } }
|名字|类型|描述|起始版| |--|--|--|---| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
SetVmBootOrderAction action = new SetVmBootOrderAction(); action.uuid = "a83e7ff6d8d84f6fa48a089b2a918258"; action.bootOrder = asList("CdRom","HardDisk"); action.sessionId = "93251a3a33994bd9b3d54d4d9abcf5d7"; SetVmBootOrderAction.Result res = action.call();
Python SDK
SetVmBootOrderAction action = SetVmBootOrderAction() action.uuid = "dccc7be070934387b50fe96f30439231" action.bootOrder = [CdRom, HardDisk] action.sessionId = "2da90129d60741a3bc69228448ed9795" SetVmBootOrderAction.Result res = action.call()
Parent topic: 云主机相关接口
获取目的地列表(GetCandidateZonesClustersHostsForCreatingVm)
获取可以创建指定云主机参数的目的区域、集群、物理机。用户可以使用该API,通过指定云主机参数获得可以创建满足参数云主机的目的地。
API请求
URLs
GET zstack/v1/vm-instances/candidate-destinations
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "instanceOfferingUuid": "74dfdb443272486cad0e1136d982d0eb", "imageUuid": "446ca20ccd5e420fa383df8fab965caa", "l3NetworkUuids": [ "654722ff8884499a8723010ef41bbb9b" ], "dataDiskOfferingUuids": [ "3ab2044725594ed7ba7466b710bf99b5", "a1a0cbbc8d704318841f707aa3c7c219" ], "clusterUuid": "f614e3dad723466c9ddd9190ef69fe62" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth bcbb6fa236704f2ca1742db90a41c6b9" \ -X GET http://localhost:8080/zstack/v1/vm-instances/candidate-destinations?\ instanceOfferingUuid=ef41e6e0659140deae7beb9e48d09b9d&imageUuid=93ca46ed00ac4fa0a5e6dc497a8b3e4b\ &l3NetworkUuids=9dc450a21d5745cca0f586c7f1fc955f\ &dataDiskOfferingUuids=66bbcf29e2ca4564a158113459d23208\ &dataDiskOfferingUuids=fc7fed0cba394e2cb660b10ded193ac1&clusterUuid=db6cc0784cf64f4a8cf47d23d8c2802a
参数列表
|名字|类型|位置|描述|可选值|起始版| |--|--|--|--|---|---| |instanceOfferingUuid|String|query|计算规格UUID| |0.6| |imageUuid|String|query|镜像UUID| |0.6| |l3NetworkUuids|List|query|三层网络列表| |0.6| |rootDiskOfferingUuid (可选)|String|query|根云盘规格。仅在imageUuid指定的镜像是ISO时需要指定| |0.6| |dataDiskOfferingUuids (可选)|List|query|云盘规格列表| |0.6| |zoneUuid (可选)|String|query|区域UUID| |0.6| |clusterUuid (可选)|String|query|集群UUID| |0.6| |defaultL3NetworkUuid (可选)|String|query|默认三层网络UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "zones": [ { "uuid": "b145bc2ad8f14810a6eec0f28508ca14", "name": "zone" } ], "clusters": [ { "name": "cluster1", "uuid": "49adbf0f48a14b899b0e6f7928556313", "hypervisorType": "KVM", "createDate": "May 11, 2017 1:23:06 PM", "lastOpDate": "May 11, 2017 1:23:06 PM", "zoneUuid": "b68fec24ba0f492c94c2e046072c16f0" } ], "hosts": [ { "zoneUuid": "b145bc2ad8f14810a6eec0f28508ca14", "name": "example", "uuid": "e1a5cb10bcbc48b4ab6dd4e648ef5960", "clusterUuid": "d5b32ea0ae1444d3b8b5a6b9d759af54", "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, "createDate": "May 11, 2017 1:23:06 PM", "lastOpDate": "May 11, 2017 1:23:06 PM" } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |success|boolean|操作是否成功|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |zones|List|详情参考zones|0.6| |clusters|List|详情参考clusters|0.6| |hosts|List|详情参考hosts|0.6|
#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|
#zones
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |state|String| |0.6| |type|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
#clusters
|名字|类型|描述|起始版本| |--|--|--|----| |name|String|资源名称|0.6| |uuid|String|资源的UUID,唯一标示该资源|0.6| |description|String|资源的详细描述|0.6| |state|String|集群状态|0.6| |hypervisorType|String|虚拟机管理程序类型|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |zoneUuid|String|区域UUID|0.6| |type|String|保留域|0.6|
#hosts
|名字|类型|描述|起始版本| |--|--|--|----| |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| |totalMemoryCapacity|Long| |0.6| |availableMemoryCapacity|Long| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
GetCandidateZonesClustersHostsForCreatingVmAction action = new GetCandidateZonesClustersHostsForCreatingVmAction(); action.instanceOfferingUuid = "f1569e619ba44cfeb264759df0720b19"; action.imageUuid = "57374e8324c34999ba81bd363a576653"; action.l3NetworkUuids = asList("dfac2b50c85a498780cf6d1828075e51"); action.dataDiskOfferingUuids = asList("bbe0af9d301e44d6b4605c6ed61f33d5","49f0cbfd2b694e5f9a5cf631f7dc219b"); action.clusterUuid = "0efc966199184f99982e9874186aab38"; action.sessionId = "5d04a0ac859746dea2f9cd81329e91ea"; GetCandidateZonesClustersHostsForCreatingVmAction.Result res = action.call();
Python SDK
GetCandidateZonesClustersHostsForCreatingVmAction action = GetCandidateZonesClustersHostsForCreatingVmAction() action.instanceOfferingUuid = "6aef4e5bcf944af293096558effda40d" action.imageUuid = "8a93ad62da8c436e8b79f37aae134bc6" action.l3NetworkUuids = [3f1df9b106a04503bb1c7a68c7bddf75] action.dataDiskOfferingUuids = [71817f0e5fa04e4e8ef5c035a0f84e67, ddb83b57bfc14aadb3df1ca6d40bfe04] action.clusterUuid = "c910b625c0f94958a6a7e4ad3df15d34" action.sessionId = "ae4cc6df99b14fb091a9b3779228709c" GetCandidateZonesClustersHostsForCreatingVmAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机可启动目的地列表(GetVmStartingCandidateClustersHosts)
获取一个停止的云主机可以启动的集群、物理机列表。用户可以用该API判断一个停止的云主机可以在哪些集群、物理机上启动。
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/starting-target-hosts
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth: a2a9ac093ee64f669665aff2807bbe8a" \ -X GET http://localhost:8080/zstack/v1/vm-instances/d8cfc97f5099454bb3eed367a79d4e4c/starting-target-hosts
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "hostInventories": [ { "zoneUuid": "1650e7c372ab4d43aa1b16e3a48f5f05", "name": "example", "uuid": "3b659b741cc743a5840aaab5a2c366d1", "clusterUuid": "5ecdcc0a2823494daa0c85a7889a7890", "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, "createDate": "Apr 24, 2017 7:11:02 PM", "lastOpDate": "Apr 24, 2017 7:11:02 PM" } ], "clusterInventories": [ { "name": "cluster1", "uuid": "2ecd7d0ddad649e4a36a7f47e43dae1a", "hypervisorType": "KVM", "createDate": "Apr 24, 2017 7:11:02 PM", "lastOpDate": "Apr 24, 2017 7:11:02 PM", "zoneUuid": "268a180f9a7d4ebe9f5a0e7ad558d523" } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |hosts|List|详情参考hosts|0.6| |clusters|List|详情参考clusters|0.6|
#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|
#hosts
|名字|类型|描述|起始版本| |--|--|--|----| |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| |totalMemoryCapacity|Long| |0.6| |availableMemoryCapacity|Long| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
#clusters
|名字|类型|描述|起始版本| |--|--|--|----| |name|String|资源名称|0.6| |uuid|String|资源的UUID,唯一标示该资源|0.6| |description|String|资源的详细描述|0.6| |state|String|集群状态|0.6| |hypervisorType|String|虚拟机管理程序类型|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |zoneUuid|String|区域UUID|0.6| |type|String|保留域|0.6|
SDK示例
Java SDK
GetVmStartingCandidateClustersHostsAction action = new GetVmStartingCandidateClustersHostsAction(); action.uuid = "a591b94c66d6452284f9940e7807425a"; action.sessionId = "5630397e6ade47e9bd73569f5177957e"; GetVmStartingCandidateClustersHostsAction.Result res = action.call();
Python SDK
GetVmStartingCandidateClustersHostsAction action = GetVmStartingCandidateClustersHostsAction() action.uuid = "0cb8127bcfb8431497562f7464ee9920" action.sessionId = "9320fb483c3c4926a7870ffa045088b2" GetVmStartingCandidateClustersHostsAction.Result res = action.call()
Parent topic: 云主机相关接口
指定云主机IP(SetVmStaticIp)
给云主机网卡指定IP,用户可以通过该API控制ZStack分配给云主机网卡的IP。
用户要确保指定的IP在指定三层网络,并且IP未被占用。
API请求
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVmStaticIp": { "l3NetworkUuid": "61e66d487dff454f9509a1f19606d274", "ip": "192.168.10.10" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmStaticIp":{"l3NetworkUuid":"9fcbd78edb58391f8d9b879ea87598fd","ip":"192.168.10.10"}}' \ http://localhost:8080/zstack/v1/vm-instances/e3749802228a36038d0e17041414fd17/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |l3NetworkUuid|String|body(包含在setVmStaticIp结构中)|三层网络UUID| |0.6| |ip|String|body(包含在setVmStaticIp结构中)|指定IP地址| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetVmStaticIpAction action = new SetVmStaticIpAction(); action.vmInstanceUuid = "ba40d9c668384207bf297e36a5b687d5"; action.l3NetworkUuid = "016dbda9a11a4f679378845052422164"; action.ip = "192.168.10.10"; action.sessionId = "3c5be55dcf2d4885b32f46e7711603e1"; SetVmStaticIpAction.Result res = action.call();
Python SDK
SetVmStaticIpAction action = SetVmStaticIpAction() action.vmInstanceUuid = "b8472643ebe34e7dab186b8df4e0f930" action.l3NetworkUuid = "c5ba309fd4e24be1a406b1c9e203e637" action.ip = "192.168.10.10" action.sessionId = "6f1fb28af50a438783d971f195629ed9" SetVmStaticIpAction.Result res = action.call()
Parent topic: 云主机相关接口
删除云主机指定IP(DeleteVmStaticIp)
删除云主机三层网络上指定的IP。
API请求
URLs
DELETE zstack/v1/vm-instances/{vmInstanceUuid}/static-ips
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "l3NetworkUuid": "0a52c0bd8b4049699ff5b772f3f3eb59", "deleteMode": "Permissive" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 64d0600e594944eca1f49970ab4ca25c" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/faf465c53e7f47898b8f41c5e90e46d3/static-ips?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |l3NetworkUuid|String|body(包含在params结构中)|三层网络UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "aa498202ad064d949e953e6b1c34653a", "name": "Test-VM", "description": "web server VM", "zoneUuid": "ac43427ffc5948c8a24aa364a4471ada", "clusterUuid": "ba25be3393a1445b8fdfdba28f87155d", "imageUuid": "b0884882126445ddb8e3d5de3490bdcf", "hostUuid": "f4f2e93245bd40c3a5db51d9ac95c593", "lastHostUuid": "88f9a2a245ef4a289588851f927763e2", "instanceOfferingUuid": "1b206ad5484645528ba14a1c27c633d0", "rootVolumeUuid": "200bf3e928de459d9182fea4cf7eb3fd", "platform": "Linux", "defaultL3NetworkUuid": "44b85e2a6d7f443b9f0bed0842449a35", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:29 PM", "lastOpDate": "May 11, 2017 1:22:29 PM", "state": "Running", "vmNics": [ { "uuid": "8767d51cb10341eebc866d756a23b160", "vmInstanceUuid": "aa498202ad064d949e953e6b1c34653a", "usedIpUuid": "cafa365e629846dd895cd4f273edd9bf", "l3NetworkUuid": "44b85e2a6d7f443b9f0bed0842449a35", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "May 11, 2017 1:22:29 PM", "lastOpDate": "May 11, 2017 1:22:29 PM" } ], "allVolumes": [ { "uuid": "200bf3e928de459d9182fea4cf7eb3fd", "name": "Root-Volume-For-VM-aa498202ad064d949e953e6b1c34653a", "primaryStorageUuid": "251c44e3521e49d4982aa9c7b3b6116b", "vmInstanceUuid": "aa498202ad064d949e953e6b1c34653a", "diskOfferingUuid": "afd12ea56bd84e8b9a26fe27b11d20ca", "rootImageUuid": "b0884882126445ddb8e3d5de3490bdcf", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-200bf3e928de459d9182fea4cf7eb3fd/200bf3e928de459d9182fea4cf7eb3fd.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:29 PM", "lastOpDate": "May 11, 2017 1:22:29 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
DeleteVmStaticIpAction action = new DeleteVmStaticIpAction(); action.vmInstanceUuid = "f81673bc3cf04884b19d5ded83cd9ff8"; action.l3NetworkUuid = "636a65b66bfc490985d44285a090ab11"; action.deleteMode = "Permissive"; action.sessionId = "93d5734188ee48058032d6a2cebebf80"; DeleteVmStaticIpAction.Result res = action.call();
Python SDK
DeleteVmStaticIpAction action = DeleteVmStaticIpAction() action.vmInstanceUuid = "6fa2e4774cb34e72986f3a4860c5fad4" action.l3NetworkUuid = "fa3953b839434d4a81a106e578a3a366" action.deleteMode = "Permissive" action.sessionId = "5cc00379d1224a1c9be943419e54f467" DeleteVmStaticIpAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机能力(GetVmCapabilities)
获取一个云主机的能力,用于判断云主机是否能做某些特定操作。目前已定义能力包括:
|名称|描述|类型| |--|--|--| |LiveMigration|是否支持热迁移|Boolean| |VolumeMigration|是否支持根云盘迁移|Boolean|
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/capabilities
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b883d676f4514489ab993c87f6a8ee70" \ -X GET http://localhost:8080/zstack/v1/vm-instances/7a6c30c6de654cdf9d29b18a78c83a64/capabilities
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "capabilities": { "LiveMigration": false, "Reimage": false, "VolumeMigration": true } }
|名字|类型|描述|起始版本| |--|--|--|----| |capabilities|Map|云主机能力结果|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVmCapabilitiesAction action = new GetVmCapabilitiesAction(); action.uuid = "2323ae79b3894f0a85018a2a458247aa"; action.sessionId = "05233d04bc144482a5b4a74fdea06408"; GetVmCapabilitiesAction.Result res = action.call();
Python SDK
GetVmCapabilitiesAction action = GetVmCapabilitiesAction() action.uuid = "0fb5a5b4a3e54314ba1c5fa2e07384d2" action.sessionId = "71df5d9cf30845dba8d1ef804bdf2108" GetVmCapabilitiesAction.Result res = action.call()
Parent topic: 云主机相关接口
更新云主机信息(UpdateVmInstance)
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "updateVmInstance": { "name": "new vm name" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"updateVmInstance":{"name":"new vm name"}}' \ http://localhost:8080/zstack/v1/vm-instances/dfa2feae60f431ac8d5f071f5594cfc1/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机UUID| |0.6| |name (可选)|String|body(包含在updateVmInstance结构中)|云主机名| |0.6| |description (可选)|String|body(包含在updateVmInstance结构中)|云主机详细描述| |0.6| |state (可选)|String|body(包含在updateVmInstance结构中)|云主机状态- 通常不应该直接更新云主机状态,否则会导致ZStack对云主机状态发生误判。 - 该字段只应用于云主机真实状态和ZStack记录状态发生不一致,而ZStack同步机制已失效时(通常意味着bug)。 - 管理员应完全理解使用该字段的后果。
| - Stopped - Running
|0.6| |defaultL3NetworkUuid (可选)|String|body(包含在updateVmInstance结构中)|默认三层网络UUID| |0.6| |platform (可选)|String|body(包含在updateVmInstance结构中)|云主机平台类型| - Linux - Windows - WindowsVirtio - Other - Paravirtualization
|0.6| |cpuNum (可选)|Integer|body(包含在updateVmInstance结构中)| - 云主机CPU数量。需停止/启动云主机后生效 - 当全局设置NUMA为true情况下创建的云主机,支持动态调整
| |0.6| |memorySize (可选)|Long|body(包含在updateVmInstance结构中)| - 云主机内存大小。需停止/启动云主机后生效 - 全局设置NUMA为true情况下创建的云主机,支持动态调整。
| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "ce30835606c64b27bd6a670cf39e5e30", "name": "new vm name", "description": "web server VM", "zoneUuid": "6557f48432f149a9be3279a167068dd1", "clusterUuid": "be99794e737d4103b4312976021f9c8b", "imageUuid": "3eb52b217b624b7790617a44625a48ac", "hostUuid": "fcac26b35b6842709506f2e389bb5a49", "lastHostUuid": "d63a723e89234b08beefd0c189f62ac1", "instanceOfferingUuid": "292e736c9cfd4b2e9e0054f466438fae", "rootVolumeUuid": "a070b034f1b24f5ab7945c143481dcb8", "platform": "Linux", "defaultL3NetworkUuid": "750133c18a2b42cfae009ca753976d56", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "Apr 24, 2017 7:11:00 PM", "lastOpDate": "Apr 24, 2017 7:11:00 PM", "state": "Running", "vmNics": [ { "uuid": "ec9245ae957f4b73baa754df34858949", "vmInstanceUuid": "ce30835606c64b27bd6a670cf39e5e30", "usedIpUuid": "c4da6c735edf4c74b3d3ea36aee8b243", "l3NetworkUuid": "750133c18a2b42cfae009ca753976d56", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "Apr 24, 2017 7:11:00 PM", "lastOpDate": "Apr 24, 2017 7:11:00 PM" } ], "allVolumes": [ { "uuid": "a070b034f1b24f5ab7945c143481dcb8", "name": "Root-Volume-For-VM-ce30835606c64b27bd6a670cf39e5e30", "primaryStorageUuid": "e56c9326ab0c40a5b3df120f96a96027", "vmInstanceUuid": "ce30835606c64b27bd6a670cf39e5e30", "diskOfferingUuid": "cfd39b1d1ecf441991d7dba4c3919e6a", "rootImageUuid": "3eb52b217b624b7790617a44625a48ac", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-a070b034f1b24f5ab7945c143481dcb8/a070b034f1b24f5ab7945c143481dcb8.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Apr 24, 2017 7:11:00 PM", "lastOpDate": "Apr 24, 2017 7:11:00 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
UpdateVmInstanceAction action = new UpdateVmInstanceAction(); action.uuid = "c424899cef6f4723baf0aae3acbe6020"; action.name = "new vm name"; action.sessionId = "4320eeda74fa41788522c75ed42ec889"; UpdateVmInstanceAction.Result res = action.call();
Python SDK
UpdateVmInstanceAction action = UpdateVmInstanceAction() action.uuid = "fb287c6cb9134d208d1ed054577ad249" action.name = "new vm name" action.sessionId = "2f01595d029449dbbf6c052ad1914271" UpdateVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
克隆云主机到指定物理机(CloneVmInstance)
API请求
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "cloneVmInstance": { "strategy": "InstantStart", "names": [ "vm1", "vm2" ] }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"cloneVmInstance":{"strategy":"InstantStart","names":["vm1","vm2"]}}' \ http://localhost:8080/zstack/v1/vm-instances/c4d628c203433f64b062ad07c8edf10d/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |strategy (可选)|String|body(包含在cloneVmInstance结构中)|策略| - InstantStart - JustCreate
|0.6| |names|List|body(包含在cloneVmInstance结构中)|云主机的名字清单| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
Note:
从ZStack 2.2开始,支持亲和组功能,SystemTags增加affinityGroup选项。
选项格式为:
affinityGroupUuid::UUID
例如:
affinityGroupUuid::5fd71606d5af451d981413f35367a8d6
API返回
返回示例
{ "result": { "numberOfClonedVm": 1.0, "inventories": [ { "inventory": { "uuid": "540efff21e45450ca36da57ce066a7aa", "name": "new vm name", "description": "web server VM", "zoneUuid": "29055b08c5f34f27b4eeef17929849dc", "clusterUuid": "78fe2d34292d4279aa4a63e8ab57273d", "imageUuid": "83156f38784241cd84972baae243888c", "hostUuid": "576fb554e9c14acc9721d536f5495e8d", "lastHostUuid": "08593719eb0f435da3a27ea01de8263e", "instanceOfferingUuid": "ab223c0391ae4552a82141d64d5c0703", "rootVolumeUuid": "328882c567b34875a05cef982a270c19", "platform": "Linux", "defaultL3NetworkUuid": "0a2a75e86244423ea7118a8a7c66af6c", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "May 11, 2017 1:22:52 PM", "lastOpDate": "May 11, 2017 1:22:52 PM", "state": "Running", "allVolumes": [ { "uuid": "328882c567b34875a05cef982a270c19", "name": "Root-Volume-For-VM-540efff21e45450ca36da57ce066a7aa", "primaryStorageUuid": "b2b15d902fc14ad19e59222fe6278978", "vmInstanceUuid": "540efff21e45450ca36da57ce066a7aa", "diskOfferingUuid": "d54d5b27a798478ab2b36e6c2eae7e05", "rootImageUuid": "83156f38784241cd84972baae243888c", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-328882c567b34875a05cef982a270c19/328882c567b34875a05cef982a270c19.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:52 PM", "lastOpDate": "May 11, 2017 1:22:52 PM" } ] } } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |success|boolean| |0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |result|CloneVmInstanceResults|详情参考result|0.6|
#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|
#result
|名字|类型|描述|起始版| |--|--|--|---| |numberOfClonedVm|int| |0.6| |inventories|List|详情参考inventories|0.6|
inventories
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|详情参考error|0.6| |inventory|VmInstanceInventory|详情参考inventory|0.6|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
CloneVmInstanceAction action = new CloneVmInstanceAction(); action.vmInstanceUuid = "0bc94e776a264bebb04b9208b3f08d11"; action.strategy = "InstantStart"; action.names = asList("vm1","vm2"); action.sessionId = "2d45c4d2ef284c43b0bb5d9dfca4b3a7"; CloneVmInstanceAction.Result res = action.call();
Python SDK
CloneVmInstanceAction action = CloneVmInstanceAction() action.vmInstanceUuid = "27d96dc80a094549953b94f212e1d892" action.strategy = "InstantStart" action.names = [vm1, vm2] action.sessionId = "83fda581f11b4d5bb834177e21a712f2" CloneVmInstanceAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机高可用级别(SetVmInstanceHaLevel)
API请求
URLs
POST zstack/v1/vm-instances/{uuid}/ha-levels
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "level": "NeverStop" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"level":"NeverStop"}}' \ http://localhost:8080/zstack/v1/vm-instances/76d39c6862b840a3aa4568d83db99022/ha-levels
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机的资源Uuid| |0.6| |level|String|body(包含在params结构中)|云主机高可用级别:- NeverStop
永不停机
OnHostFailure
物理机发生异常触发高可用
| - NeverStop - OnHostFailure
|0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout" } }
SDK示例
Java SDK
SetVmInstanceHaLevelAction action = new SetVmInstanceHaLevelAction(); action.uuid = "76d39c6862b840a3aa4568d83db99022"; action.level = "NeverStop"; action.sessionId = "673a3db55e4a43739aa2b701462547f3"; SetVmInstanceHaLevelAction.Result res = action.call();
Python SDK
SetVmInstanceHaLevelAction action = SetVmInstanceHaLevelAction() action.uuid = "76d39c6862b840a3aa4568d83db99022" action.level = "NeverStop" action.sessionId = "f631227267ef445a9d8066e163c6618a" SetVmInstanceHaLevelAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机高可用级别(GetVmInstanceHaLevel)
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/ha-levels
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 92f80693e3d641c68c014d4f762c0b70" \ -X GET http://localhost:8080/zstack/v1/vm-instances/76d39c6862b840a3aa4568d83db99022/ha-levels
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机资源Uuid| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "level": "NeverStop" }
|名字|类型|描述|起始版本| |--|--|--|----| |level|String|云主机高可用级别,NeverStop或OnHostFailure|0.6| |success|boolean| |0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVmInstanceHaLevelAction action = new GetVmInstanceHaLevelAction(); action.uuid = "76d39c6862b840a3aa4568d83db99022"; action.sessionId = "ed55da0421704d2ca59ff0106cae94bb"; GetVmInstanceHaLevelAction.Result res = action.call();
Python SDK
GetVmInstanceHaLevelAction action = GetVmInstanceHaLevelAction() action.uuid = "76d39c6862b840a3aa4568d83db99022" action.sessionId = "559a84ded13d4e88a7fdb01f2dfd47f0" GetVmInstanceHaLevelAction.Result res = action.call()
Parent topic: 云主机相关接口
取消云主机高可用(DeleteVmInstanceHaLevel)
API请求
URLs
DELETE zstack/v1/instances/{uuid}/ha-levels
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 038c30608df54956bea7e06d6adf7ffe" \ -X DELETE http://localhost:8080/zstack/v1/vm-instances/76d39c6862b840a3aa4568d83db99022/ha-levels?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云主机资源Uuid| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteVmInstanceHaLevelAction action = new DeleteVmInstanceHaLevelAction(); action.uuid = "76d39c6862b840a3aa4568d83db99022"; action.sessionId = "0cc42e2185664cd6a762ea527075e9f9"; DeleteVmInstanceHaLevelAction.Result res = action.call();
Python SDK
DeleteVmInstanceHaLevelAction action = DeleteVmInstanceHaLevelAction() action.uuid = "76d39c6862b840a3aa4568d83db99022" action.sessionId = "55fbd55cda2a45f3abbd540620846039" DeleteVmInstanceHaLevelAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机Qga (GetVmQga)
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/qga
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 34fc90e40acb4b59b0051485dc625b34" \ -X GET http://localhost:8080/zstack/v1/vm-instances/ab76c455f44b4b1b8a33ecdde1a98eb3/qga
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |systemTags (可选)|List|query| | |0.6| |userTags (可选)|List|query| | |0.6|
API返回
返回示例
{ "uuid": "889251004c244ec6aafd2df09b8cfcbd", "enable": true }
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |enable|boolean| |0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVmQgaAction action = new GetVmQgaAction(); action.uuid = "f2e1551d87d6495faa2bbf3059f060c6"; action.sessionId = "1759cb82bcb44dd9b06cac166513ea41"; GetVmQgaAction.Result res = action.call();
Python SDK
GetVmQgaAction action = GetVmQgaAction() action.uuid = "d9772f9d072f4412954e52516111cc3c" action.sessionId = "9f1efc92185649659a77f8de8ea5d886" GetVmQgaAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机Qga (SetVmQga)
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "enable": false }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmQga":{"enable":false}}' \ http://localhost:8080/zstack/v1/vm-instances/8f37ceee285c3418b28247388508601a/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |enable|boolean|body(包含在params结构中)| | |0.6| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body| | |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetVmQgaAction action = new SetVmQgaAction(); action.uuid = "771991c9b47f45a392bddeadba95ab2b"; action.enable = false; action.sessionId = "6dc45ce48e8345f89c8487bb9a5180f8"; SetVmQgaAction.Result res = action.call();
Python SDK
SetVmQgaAction action = SetVmQgaAction() action.uuid = "084bb6e8ecd9497fb261049cce04b116" action.enable = false action.sessionId = "5e78bf8076a84933928ee8d2ef04eca9" SetVmQgaAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机RDP开关状态(GetVmRDP)
获取VM RDP开关状态,返回值为true或者false
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/rdp
Headers
Authorization: OAuth the-session-uuid
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth c38710f23af942819cc2c431bd94407b" \ -X GET http://localhost:8080/zstack/v1/vm-instances/78494eb669424e97b6f18920a920adbf/rdp
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.1| |systemTags (可选)|List|query| | |2.1| |userTags (可选)|List|query| | |2.1|
API返回
返回示例
{ "enable": true }
|名字|类型|描述|起始版本| |--|--|--|----| |enable|boolean|vm RDP 开关是否开启|2.1| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.1|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.1| |description|String|错误的概要描述|2.1| |details|String|错误的详细信息|2.1| |elaboration|String|保留字段,默认为null|2.1| |opaque|LinkedHashMap|保留字段,默认为null|2.1| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.1|
SDK示例
Java SDK
GetVmRDPAction action = new GetVmRDPAction(); action.uuid = "2503d2eb486e43469fef0e4864fb6c90"; action.sessionId = "380901023c664283a2a3edc0c52817f2"; GetVmRDPAction.Result res = action.call();
Python SDK
GetVmRDPAction action = GetVmRDPAction() action.uuid = "4cec955330e44ac980b99f20c811f1cc" action.sessionId = "2971ac1171da458b964bf689032ba778" GetVmRDPAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机RDP开关状态(SetVmRDP)
设置云主机RDP功能是否开启,如果开启,桌面云会使用RDP连接该云主机。
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVmRDP": { "enable": true }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmRDP":{"enable":true}}' \ http://localhost:8080/zstack/v1/vm-instances/f523cb5736b630acb643dda6d31be5a0/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.2| |enable|boolean|body(包含在setVmRDP结构中)|云主机是否被标识为RDP可访问| |2.2| |systemTags (可选)|List|body| | |2.2| |userTags (可选)|List|body| | |2.2|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetVmRDPAction action = new SetVmRDPAction(); action.uuid = "e2889e09bb0a4f1b9f2757d8bd0c1fc6"; action.enable = true; action.sessionId = "595b40e65a1f4755a68573ab9ef6802c"; SetVmRDPAction.Result res = action.call();
Python SDK
SetVmRDPAction action = SetVmRDPAction() action.uuid = "dc71514a6e1a490b9985b1dcb4faff11" action.enable = true action.sessionId = "aee17676e2604d9ab50a4b8907c31568" SetVmRDPAction.Result res = action.call()
Parent topic: 云主机相关接口
获取云主机支持的屏幕数(GetVmMonitorNumber)
获取vm支持的屏幕个数
API请求
URLs
GET zstack/v1/vm-instances/{uuid}/monitorNumber
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 536c3b51e70f441190204e645a3d2d76" \ -X GET http://localhost:8080/zstack/v1/vm-instances/deb35f3b8ebf4b7e9765726a9c8e3505/monitorNumber
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.2| |systemTags (可选)|List|query| | |2.2| |userTags (可选)|List|query| | |2.2|
API返回
返回示例
{ "monitorNumber": 2.0 }
|名字|类型|描述|起始版本| |--|--|--|----| |monitorNumber|Integer| |2.2| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.2|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.2| |description|String|错误的概要描述|2.2| |details|String|错误的详细信息|2.2| |elaboration|String|保留字段,默认为null|2.2| |opaque|LinkedHashMap|保留字段,默认为null|2.2| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.2|
SDK示例
Java SDK
GetVmMonitorNumberAction action = new GetVmMonitorNumberAction(); action.uuid = "6415ca5909524c00b7b66c9662b45df1"; action.sessionId = "4bf39c422c2d4e01b5ab88da17096d0d"; GetVmMonitorNumberAction.Result res = action.call();
Python SDK
GetVmMonitorNumberAction action = GetVmMonitorNumberAction() action.uuid = "dc6e40115e674ccab14d9425d0028428" action.sessionId = "3f5d36676ca94b9183b567470a22ed19" GetVmMonitorNumberAction.Result res = action.call()
Parent topic: 云主机相关接口
设置云主机支持的屏幕数(SetVmMonitorNumber)
设置云主机支持的屏幕个数
API请求
URLs
PUT zstack/v1/vm-instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVmMonitorNumber": { "monitorNumber": 2.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVmMonitorNumber":{"monitorNumber":2.0}}' \ http://localhost:8080/zstack/v1/vm-instances/7cc2eec452593010bd2691f88385de7a/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.2| |monitorNumber|Integer|body(包含在setVmMonitorNumber结构中)|显示器个数| |2.2| |systemTags (可选)|List|body| | |2.2| |userTags (可选)|List|body| | |2.2|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetVmMonitorNumberAction action = new SetVmMonitorNumberAction(); action.uuid = "eb57f91af28a48dcbb6c56220a9b6d24"; action.monitorNumber = 2.0; action.sessionId = "d8b870a03f97490fa6c39085cec24da7"; SetVmMonitorNumberAction.Result res = action.call();
Python SDK
SetVmMonitorNumberAction action = SetVmMonitorNumberAction() action.uuid = "9a07d71b055e4da7a2f172e4cf7f337f" action.monitorNumber = 2.0 action.sessionId = "56766234a9a54fe3b70c0e28b22fea5c" SetVmMonitorNumberAction.Result res = action.call()
Parent topic: 云主机相关接口
修改云主机根云盘(ChangeVmImage)
API请求
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "changeVmImage": { "imageUuid": "dbfd52c2f87c39cda8c8945fca8d6a5a" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"changeVmImage":{"imageUuid":"dbfd52c2f87c39cda8c8945fca8d6a5a"}}' \ http://localhost:8080/zstack/v1/vm-instances/af9e42b52dc836dfac3ee89b08c47488/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |2.2| |imageUuid|String|body(包含在changeVmImage结构中)|镜像UUID| |2.2| |systemTags (可选)|List|body|系统标签| |2.2| |userTags (可选)|List|body|用户标签| |2.2|
API返回
返回示例
{ "inventory": { "uuid": "8753ddd9d41d3e1c81bca779096325e6", "name": "Test-VM", "description": "web server VM", "zoneUuid": "8f13ce3cefcc3b4f905140613c0790e9", "clusterUuid": "48574e91679f376f9443d75bd3deabd3", "imageUuid": "d20e62e8cab133498f1456c14e210644", "hostUuid": "1f74c3ba1d8a38afbc2c00b024b9df6f", "lastHostUuid": "9220f51b605a308ab2d540541261d452", "instanceOfferingUuid": "d1fe019ddd65376491f5b992dbe52f9d", "rootVolumeUuid": "d4131773654237c997b00fad3102d30d", "platform": "Linux", "defaultL3NetworkUuid": "f12a1735a9f33a86a16d9487351832ac", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "Nov 14, 2017 10:20:57 PM", "lastOpDate": "Nov 14, 2017 10:20:57 PM", "state": "Running", "vmNics": [ { "uuid": "6364c6ddbac03148b680f477761fd87a", "vmInstanceUuid": "8753ddd9d41d3e1c81bca779096325e6", "usedIpUuid": "996010937c043cee98258e261191d3e4", "l3NetworkUuid": "f12a1735a9f33a86a16d9487351832ac", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "Nov 14, 2017 10:20:57 PM", "lastOpDate": "Nov 14, 2017 10:20:57 PM" } ], "allVolumes": [ { "uuid": "d4131773654237c997b00fad3102d30d", "name": "Root-Volume-For-VM-8753ddd9d41d3e1c81bca779096325e6", "primaryStorageUuid": "080271df17b53de2857ab4728bafb21d", "vmInstanceUuid": "8753ddd9d41d3e1c81bca779096325e6", "diskOfferingUuid": "0fa1ba3b260633ecaa74111268b22d11", "rootImageUuid": "d20e62e8cab133498f1456c14e210644", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-d4131773654237c997b00fad3102d30d/d4131773654237c997b00fad3102d30d.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Nov 14, 2017 10:20:57 PM", "lastOpDate": "Nov 14, 2017 10:20:57 PM" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.2| |inventory|VmInstanceInventory|详情参考inventory|2.2|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.2| |description|String|错误的概要描述|2.2| |details|String|错误的详细信息|2.2| |elaboration|String|保留字段,默认为null|2.2| |opaque|LinkedHashMap|保留字段,默认为null|2.2| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.2|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |name|String|资源名称|2.2| |description|String|资源的详细描述|2.2| |zoneUuid|String|区域UUID|2.2| |clusterUuid|String|集群UUID|2.2| |imageUuid|String|镜像UUID|2.2| |hostUuid|String|物理机UUID|2.2| |lastHostUuid|String| |2.2| |instanceOfferingUuid|String|计算规格UUID|2.2| |rootVolumeUuid|String|根云盘UUID|2.2| |platform|String| |2.2| |defaultL3NetworkUuid|String| |2.2| |type|String| |2.2| |hypervisorType|String| |2.2| |memorySize|Long| |2.2| |cpuNum|Integer| |2.2| |cpuSpeed|Long| |2.2| |allocatorStrategy|String| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2| |state|String| |2.2| |vmNics|List|详情参考vmNics|2.2| |allVolumes|List|详情参考allVolumes|2.2|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |vmInstanceUuid|String|云主机UUID|2.2| |l3NetworkUuid|String|三层网络UUID|2.2| |ip|String| |2.2| |mac|String| |2.2| |netmask|String| |2.2| |gateway|String| |2.2| |metaData|String| |2.2| |deviceId|Integer| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2|
#allVolumes
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |name|String|资源名称|2.2| |description|String|资源的详细描述|2.2| |primaryStorageUuid|String|主存储UUID|2.2| |vmInstanceUuid|String|云主机UUID|2.2| |diskOfferingUuid|String|云盘规格UUID|2.2| |rootImageUuid|String| |2.2| |installPath|String| |2.2| |type|String| |2.2| |format|String| |2.2| |size|Long| |2.2| |actualSize|Long| |2.2| |deviceId|Integer| |2.2| |state|String| |2.2| |status|String| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2| |isShareable|Boolean| |2.2|
SDK示例
Java SDK
ChangeVmImageAction action = new ChangeVmImageAction(); action.vmInstanceUuid = "af9e42b52dc836dfac3ee89b08c47488"; action.imageUuid = "dbfd52c2f87c39cda8c8945fca8d6a5a"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; ChangeVmImageAction.Result res = action.call();
Python SDK
ChangeVmImageAction action = ChangeVmImageAction() action.vmInstanceUuid = "af9e42b52dc836dfac3ee89b08c47488" action.imageUuid = "dbfd52c2f87c39cda8c8945fca8d6a5a" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" ChangeVmImageAction.Result res = action.call()
Parent topic: 云主机相关接口
获取候选镜像列表(GetImageCandidatesForVmToChange)
获取用于修改云主机根云盘的候选镜像列表。
API请求
URLs
GET zstack/v1/vm-instances/{vmInstanceUuid}/image-candidates
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/vm-instances/54f0aebe7a2536978aafb9eb7a95003e/image-candidates
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid (可选)|String|url|云主机UUID| |2.2| |systemTags (可选)|List|query|系统标签| |2.2| |userTags (可选)|List|query|用户标签| |2.2|
API返回
返回示例
{ "inventories": [ { "uuid": "2354990ad5ee343eba48bb07851a1423", "name": "TinyLinux", "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "qcow2", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "2354990ad5ee343eba48bb07851a1423", "backupStorageUuid": "a03a78dbdab23444bb109d67a5059389", "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd", "status": "Ready" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.2| |inventories|List|详情参考inventories|2.2|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.2| |description|String|错误的概要描述|2.2| |details|String|错误的详细信息|2.2| |elaboration|String|保留字段,默认为null|2.2| |opaque|LinkedHashMap|保留字段,默认为null|2.2| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.2|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |name|String|资源名称|2.2| |description|String|资源的详细描述|2.2| |exportUrl|String| |2.2| |exportMd5Sum|String| |2.2| |state|String| |2.2| |status|String| |2.2| |size|Long| |2.2| |actualSize|Long| |2.2| |md5Sum|String| |2.2| |url|String| |2.2| |mediaType|String| |2.2| |guestOsType|String| |2.2| |type|String| |2.2| |platform|String| |2.2| |format|String| |2.2| |system|Boolean| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2| |backupStorageRefs|List|详情参考backupStorageRefs|2.2|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|2.2| |backupStorageUuid|String|镜像存储UUID|2.2| |installPath|String| |2.2| |status|String| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2|
SDK示例
Java SDK
GetImageCandidatesForVmToChangeAction action = new GetImageCandidatesForVmToChangeAction(); action.vmInstanceUuid = "54f0aebe7a2536978aafb9eb7a95003e"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; GetImageCandidatesForVmToChangeAction.Result res = action.call();
Python SDK
GetImageCandidatesForVmToChangeAction action = GetImageCandidatesForVmToChangeAction() action.vmInstanceUuid = "54f0aebe7a2536978aafb9eb7a95003e" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" GetImageCandidatesForVmToChangeAction.Result res = action.call()
Parent topic: 云主机相关接口
更新云主机mac地址(UpdateVmNicMac)
API请求
URLs
PUT zstack/v1/vm-instances/nics/{vmNicUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "updateVmNicMac": { "mac": "fa:4c:ee:9a:76:00" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"updateVmNicMac":{"mac":"fa:4c:ee:9a:76:00"}}' \ http://localhost:8080/zstack/v1/vm-instances/nics/c6a34d551b36322ab83b87f7eab6bd41/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmNicUuid|String|url|云主机网卡UUID| |2.3| |mac|String|body(包含在updateVmNicMac结构中)|mac地址| |2.3| |systemTags (可选)|List|body|系统标签| |2.3| |userTags (可选)|List|body|用户标签| |2.3|
API返回
该API成功时返回一个空的JSON结构{}
,出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
UpdateVmNicMacAction action = new UpdateVmNicMacAction(); action.vmNicUuid = "c6a34d551b36322ab83b87f7eab6bd41"; action.mac = "fa:4c:ee:9a:76:00"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; UpdateVmNicMacAction.Result res = action.call();
Python SDK
UpdateVmNicMacAction action = UpdateVmNicMacAction() action.vmNicUuid = "c6a34d551b36322ab83b87f7eab6bd41" action.mac = "fa:4c:ee:9a:76:00" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" UpdateVmNicMacAction.Result res = action.call()
Parent topic: 云主机相关接口
云盘相关接口
创建云盘(CreateDataVolume)
API请求
URLs
POST zstack/v1/volumes/data
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "test-volume", "description": "test-data-volume", "diskOfferingUuid": "d8732f8e173543ef85a0c2066559ef94", "primaryStorageUuid": "ad21b7c7f4ca4d86b348a415347ab1b5", "resourceUuid": "e3c9ebe5b5144dd4ba791c5f2959726a" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"test-volume","description":"test-data-volume","diskOfferingUuid":"d88594833a393e119c6fc5a8aa2ad08f","primaryStorageUuid":"5fe18eef72483c9cbde984a3176fab78","resourceUuid":"52f6075e4d6839fc8a40f569fb7d991e"}}' \ http://localhost:8080/zstack/v1/volumes/data
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|云盘名称| |0.6| |description (可选)|String|body(包含在params结构中)|云盘的描述| |0.6| |diskOfferingUuid|String|body(包含在params结构中)|云盘规格UUID| |0.6| |primaryStorageUuid (可选)|String|body(包含在params结构中)|主存储UUID| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|资源UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "b9d6460b286441099fa9cb3fe5bce9ec", "name": "test-volume", "primaryStorageUuid": "d7d84bb097da41918ee27eeb3b92d4f4", "vmInstanceUuid": "8732b8e254ad4db18a5cad5d04315948", "diskOfferingUuid": "7e6d828db0b84d8cb62a44e3d4badc7d", "rootImageUuid": "8384b89b03914655b888f9b4f864ab07", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-b9d6460b286441099fa9cb3fe5bce9ec/b9d6460b286441099fa9cb3fe5bce9ec.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:51 PM", "lastOpDate": "May 11, 2017 1:22:51 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
CreateDataVolumeAction action = new CreateDataVolumeAction(); action.name = "test-volume"; action.description = "test-data-volume"; action.diskOfferingUuid = "cec2445214fd4e5bb10671b453d25677"; action.primaryStorageUuid = "be3baf0aa09f45ab9ae19c7b6d177ca2"; action.resourceUuid = "f2ebba352d8b43feb434f926f1635ae4"; action.sessionId = "054df264a21d40bbbdf4f292c4993842"; CreateDataVolumeAction.Result res = action.call();
Python SDK
CreateDataVolumeAction action = CreateDataVolumeAction() action.name = "test-volume" action.description = "test-data-volume" action.diskOfferingUuid = "d9ede14fbc6547808208d40658d1dbbd" action.primaryStorageUuid = "f6f7257560cd4278b2202157b45d8687" action.resourceUuid = "3344b25d00ae40c4bfab494d724cb95c" action.sessionId = "755a549dc19e400ea3b22710c5370c75" CreateDataVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
删除云盘(DeleteDataVolume)
API请求
URLs
DELETE zstack/v1/volumes/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 92d7ee354b4e4ed19aea6a7ebb172096" \ -X DELETE http://localhost:8080/zstack/v1/volumes/3102474ff9514720b79ff3719ab6c8e5?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的资源Uuid| |0.6| |deleteMode (可选)|String|body|删除模式:Permissive(删除前检查)或Enforcing(强行删除)| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteDataVolumeAction action = new DeleteDataVolumeAction(); action.uuid = "0c9ca7222d914c628d60f5f38b8a5e1e"; action.deleteMode = "Permissive"; action.sessionId = "6b164d54219d4ef8a287fb4937333d54"; DeleteDataVolumeAction.Result res = action.call();
Python SDK
DeleteDataVolumeAction action = DeleteDataVolumeAction() action.uuid = "ba73b65a66ce433790526c3ee146db3b" action.deleteMode = "Permissive" action.sessionId = "fce147bb4ab540448ad4f1798e90f3f9" DeleteDataVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
彻底删除云盘(ExpungeDataVolume)
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "expungeDataVolume": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"expungeDataVolume":{}}' \ http://localhost:8080/zstack/v1/volumes/6dd47cca96f238c899aacd61867db520/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID,唯一标示该资源| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
ExpungeDataVolumeAction action = new ExpungeDataVolumeAction(); action.uuid = "347edf4db9e9482a895f7aab3d7f4c26"; action.sessionId = "cc3787426fdd480f8ae6ad656b37b909"; ExpungeDataVolumeAction.Result res = action.call();
Python SDK
ExpungeDataVolumeAction action = ExpungeDataVolumeAction() action.uuid = "2dcb23f228294cab80bcd90e0024dc89" action.sessionId = "86af19d2bda54fa6bee0204b8e33d4de" ExpungeDataVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
恢复云盘(RecoverDataVolume)
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "recoverDataVolume": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"recoverDataVolume":{}}' \ http://localhost:8080/zstack/v1/volumes/9f5090fc93ff33e283e0ff3c99fad1e2/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID,唯一标示该资源| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "70820c8ead5144ebaf603b88e63a4d17", "name": "test-volume", "primaryStorageUuid": "abdb1c3460094359baa202c481633470", "vmInstanceUuid": "2f0d6191cc5d452cbbe83284f750c8dd", "diskOfferingUuid": "e3526a708a2845f49f2d09404bf0b67d", "rootImageUuid": "283433d3b0654d16a63f1add9abad3e6", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-70820c8ead5144ebaf603b88e63a4d17/70820c8ead5144ebaf603b88e63a4d17.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "May 11, 2017 1:22:48 PM", "lastOpDate": "May 11, 2017 1:22:48 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
RecoverDataVolumeAction action = new RecoverDataVolumeAction(); action.uuid = "16bc12c40c2242189a9c80a0e908dc21"; action.sessionId = "e444803b7dd047238dca620217929bff"; RecoverDataVolumeAction.Result res = action.call();
Python SDK
RecoverDataVolumeAction action = RecoverDataVolumeAction() action.uuid = "d5bd95c8ce764a72b77510f17a2eb3a4" action.sessionId = "ba4360074009447184682979d1c0fd26" RecoverDataVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
开启或关闭云盘(ChangeVolumeState)
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "changeVolumeState": { "stateEvent": "enable" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"changeVolumeState":{"stateEvent":"enable"}}' \ http://localhost:8080/zstack/v1/volumes/97fa26ec14d9328c9cfada75e3c0307b/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘资源Uuid| |0.6| |stateEvent|String|body(包含在changeVolumeState结构中)|开启或关闭| - enable - disable
|0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "0404b47365d14328b69be6ba29f79e74", "name": "test-volume", "primaryStorageUuid": "b86a9e49bf0e4c96b13b416de45031b1", "vmInstanceUuid": "00e88729e2f64212a7ae19c135de879d", "diskOfferingUuid": "9042780280534984ad298f8c6613e162", "rootImageUuid": "de9c09f4f3f7409e98ac0dbb6cae76a2", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-0404b47365d14328b69be6ba29f79e74/0404b47365d14328b69be6ba29f79e74.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:21:21 PM", "lastOpDate": "Jun 7, 2017 9:21:21 PM" } } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
ChangeVolumeStateAction action = new ChangeVolumeStateAction(); action.uuid = "67553476ee8643f49ac88304822acd7f"; action.stateEvent = "enable"; action.sessionId = "dc32c1bb220843efb1e3b27b9ca95695"; ChangeVolumeStateAction.Result res = action.call();
Python SDK
ChangeVolumeStateAction action = ChangeVolumeStateAction() action.uuid = "d18b8dc1ba91461f995e6904bd6a7fc4" action.stateEvent = "enable" action.sessionId = "72301e2f3cf94e57adf10f56a08d1d12" ChangeVolumeStateAction.Result res = action.call()
Parent topic: 云盘相关接口
从镜像创建云盘(CreateDataVolumeFromVolumeTemplate)
API请求
URLs
POST zstack/v1/volumes/data/from/data-volume-templates/{imageUuid}
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "data-volume-1", "description": "dataVolume-from-volume-template", "primaryStorageUuid": "faf07bfbec0944499d566345f0de383e", "hostUuid": "c0411ea2b3d949fab31239d200a83faf" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"data-volume-1","description":"dataVolume-from-volume-template","primaryStorageUuid":"849de664b4db321f8eeef65a1aa757c7","hostUuid":"0de619ae30373e97acc7bb4b42ca87a1"}}' \ http://localhost:8080/zstack/v1/volumes/data/from/data-volume-templates/285f4a49e7403d2dad9545b42c33b837
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |imageUuid|String|url|镜像UUID| |0.6| |name|String|body(包含在params结构中)|云盘名称| |0.6| |description (可选)|String|body(包含在params结构中)|云盘的详细描述| |0.6| |primaryStorageUuid|String|body(包含在params结构中)|主存储UUID| |0.6| |hostUuid (可选)|String|body(包含在params结构中)|物理机UUID| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)| | |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "289aaa0f33004cb6adba798bf9c8273b", "name": "test-volume", "primaryStorageUuid": "5697632ba45c46408044aefbab433945", "vmInstanceUuid": "c0dcccf2ca8945e1b96b446f7bdba30f", "diskOfferingUuid": "5909df7b2c3f4751b0491f53533c505f", "rootImageUuid": "a8c3608b85a0450d99b9b5339ee4dcec", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-289aaa0f33004cb6adba798bf9c8273b/289aaa0f33004cb6adba798bf9c8273b.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:21:14 PM", "lastOpDate": "Jun 7, 2017 9:21:14 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
CreateDataVolumeFromVolumeTemplateAction action = new CreateDataVolumeFromVolumeTemplateAction(); action.imageUuid = "f0f991b7883b49869e03b0e9d42a5ce9"; action.name = "data-volume-1"; action.description = "dataVolume-from-volume-template"; action.primaryStorageUuid = "0b325fbe797f413290c6015f49160caf"; action.hostUuid = "2c23c98e197745359455268a6414f6cc"; action.sessionId = "351589a73b6247ee817acfc89609a396"; CreateDataVolumeFromVolumeTemplateAction.Result res = action.call();
Python SDK
CreateDataVolumeFromVolumeTemplateAction action = CreateDataVolumeFromVolumeTemplateAction() action.imageUuid = "eeea8f11bf174bf39ffb341c96e93765" action.name = "data-volume-1" action.description = "dataVolume-from-volume-template" action.primaryStorageUuid = "f1bf0bc060474a9484a822a7b9ea3bec" action.hostUuid = "883173c367ba42e49434429012376f36" action.sessionId = "7c098bc9e7e24c1ca81ff90d355b2fca" CreateDataVolumeFromVolumeTemplateAction.Result res = action.call()
Parent topic: 云盘相关接口
从快照创建云盘(CreateDataVolumeFromVolumeSnapshot)
API请求
URLs
POST zstack/v1/volumes/data/from/volume-snapshots/{volumeSnapshotUuid}
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "DataVolume-1", "description": "dataVolume-from-snapshot", "primaryStorageUuid": "4102177b842946a4adf6ba0008710ed6" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"DataVolume-1","description":"dataVolume-from-snapshot","primaryStorageUuid":"b2237f228a343d0cb8b20b5b64663314"}}' \ http://localhost:8080/zstack/v1/volumes/data/from/volume-snapshots/192da9c7d6493a5d9a35d2df2dcc82b0
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|云盘名称| |0.6| |description (可选)|String|body(包含在params结构中)|云盘的详细描述| |0.6| |volumeSnapshotUuid|String|url|云盘快照UUID| |0.6| |primaryStorageUuid (可选)|String|body(包含在params结构中)|主存储UUID| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|资源的Uuid| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "0f7ad281abd34b4d94df149756daa45d", "name": "test-volume", "primaryStorageUuid": "e39d9b37365141f8a126e53555a57f2d", "vmInstanceUuid": "b03e00f24ef842cb9c31fd0f8ab3f38b", "diskOfferingUuid": "cc97edd1f7aa4cc39656e73490863b4d", "rootImageUuid": "d15926cb82a54a26b098e19a982f2f6b", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-0f7ad281abd34b4d94df149756daa45d/0f7ad281abd34b4d94df149756daa45d.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:21:17 PM", "lastOpDate": "Jun 7, 2017 9:21:17 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
CreateDataVolumeFromVolumeSnapshotAction action = new CreateDataVolumeFromVolumeSnapshotAction(); action.name = "DataVolume-1"; action.description = "dataVolume-from-snapshot"; action.volumeSnapshotUuid = "179e11d25aea49ce81ba612108451a8f"; action.primaryStorageUuid = "4d39340d1a9d4bd7a834493af50020ab"; action.sessionId = "d28727a6c2fc44fe9673c4b67da615b5"; CreateDataVolumeFromVolumeSnapshotAction.Result res = action.call();
Python SDK
CreateDataVolumeFromVolumeSnapshotAction action = CreateDataVolumeFromVolumeSnapshotAction() action.name = "DataVolume-1" action.description = "dataVolume-from-snapshot" action.volumeSnapshotUuid = "79200ff743314dd1b1e46bdf9b26f72f" action.primaryStorageUuid = "920b891ae2b84a53a802a0ddc37a7d0c" action.sessionId = "c4c003ce6d664a0db244e5587b6ec7d2" CreateDataVolumeFromVolumeSnapshotAction.Result res = action.call()
Parent topic: 云盘相关接口
获取云盘清单(QueryVolume)
API请求
URLs
GET zstack/v1/volumes GET zstack/v1/volumes/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 37d226de07584043ab547642e4a9d14c" \ -X GET http://localhost:8080/zstack/v1/volumes
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 97dc2b0fd5264c6bb2ff9e693791d492" \ -X GET http://localhost:8080/zstack/v1/volumes/ca621f583bac4b979348fce553525146
可查询字段
运行zstack-cli命令行工具,输入QueryVolume
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{ "inventories": [ { "uuid": "b289ce8ac3874e88b4d4ce5cc4fc4c6e", "name": "test-volume", "primaryStorageUuid": "8749501379364105ba214227fc79578f", "vmInstanceUuid": "4cf370ed63bb43f99d88755b87f722c1", "diskOfferingUuid": "9e4d1d1a0e1a483da86eac0ab99c96ce", "rootImageUuid": "0116e6093d80474693ddac2e670122e4", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-b289ce8ac3874e88b4d4ce5cc4fc4c6e/b289ce8ac3874e88b4d4ce5cc4fc4c6e.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:20:25 PM", "lastOpDate": "Jun 7, 2017 9:20:25 PM" } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
QueryVolumeAction action = new QueryVolumeAction(); action.conditions = asList(); action.sessionId = "a6c77f7c77dd425e98f3089363725c06"; QueryVolumeAction.Result res = action.call();
Python SDK
QueryVolumeAction action = QueryVolumeAction() action.conditions = [] action.sessionId = "8e464fe1562b4fcc80b02596f455e6a8" QueryVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
获取云盘格式(GetVolumeFormat)
API请求
URLs
GET zstack/v1/volumes/formats
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 91c86306f8fd45ba9af34c549baa8052" \ -X GET http://localhost:8080/zstack/v1/volumes/formats
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "formats": [ { "format": "iso", "masterHypervisorType": "KVM", "supportingHypervisorTypes": [ "ESX", "KVM" ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |formats|List|详情参考formats|0.6|
#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|
#formats
|名字|类型|描述|起始版本| |--|--|--|----| |format|String|云盘格式|0.6| |masterHypervisorType|String|默认的Hypervisor类型|0.6| |supportingHypervisorTypes|List|支持的Hypervisor类型列表|0.6|
SDK示例
Java SDK
GetVolumeFormatAction action = new GetVolumeFormatAction(); action.sessionId = "6fda4c2362614bec9ec42a2eb8f4a4b0"; GetVolumeFormatAction.Result res = action.call();
Python SDK
GetVolumeFormatAction action = GetVolumeFormatAction() action.sessionId = "a5cd7896806e4717a609899d22a90594" GetVolumeFormatAction.Result res = action.call()
Parent topic: 云盘相关接口
获取云盘支持的类型的能力(GetVolumeCapabilities)
API请求
URLs
GET zstack/v1/volumes/{uuid}/capabilities
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 202bde8c03d94942b052da20b48a2301" \ -X GET http://localhost:8080/zstack/v1/volumes/96646576bd1c44ac845810374ca41c58/capabilities
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID,唯一标示该资源| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "capabilities": { "MigrationToOtherPrimaryStorage": true, "MigrationInCurrentPrimaryStorage": true } }
|名字|类型|描述|起始版本| |--|--|--|----| |capabilities|Map|云盘支持的类型列表|0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetVolumeCapabilitiesAction action = new GetVolumeCapabilitiesAction(); action.uuid = "23c96138a1874aeebcd082be9b21f905"; action.sessionId = "b8980f940bad4558947437d211262e2f"; GetVolumeCapabilitiesAction.Result res = action.call();
Python SDK
GetVolumeCapabilitiesAction action = GetVolumeCapabilitiesAction() action.uuid = "b645da1aa3ed4771b0860d01144929b6" action.sessionId = "277436d4a8f54942a496ca64b2d7f3f0" GetVolumeCapabilitiesAction.Result res = action.call()
Parent topic: 云盘相关接口
同步云盘大小(SyncVolumeSize)
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "syncVolumeSize": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"syncVolumeSize":{}}' \ http://localhost:8080/zstack/v1/volumes/017a6c821b3433c594285712cd7e69f4/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID,唯一标示该资源| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "d0cd0413d1b241fca524322b56f4687d", "name": "test-volume", "primaryStorageUuid": "8dea01cf7afb4d7bb89ea432fc15258e", "vmInstanceUuid": "f93fa5fea43f42449409c35914c47732", "diskOfferingUuid": "a2915a283c744389a6bae0d42b203e18", "rootImageUuid": "da66399cb83048b0b87fa113ddcd3755", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-d0cd0413d1b241fca524322b56f4687d/d0cd0413d1b241fca524322b56f4687d.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:21:08 PM", "lastOpDate": "Jun 7, 2017 9:21:08 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
SyncVolumeSizeAction action = new SyncVolumeSizeAction(); action.uuid = "793ac8595fbc44618934ccf474c9c82b"; action.sessionId = "eab6cd1a880749ae818f6402c0c72af5"; SyncVolumeSizeAction.Result res = action.call();
Python SDK
SyncVolumeSizeAction action = SyncVolumeSizeAction() action.uuid = "e269f644c3324709a2254d84a6f86457" action.sessionId = "48363f37efe6484abfff927059cedae3" SyncVolumeSizeAction.Result res = action.call()
Parent topic: 云盘相关接口
扩展根云盘(ResizeRootVolume)
API请求
URLs
PUT zstack/v1/volumes/resize/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "resizeRootVolume": { "size": 1.0E7 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"resizeRootVolume":{"size":1.0E7}}' \ http://localhost:8080/zstack/v1/volumes/resize/16a052d270983392bd2824c06a44253f/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.2| |size|long|body(包含在resizeRootVolume结构中)|扩展后大小| |2.2| |systemTags (可选)|List|body| | |2.2| |userTags (可选)|List|body| | |2.2|
API返回
返回示例
{ "inventory": { "uuid": "f6ace13363934d2d9a2dc29c53a83bc4", "name": "test-volume", "primaryStorageUuid": "a849a9d7cf864b95a4a1223db572a73c", "vmInstanceUuid": "d05fda61030645c293688fd2e67b6881", "diskOfferingUuid": "f31553ca15f4495cbd7f3954426f9f1f", "rootImageUuid": "5ef070a672ea48e583c8f4fd6441a58c", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-f6ace13363934d2d9a2dc29c53a83bc4/f6ace13363934d2d9a2dc29c53a83bc4.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Sep 22, 2017 12:24:45 PM", "lastOpDate": "Sep 22, 2017 12:24:45 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.2| |inventory|VolumeInventory|详情参考inventory|2.2|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.2| |description|String|错误的概要描述|2.2| |details|String|错误的详细信息|2.2| |elaboration|String|保留字段,默认为null|2.2| |opaque|LinkedHashMap|保留字段,默认为null|2.2| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.2|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |name|String|资源名称|2.2| |description|String|资源的详细描述|2.2| |primaryStorageUuid|String|主存储UUID|2.2| |vmInstanceUuid|String|云主机UUID|2.2| |diskOfferingUuid|String|云盘规格UUID|2.2| |rootImageUuid|String| |2.2| |installPath|String| |2.2| |type|String| |2.2| |format|String| |2.2| |size|Long| |2.2| |actualSize|Long| |2.2| |deviceId|Integer| |2.2| |state|String| |2.2| |status|String| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2| |isShareable|Boolean| |2.2|
SDK示例
Java SDK
ResizeRootVolumeAction action = new ResizeRootVolumeAction(); action.uuid = "d39ece16a6e74d1582541f256a6bc6fe"; action.size = 1.0E7; action.sessionId = "cae45c7f96264807afaf6337ee40c236"; ResizeRootVolumeAction.Result res = action.call();
Python SDK
ResizeRootVolumeAction action = ResizeRootVolumeAction() action.uuid = "9101b352108041baad9acfadcd38aa22" action.size = 1.0E7 action.sessionId = "dfa1c04aa43f48118cae6ccaabd8bc5c" ResizeRootVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
扩展数据云盘(ResizeDataVolume)
API请求
URLs
PUT zstack/v1/volumes/data/resize/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "resizeDataVolume": { "size": 1.0E7 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"resizeDataVolume":{"size":1.0E7}}' \ http://localhost:8080/zstack/v1/volumes/data/resize/6c2a13e8d7fa3ef99091bc6a445d4e9c/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.2| |size|long|body(包含在resizeDataVolume结构中)|扩展后大小| |2.2| |systemTags (可选)|List|body|系统标签| |2.2| |userTags (可选)|List|body|用户标签| |2.2|
API返回
返回示例
{ "inventory": { "uuid": "f17a01d17e4d39bdb17d227a1df97e3a", "name": "test-volume", "primaryStorageUuid": "83245aa16d02322785f84450d1a05441", "vmInstanceUuid": "14ca01538ffa3ab49aad3dd60c4c41b4", "diskOfferingUuid": "9dd65df23d453f25855a2c2b2f9f778b", "rootImageUuid": "825ca3ebcb053abf843ed8b2731ec4b9", "installPath": "/zstack_ps/dataVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-f17a01d17e4d39bdb17d227a1df97e3a/f17a01d17e4d39bdb17d227a1df97e3a.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Nov 20, 2017 1:50:58 PM", "lastOpDate": "Nov 20, 2017 1:50:58 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.2| |inventory|VolumeInventory|详情参考inventory|2.2|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.2| |description|String|错误的概要描述|2.2| |details|String|错误的详细信息|2.2| |elaboration|String|保留字段,默认为null|2.2| |opaque|LinkedHashMap|保留字段,默认为null|2.2| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.2|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |name|String|资源名称|2.2| |description|String|资源的详细描述|2.2| |primaryStorageUuid|String|主存储UUID|2.2| |vmInstanceUuid|String|云主机UUID|2.2| |diskOfferingUuid|String|云盘规格UUID|2.2| |rootImageUuid|String| |2.2| |installPath|String| |2.2| |type|String| |2.2| |format|String| |2.2| |size|Long| |2.2| |actualSize|Long| |2.2| |deviceId|Integer| |2.2| |state|String| |2.2| |status|String| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2| |isShareable|Boolean| |2.2|
SDK示例
Java SDK
ResizeDataVolumeAction action = new ResizeDataVolumeAction(); action.uuid = "6c2a13e8d7fa3ef99091bc6a445d4e9c"; action.size = 1.0E7; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; ResizeDataVolumeAction.Result res = action.call();
Python SDK
ResizeDataVolumeAction action = ResizeDataVolumeAction() action.uuid = "6c2a13e8d7fa3ef99091bc6a445d4e9c" action.size = 1.0E7 action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" ResizeDataVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
修改云盘属性(UpdateVolume)
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "updateVolume": { "name": "volume-1", "description": "data-volume" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"updateVolume":{"name":"volume-1","description":"data-volume"}}' \ http://localhost:8080/zstack/v1/volumes/f1eddfdb19ad3a0881b0be863901ff09/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID,唯一标示该资源| |0.6| |name (可选)|String|body(包含在updateVolume结构中)|云盘名称| |0.6| |description (可选)|String|body(包含在updateVolume结构中)|云盘的详细描述| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "31ae1f16a1774ead98a84432e08e438c", "name": "test-volume", "primaryStorageUuid": "dafbef4c002b4bf49ac63a2e0cf8c616", "vmInstanceUuid": "417e81050f424bf88b515c2bbc3e9d24", "diskOfferingUuid": "80b0f3edaa2f4c0284240d16aebf8da4", "rootImageUuid": "edb9e2aa51c5489db12a7073daa6c878", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-31ae1f16a1774ead98a84432e08e438c/31ae1f16a1774ead98a84432e08e438c.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:20:28 PM", "lastOpDate": "Jun 7, 2017 9:20:28 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
UpdateVolumeAction action = new UpdateVolumeAction(); action.uuid = "cebcb28540d9474ebf0be79fc9c7efe4"; action.name = "volume-1"; action.description = "data-volume"; action.sessionId = "e5e68d56602441d187139189dce441f7"; UpdateVolumeAction.Result res = action.call();
Python SDK
UpdateVolumeAction action = UpdateVolumeAction() action.uuid = "d429120df78e4b7290fd4f50adfa2f2e" action.name = "volume-1" action.description = "data-volume" action.sessionId = "31a278c3b4024dc48b952196c0ae34a0" UpdateVolumeAction.Result res = action.call()
Parent topic: 云盘相关接口
设置云盘限速(SetVolumeQoS)
API请求
URLs
POST zstack/v1/volumes/{uuid}/QoS
Headers
Authorization: OAuth the-session-uuid
Body
{ "setVolumeQoS": { "volumeBandwidth": 10000.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setVolumeQos":{"volumeBandwidth":10000.0}}' \ http://localhost:8080/zstack/v1/volumes/384f99ce0b7a307685856b23f75c5167/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID| |0.6| |volumeBandwidth|Long|body(包含在params结构中)|云盘限速带宽| |0.6| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body| | |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetVolumeQoSAction action = new SetVolumeQoSAction(); action.uuid = "ac4fdd09c5884f58a5b38b805b5ddb78"; action.volumeBandwidth = 10000.0; action.sessionId = "aeec637635af476b94356f4f8fe714be"; SetVolumeQoSAction.Result res = action.call();
Python SDK
SetVolumeQoSAction action = SetVolumeQoSAction() action.uuid = "26d462d809b54d52b2814bbf1302f305" action.volumeBandwidth = 10000.0 action.sessionId = "eb791fa4bdfb4be28ff279651cde78f9" SetVolumeQoSAction.Result res = action.call()
Parent topic: 云盘相关接口
获取云盘限速(GetVolumeQoS)
API请求
URLs
GET zstack/v1/volumes/{uuid}/QoS
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 8e7e92f06173470890863f425ddba7dc" \ -X GET http://localhost:8080/zstack/v1/volumes/6d6550ffa8e94ae9a8eccba3491f051f/QoS
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID| |0.6| |systemTags (可选)|List|query| | |0.6| |userTags (可选)|List|query| | |0.6|
API返回
返回示例
{ "volumeUuid": "5cbb33fd2d794c53aa361472c4727c34", "volumeBandwidth": 100000.0 }
|名字|类型|描述|起始版本| |--|--|--|----| |volumeBandwidth|long| |0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。详情参考error|0.6|
#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
GetVolumeQoSAction action = new GetVolumeQoSAction(); action.uuid = "b0d6b8438a204fa4be27bff9675506ea"; action.sessionId = "58b4821e41664694b7200e3115d02dd8"; GetVolumeQoSAction.Result res = action.call();
Python SDK
GetVolumeQoSAction action = GetVolumeQoSAction() action.uuid = "17e922620ef04608acf153c1ef77c345" action.sessionId = "2c7784a71e3a46c9b99fba43c247f41f" GetVolumeQoSAction.Result res = action.call()
Parent topic: 云盘相关接口
取消云盘网卡限速(DeleteVolumeQoS)
API请求
URLs
DELETE/v1/volumes/{uuid}/QoS
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth e6a3f0f98d2f407ca5130130fc08fab1" \ -X DELETE http://localhost:8080/zstack/v1/volumes/f86d29d7d37a4001809586b4127caca7/QoS?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID| |0.6| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body| | |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteVolumeQoSAction action = new DeleteVolumeQoSAction(); action.uuid = "3dfcb78645dd4fd5abad6d24facd0432"; action.sessionId = "5cb9c0fce58d480f983e9817f51e4c25"; DeleteVolumeQoSAction.Result res = action.call();
Python SDK
DeleteVolumeQoSAction action = DeleteVolumeQoSAction() action.uuid = "b29a63fa724b46a19298a29f15f782d9" action.sessionId = "2d4291b624ad42a2975136a9ea10f3b0" DeleteVolumeQoSAction.Result res = action.call()
Parent topic: 云盘相关接口
获取云盘是否能被加载(GetDataVolumeAttachableVm)
API请求
URLs
GET zstack/v1/volumes/{volumeUuid}/candidate-vm-instances
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 2da4ab715edf474ea45825d21c7ce711" \ -X GET http://localhost:8080/zstack/v1/volumes/2b419a8547074e098d0da9ee92935344/candidate-vm-instances
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |volumeUuid|String|url|云盘UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
返回示例
{ "inventories": [ { "uuid": "237e1c010bed43288f2f158cd3b1e218", "name": "Test-VM", "description": "web server VM", "zoneUuid": "4537a02725fd49adb8815887fe95e38d", "clusterUuid": "fe33a5b88c054e94b13a8914086e50f3", "imageUuid": "5bed7e1839c44b4289f0eab2af35681d", "hostUuid": "0242f2a240564fd5bdf84bf651740129", "lastHostUuid": "649a873867a247b1bed6b96b61b2e19a", "instanceOfferingUuid": "1edf7842c7f34e00b48d3899d14a1ff2", "rootVolumeUuid": "2adc2350eb16479aa7b9dfdb9bc82d6a", "platform": "Linux", "defaultL3NetworkUuid": "7119ed6d54ca4624aa8e362d07b03a35", "type": "UserVm", "hypervisorType": "KVM", "memorySize": 8.589934592E9, "cpuNum": 1.0, "allocatorStrategy": "LastHostPreferredAllocatorStrategy", "createDate": "Jun 7, 2017 9:20:15 PM", "lastOpDate": "Jun 7, 2017 9:20:15 PM", "state": "Running", "vmNics": [ { "uuid": "f967eee9618c4ee3a8cda348b333ba21", "vmInstanceUuid": "237e1c010bed43288f2f158cd3b1e218", "usedIpUuid": "ead7ed9822e64f18b2f926cb71e0b9da", "l3NetworkUuid": "7119ed6d54ca4624aa8e362d07b03a35", "ip": "192.168.1.10", "mac": "00:0c:29:bd:99:fc", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "deviceId": 0.0, "createDate": "Jun 7, 2017 9:20:15 PM", "lastOpDate": "Jun 7, 2017 9:20:15 PM" } ], "allVolumes": [ { "uuid": "2adc2350eb16479aa7b9dfdb9bc82d6a", "name": "Root-Volume-For-VM-237e1c010bed43288f2f158cd3b1e218", "primaryStorageUuid": "bdffc9aef10d48e4b028d26b09df2e35", "vmInstanceUuid": "237e1c010bed43288f2f158cd3b1e218", "diskOfferingUuid": "0319566f3f7647dbb3a8e642b05f4bfe", "rootImageUuid": "5bed7e1839c44b4289f0eab2af35681d", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-2adc2350eb16479aa7b9dfdb9bc82d6a/2adc2350eb16479aa7b9dfdb9bc82d6a.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:20:15 PM", "lastOpDate": "Jun 7, 2017 9:20:15 PM" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |zoneUuid|String|区域UUID|0.6| |clusterUuid|String|集群UUID|0.6| |imageUuid|String|镜像UUID|0.6| |hostUuid|String|物理机UUID|0.6| |lastHostUuid|String| |0.6| |instanceOfferingUuid|String|计算规格UUID|0.6| |rootVolumeUuid|String|根云盘UUID|0.6| |platform|String| |0.6| |defaultL3NetworkUuid|String| |0.6| |type|String| |0.6| |hypervisorType|String| |0.6| |memorySize|Long| |0.6| |cpuNum|Integer| |0.6| |cpuSpeed|Long| |0.6| |allocatorStrategy|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6| |vmNics|List|详情参考vmNics|0.6| |allVolumes|List|详情参考allVolumes|0.6|
#vmNics
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |vmInstanceUuid|String|云主机UUID|0.6| |l3NetworkUuid|String|三层网络UUID|0.6| |ip|String| |0.6| |mac|String| |0.6| |netmask|String| |0.6| |gateway|String| |0.6| |metaData|String| |0.6| |deviceId|Integer| |0.6| |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| |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|
SDK示例
Java SDK
GetDataVolumeAttachableVmAction action = new GetDataVolumeAttachableVmAction(); action.volumeUuid = "df8f99ea16c54b7f945cbf3bc3968708"; action.sessionId = "a6bd56927c384d639f6ed058226a6a87"; GetDataVolumeAttachableVmAction.Result res = action.call();
Python SDK
GetDataVolumeAttachableVmAction action = GetDataVolumeAttachableVmAction() action.volumeUuid = "212352bd2dc64bb6b42d052ba7b55c8f" action.sessionId = "bc975e8c54764903857ddf7e22a8fa88" GetDataVolumeAttachableVmAction.Result res = action.call()
Parent topic: 云盘相关接口
挂载云盘到云主机上(AttachDataVolumeToVm)
API请求
URLs
POST zstack/v1/volumes/{volumeUuid}/vm-instances/{vmInstanceUuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST http://localhost:8080/zstack/v1/volumes/6fdcff5868fe376a98359eba8b3d0efe/vm-instances/f6abc3b26ffe337ba61dd7298fb0b9df
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |volumeUuid|String|url|云盘UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "4c118c4e51e54f839e6e0af9e17527f2", "name": "test-volume", "primaryStorageUuid": "9cd9e87803864fa1ae6cf4001fb5d4c8", "vmInstanceUuid": "8a6f516d0da04addb062c903dd000830", "diskOfferingUuid": "bdb5f71d810c49a08ff0e91f81936009", "rootImageUuid": "a12e3048aab340c1b2c6bad2e4187a3a", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-4c118c4e51e54f839e6e0af9e17527f2/4c118c4e51e54f839e6e0af9e17527f2.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:20:35 PM", "lastOpDate": "Jun 7, 2017 9:20:35 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
AttachDataVolumeToVmAction action = new AttachDataVolumeToVmAction(); action.vmInstanceUuid = "255dc5614937406c9a988d9c1786b210"; action.volumeUuid = "1e54148b369b4edeb40fa355d96418f0"; action.sessionId = "f705bc797bc34ebd80690e8f154103d1"; AttachDataVolumeToVmAction.Result res = action.call();
Python SDK
AttachDataVolumeToVmAction action = AttachDataVolumeToVmAction() action.vmInstanceUuid = "ebbc8ec209e54fc3a9872316b4d70bc6" action.volumeUuid = "9451c035198c4e91818a0f47d6fc47c5" action.sessionId = "4f838000320d44daa355120a7adef512" AttachDataVolumeToVmAction.Result res = action.call()
Parent topic: 云盘相关接口
从云主机上卸载云盘(DetachDataVolumeFromVm)
API请求
URLs
DELETE/v1/volumes/{uuid}/vm-instances
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 7e5632146864445d8429d29e51dec0cb" \ -X DELETE http://localhost:8080/zstack/v1/volumes/7beae849715345d7aa8793d1c2942279/vm-instances?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|云盘的UUID,唯一标示该资源| |0.6| |vmUuid (可选)|String|body|云主机的UUID| |0.6| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "eeb5dcf6332e44cb81c190df7e6a68e9", "name": "test-volume", "primaryStorageUuid": "3d51fd1b41a5461ea1fcc7cc216e4db8", "vmInstanceUuid": "e64ebdc324d445d5aad979fc62eb0a0d", "diskOfferingUuid": "1391925279d7436cb6efd5c39c5144d1", "rootImageUuid": "44794b5fec4a4061b533560fbaf458e2", "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-eeb5dcf6332e44cb81c190df7e6a68e9/eeb5dcf6332e44cb81c190df7e6a68e9.qcow2", "type": "Root", "format": "qcow2", "size": 1.073741824E11, "actualSize": 2.147483648E10, "deviceId": 0.0, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:20:31 PM", "lastOpDate": "Jun 7, 2017 9:20:31 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |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| |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|
SDK示例
Java SDK
DetachDataVolumeFromVmAction action = new DetachDataVolumeFromVmAction(); action.uuid = "a25328c5d8664e9bbfb4056561ff273b"; action.vmUuid = "a50e728336b8455e9802785ee6d81959"; action.sessionId = "b7ff5722af3e42f5ab4d0c77b8664f6c"; DetachDataVolumeFromVmAction.Result res = action.call();
Python SDK
DetachDataVolumeFromVmAction action = DetachDataVolumeFromVmAction() action.uuid = "b23d5a96ba19477dacae2429f9f181ef" action.vmUuid = "58ab89b6a8e64a649fc38831ceaa95c8" action.sessionId = "e97c2484efd84e0ba9f2f50a01a41d1a" DetachDataVolumeFromVmAction.Result res = action.call()
Parent topic: 云盘相关接口
从云盘创建快照(CreateVolumeSnapshot)
API请求
URLs
POST zstack/v1/volumes/{volumeUuid}/volume-snapshots
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "snapshot-volume", "description": "a snapshot for volume" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"snapshot-volume","description":"a snapshot for volume"}}' \ http://localhost:8080/zstack/v1/volumes/96971a1cd12f3ebdba54578846992057/volume-snapshots
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |volumeUuid|String|url|云盘UUID| |0.6| |name|String|body(包含在params结构中)|快照名称| |0.6| |description (可选)|String|body(包含在params结构中)|快照的详细描述| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|资源的Uuid| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "ec8f396d8a5d48ce8bd949d469c0be62", "name": "Snapshot-1", "description": "create-snapshot-from-volume", "type": "Hypervisor", "volumeUuid": "e60a0fb0b75743c1b0fcb017e31db043", "treeUuid": "b5cf59580ef443c4b7106cf755e6c572", "parentUuid": "cc0e37297d76486186f0dd2b61ddf4e2", "primaryStorageUuid": "82280d3f2f01482bbcdfee03599bcad5", "primaryStorageInstallPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-e60a0fb0b75743c1b0fcb017e31db043/snapshots/ec8f396d8a5d48ce8bd949d469c0be62.qcow2", "volumeType": "Root", "format": "qcow2", "latest": true, "size": 1.073741824E9, "state": "Enabled", "status": "Ready", "createDate": "Jun 7, 2017 9:20:17 PM", "lastOpDate": "Jun 7, 2017 9:20:17 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeSnapshotInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |type|String| |0.6| |volumeUuid|String|云盘UUID|0.6| |treeUuid|String| |0.6| |parentUuid|String| |0.6| |primaryStorageUuid|String|主存储UUID|0.6| |primaryStorageInstallPath|String| |0.6| |volumeType|String| |0.6| |format|String| |0.6| |latest|Boolean| |0.6| |size|Long| |0.6| |state|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |volumeSnapshotUuid|String|云盘快照UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6|
SDK示例
Java SDK
CreateVolumeSnapshotAction action = new CreateVolumeSnapshotAction(); action.volumeUuid = "093310638cef494088eac315cf1ff1b1"; action.name = "snapshot-volume"; action.description = "a snapshot for volume"; action.sessionId = "6020beb6826b4bb5a980965b435b2998"; CreateVolumeSnapshotAction.Result res = action.call();
Python SDK
CreateVolumeSnapshotAction action = CreateVolumeSnapshotAction() action.volumeUuid = "5321658e475a4a8d9e41eef1186a079b" action.name = "snapshot-volume" action.description = "a snapshot for volume" action.sessionId = "aad13372afb149918537613c50c3f49b" CreateVolumeSnapshotAction.Result res = action.call()
Parent topic: 云盘相关接口
查询云盘快照(QueryVolumeSnapshot)
API请求
URLs
GET zstack/v1/volume-snapshots GET zstack/v1/volume-snapshots/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 7f983595cc744a14bb0fc9bfdd712e39" \ -X GET http://localhost:8080/zstack/v1/volume-snapshots?q=uuid=a3da945723d44971afded91bf3ebfd4d
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 90e4d7e2760e4f1893b78be27095bb9e" \ -X GET http://localhost:8080/zstack/v1/volume-snapshots/d8713ee3864442de8afc6cd614f51921
可查询字段
运行zstack-cli命令行工具,输入QueryVolumeSnapshot
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{ "inventories": [ { "uuid": "492ebccdeb804e308361b08e4f0e9a7a", "name": "My Snapshot 2", "primaryStorageUuid": "/zstack_ps/rootVolumes/acct-e77f16d460ea46e18262547b56972273/vol-13c66bb52d0949398e520183b917f813/snapshots/2fa6979af5c6479fa98f37d316f44b5f.qcow2", "volumeType": "Root", "format": "qcow2", "latest": false, "size": 1310720.0, "state": "Enabled", "status": "Ready" } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |type|String| |0.6| |volumeUuid|String|云盘UUID|0.6| |treeUuid|String| |0.6| |parentUuid|String| |0.6| |primaryStorageUuid|String|主存储UUID|0.6| |primaryStorageInstallPath|String| |0.6| |volumeType|String| |0.6| |format|String| |0.6| |latest|Boolean| |0.6| |size|Long| |0.6| |state|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |volumeSnapshotUuid|String|云盘快照UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6|
SDK示例
Java SDK
QueryVolumeSnapshotAction action = new QueryVolumeSnapshotAction(); action.conditions = asList("uuid=d8722eb3601448dcbbd9f4b5a93ceb0e"); action.sessionId = "007c535099cc4f2eaab878d021a9d89a"; QueryVolumeSnapshotAction.Result res = action.call();
Python SDK
QueryVolumeSnapshotAction action = QueryVolumeSnapshotAction() action.conditions = ["uuid=b64521c0da3a462da02687c4bee1a646"] action.sessionId = "ecd0d0d0ccbc4be9a2c42a7d7b05d924" QueryVolumeSnapshotAction.Result res = action.call()
Parent topic: 云盘相关接口
查询快照树(QueryVolumeSnapshotTree)
API请求
URLs
GET zstack/v1/volume-snapshots/trees GET zstack/v1/volume-snapshots/trees/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 6765993e28b6428fa5715c69c93962b2" \ -X GET http://localhost:8080/zstack/v1/volume-snapshots/trees?q=uuid=5ef4209325014bee8b2609e5f2fa3857
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 31697ae56f274658a261b666089f3891" \ -X GET http://localhost:8080/zstack/v1/volume-snapshots/trees/60a48ac22a474922bd4e18f4a16cff6d
可查询字段
运行zstack-cli命令行工具,输入QueryVolumeSnapshotTree
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
QueryVolumeSnapshotTreeAction action = new QueryVolumeSnapshotTreeAction(); action.conditions = asList("uuid=f8b757fa8d354157aa83712be91c391c"); action.sessionId = "5a9d257d977543efb617d3a4619e9e10"; QueryVolumeSnapshotTreeAction.Result res = action.call();
Python SDK
QueryVolumeSnapshotTreeAction action = QueryVolumeSnapshotTreeAction() action.conditions = ["uuid=e7a8480f474e42aeabb8e9a5c74b2c3b"] action.sessionId = "43ac6f171e87458096fda52a497a21b2" QueryVolumeSnapshotTreeAction.Result res = action.call()
Parent topic: 云盘相关接口
更新云盘快照信息(UpdateVolumeSnapshot)
API请求
URLs
PUT zstack/v1/volume-snapshots/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "updateVolumeSnapshot": { "name": "My Snapshot" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"updateVolumeSnapshot":{"name":"My Snapshot"}}' \ http://localhost:8080/zstack/v1/volume-snapshots/df56acfb356130869fc80dbf80cf3172/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|快照的UUID,唯一标示该资源| |0.6| |name (可选)|String|body(包含在updateVolumeSnapshot结构中)|快照的新名称| |0.6| |description (可选)|String|body(包含在updateVolumeSnapshot结构中)|快照的新详细描述| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "a50e9be4b0eb492aa1cbb767e38ee45e", "name": "My Snapshot 2", "primaryStorageUuid": "/zstack_ps/rootVolumes/acct-e77f16d460ea46e18262547b56972273/vol-13c66bb52d0949398e520183b917f813/snapshots/2fa6979af5c6479fa98f37d316f44b5f.qcow2", "volumeType": "Root", "format": "qcow2", "latest": false, "size": 1310720.0, "state": "Enabled", "status": "Ready" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|VolumeSnapshotInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |type|String| |0.6| |volumeUuid|String|云盘UUID|0.6| |treeUuid|String| |0.6| |parentUuid|String| |0.6| |primaryStorageUuid|String|主存储UUID|0.6| |primaryStorageInstallPath|String| |0.6| |volumeType|String| |0.6| |format|String| |0.6| |latest|Boolean| |0.6| |size|Long| |0.6| |state|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |volumeSnapshotUuid|String|云盘快照UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6|
SDK示例
Java SDK
UpdateVolumeSnapshotAction action = new UpdateVolumeSnapshotAction(); action.uuid = "b4eadb8d20cc41e8a575c82553ec912c"; action.name = "My Snapshot"; action.sessionId = "94fb0621bb4647bb989864c845c6c22e"; UpdateVolumeSnapshotAction.Result res = action.call();
Python SDK
UpdateVolumeSnapshotAction action = UpdateVolumeSnapshotAction() action.uuid = "e6ded156a6f440889b258d0738c517b4" action.name = "My Snapshot" action.sessionId = "36d4adc78a9d4c73b141095efa8c78bc" UpdateVolumeSnapshotAction.Result res = action.call()
Parent topic: 云盘相关接口
删除云盘快照(DeleteVolumeSnapshot)
API请求
URLs
DELETE zstack/v1/volume-snapshots/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 3c050c50069f4dd48ac242bfecd8e510" \ -X DELETE http://localhost:8080/zstack/v1/volume-snapshots/8aed13fa10114a50b227b2adf17ddba1?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |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返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteVolumeSnapshotAction action = new DeleteVolumeSnapshotAction(); action.uuid = "ce68d5c274274e4e8d9ce817ef88125b"; action.deleteMode = "Permissive"; action.sessionId = "8118879be81944ceb1342b9fbc8d1eda"; DeleteVolumeSnapshotAction.Result res = action.call();
Python SDK
DeleteVolumeSnapshotAction action = DeleteVolumeSnapshotAction() action.uuid = "0665f04d54a54ab78b41f261b04a99fb" action.deleteMode = "Permissive" action.sessionId = "4764b21ec49848bfba76b2da27a0fe91" DeleteVolumeSnapshotAction.Result res = action.call()
Parent topic: 云盘相关接口
创建快照的定时任务(CreateVolumeSnapshotScheduler)
API请求
URLs
POST zstack/v1/volumes/{volumeUuid}/schedulers/creating-volume-snapshots
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "snapShotName": "test-snapshot-scheduler", "schedulerName": "snapshot-scheduler", "schedulerDescription": "for test snapshot scheduler", "type": "simple", "interval": 5.0, "repeatCount": 10.0, "startTime": 0.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 08c65269bb504c129cd00204624da38d" \ -X POST http://localhost:8080/zstack/v1/volumes/4d63dbc47a474ccbb6fcc7be6ba85ea0/schedulers/creating-volume-snapshots?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |volumeUuid|String|url|云盘UUID| |0.6| |snapShotName|String|body(包含在params结构中)|定时任务名称| |0.6| |volumeSnapshotDescription (可选)|String|body(包含在params结构中)|对定时创建的快照描述| |0.6| |schedulerName|String|body(包含在params结构中)|定时任务名称| |0.6| |schedulerDescription (可选)|String|body(包含在params结构中)|定时任务描述| |0.6| |type|String|body(包含在params结构中)|定时任务类型,支持simple和cron两种类型| - simple - cron
|0.6| |interval (可选)|Integer|body(包含在params结构中)|定时任务间隔,单位秒| |0.6| |repeatCount (可选)|Integer|body(包含在params结构中)|定时任务重复次数,仅针对simple类型的定时任务生效| |0.6| |startTime (可选)|Long|body(包含在params结构中)|定时任务启动时间,必须遵循unix timestamp格式,0为从立刻开始| |0.6| |cron (可选)|String|body(包含在params结构中)|cron表达式,需遵循Java Quartz组件cron格式标准| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|用户可指定创建Scheduler所使用的uuid| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "ed2d61e359b943d3bbf459989064cf82", "targetResourceUuid": "71966b05ec5142689438e5ec5e70c2a1", "schedulerName": "Test", "schedulerType": "simple", "repeatCount": 10.0, "startTime": "Jun 7, 2017 9:20:20 PM", "createDate": "Jun 7, 2017 9:20:20 PM", "lastOpDate": "Jun 7, 2017 9:20:20 PM", "jobClassName": "CreateVolumeSnapshotJob", "state": "Enabled" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|1.6| |inventory|SchedulerInventory|详情参考inventory|1.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |targetResourceUuid|String| |0.6| |schedulerName|String| |0.6| |schedulerJob|String| |0.6| |schedulerType|String| |0.6| |schedulerInterval|Integer| |0.6| |repeatCount|Integer| |0.6| |cronScheduler|String| |0.6| |startTime|Timestamp| |0.6| |stopTime|Timestamp| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String| |0.6|
SDK示例
Java SDK
CreateVolumeSnapshotSchedulerAction action = new CreateVolumeSnapshotSchedulerAction(); action.volumeUuid = "840ffda920fc4cbdb847da88d407ff4a"; action.snapShotName = "test-snapshot-scheduler"; action.schedulerName = "snapshot-scheduler"; action.schedulerDescription = "for test snapshot scheduler"; action.type = "simple"; action.interval = 5.0; action.repeatCount = 10.0; action.startTime = 0.0; action.sessionId = "12eac6c7764c43c98f1e6eeb63ddb207"; CreateVolumeSnapshotSchedulerAction.Result res = action.call();
Python SDK
CreateVolumeSnapshotSchedulerAction action = CreateVolumeSnapshotSchedulerAction() action.volumeUuid = "1c3bfa7308164db8add88fcc80b42e31" action.snapShotName = "test-snapshot-scheduler" action.schedulerName = "snapshot-scheduler" action.schedulerDescription = "for test snapshot scheduler" action.type = "simple" action.interval = 5.0 action.repeatCount = 10.0 action.startTime = 0.0 action.sessionId = "faa9b478f38040cf9f9151a46daf6fa8" CreateVolumeSnapshotSchedulerAction.Result res = action.call()
Parent topic: 云盘相关接口
将云盘回滚至指定快照(RevertVolumeFromSnapshot)
API请求
URLs
PUT zstack/v1/volume-snapshots/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "revertVolumeFromSnapshot": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"revertVolumeFromSnapshot":{}}' \ http://localhost:8080/zstack/v1/volume-snapshots/eba17ed729a03a76afb168cf41373daf/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|快照的UUID,唯一标示该资源| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
RevertVolumeFromSnapshotAction action = new RevertVolumeFromSnapshotAction(); action.uuid = "34a3c300041249d098187c2120ab0097"; action.sessionId = "a5e0822600934b84ba8bb8fa0af5bce0"; RevertVolumeFromSnapshotAction.Result res = action.call();
Python SDK
RevertVolumeFromSnapshotAction action = RevertVolumeFromSnapshotAction() action.uuid = "f3728a6d5e324c41a98b12c067db105b" action.sessionId = "63799306e40e486c94d31dc2fcbbee6a" RevertVolumeFromSnapshotAction.Result res = action.call()
Parent topic: 云盘相关接口
镜像相关接口
添加镜像(AddImage)
向镜像服务器添加镜像。
API请求
URLs
POST zstack/v1/images
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "TinyLinux", "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "system": false, "format": "qcow2", "platform": "Linux", "backupStorageUuids": [ "c340364aad7b4130a12e641afe3a968f" ] }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"TinyLinux","url":"http://192.168.1.20/share/images/tinylinux.qcow2","mediaType":"RootVolumeTemplate","system":false,"format":"qcow2","platform":"Linux","backupStorageUuids":["b8fc9c1c027438c28d36af24eca06595"]}}' \ http://localhost:8080/zstack/v1/images
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|镜像名称| |0.6| |description (可选)|String|body(包含在params结构中)|镜像的详细描述| |0.6| |url|String|body(包含在params结构中)|被添加镜像的URL地址| |0.6| |mediaType (可选)|String|body(包含在params结构中)|镜像的类型| - RootVolumeTemplate - ISO - DataVolumeTemplate
|0.6| |guestOsType (可选)|String|body(包含在params结构中)|镜像对应客户机操作系统的类型| |0.6| |system (可选)|boolean|body(包含在params结构中)|是否系统镜像(如,云路由镜像)| |0.6| |format|String|body(包含在params结构中)|镜像的格式,比如:raw| |0.6| |platform (可选)|String|body(包含在params结构中)|镜像的系统平台| - Linux - Windows - WindowsVirtio - Other - Paravirtualization
|0.6| |backupStorageUuids|List|body(包含在params结构中)|指定添加镜像的镜像服务器UUID列表| |0.6| |type (可选)|String|body(包含在params结构中)|内部使用字段| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|资源UUID。若指定,镜像会使用该字段值作为UUID。| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "8c63603a810a4838a4cd62228e6e13b2", "name": "TinyLinux", "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "qcow2", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "8c63603a810a4838a4cd62228e6e13b2", "backupStorageUuid": "06ccc8e0322a4cd3ae5555d9d88451de", "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
AddImageAction action = new AddImageAction(); action.name = "TinyLinux"; action.url = "http://192.168.1.20/share/images/tinylinux.qcow2"; action.mediaType = "RootVolumeTemplate"; action.system = false; action.format = "qcow2"; action.platform = "Linux"; action.backupStorageUuids = asList("93bb676bfdaf466595da28fa4e4bfadb"); action.sessionId = "363c0781f96944708e5b9d9679299c71"; AddImageAction.Result res = action.call();
Python SDK
AddImageAction action = AddImageAction() action.name = "TinyLinux" action.url = "http://192.168.1.20/share/images/tinylinux.qcow2" action.mediaType = "RootVolumeTemplate" action.system = false action.format = "qcow2" action.platform = "Linux" action.backupStorageUuids = [82cf390987674fe09c05c87720815e00] action.sessionId = "180d52fb2f2146c8a522d723b9ae1cf7" AddImageAction.Result res = action.call()
Parent topic: 镜像相关接口
删除镜像(DeleteImage)
API请求
URLs
DELETE zstack/v1/images/{uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "backupStorageUuids": [ "2499cd48fc33450a8737efff67ccb920" ], "deleteMode": "Permissive" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth fb8be86094544022ad3e3abd0027b420" \ -X DELETE http://localhost:8080/zstack/v1/images/f92e888c970c4f739d91e59f6dd94b1e?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|镜像的UUID,唯一标示该镜像| |0.6| |backupStorageUuids (可选)|List|body(包含在params结构中)|镜像服务器UUID列表| |0.6| |deleteMode (可选)|String|body(包含在params结构中)|删除模式(Permissive 或者 Enforcing, 默认 Permissive)| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteImageAction action = new DeleteImageAction(); action.uuid = "22850dff70934ffdaa839a950cb5a470"; action.backupStorageUuids = asList("32974c8955cd4ed79d13458e41490883"); action.deleteMode = "Permissive"; action.sessionId = "517a458b87ca49cf80bf26e6000bc611"; DeleteImageAction.Result res = action.call();
Python SDK
DeleteImageAction action = DeleteImageAction() action.uuid = "5bbd892e048b48b283e5d2f49a6a4e94" action.backupStorageUuids = [fd127191bf504e3daf5292800c1ea2d8] action.deleteMode = "Permissive" action.sessionId = "cf5cf2689379496aaa4449fd14dc8330" DeleteImageAction.Result res = action.call()
Parent topic: 镜像相关接口
彻底删除镜像(ExpungeImage)
API请求
URLs
PUT zstack/v1/images/{imageUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "backupStorageUuids": [ "ef3843bdde80427e9c8c0d4f05aa5cde" ] }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"expungeImage":{"backupStorageUuids":["3be136c8d8b8323bb94b8464aae4b0a7"]}}' \ http://localhost:8080/zstack/v1/images/4dcddfadcd113b5f89f181c4f4a080c7/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |imageUuid|String|url|镜像UUID| |0.6| |backupStorageUuids (可选)|List|body(包含在params结构中)|镜像服务器UUID列表| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
ExpungeImageAction action = new ExpungeImageAction(); action.imageUuid = "ddb63556ae714ee78bf468d5067beedd"; action.backupStorageUuids = asList("6f21a1307fb24117a25ed907c00a3e47"); action.sessionId = "b12c879167d3459a844b6ac1f8ff3b74"; ExpungeImageAction.Result res = action.call();
Python SDK
ExpungeImageAction action = ExpungeImageAction() action.imageUuid = "59fcc3775336469facfd93c5c16bdb2d" action.backupStorageUuids = [2dfcf2dfadb14022ac09172a82fb3aac] action.sessionId = "11fe68c420514cb0a8d8e1d1c5755d11" ExpungeImageAction.Result res = action.call()
Parent topic: 镜像相关接口
查询镜像(QueryImage)
API请求
URLs
GET zstack/v1/images GET zstack/v1/images/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth ecf1dc42b51d4c7c8f814bd10ac0ba79" \ -X GET http://localhost:8080/zstack/v1/images?q=uuid=0538611eb03a48e0bbcfd08e528f0aa1
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 69e2477d74ae4b53a19b21ee6e88f9da" \ -X GET http://localhost:8080/zstack/v1/images/21897673f8274d319c4aeba92e8e4c73
可查询字段
运行zstack-cli命令行工具,输入QueryImage
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{ "inventories": [ { "actualSize": 7995392, "backupStorageRefs": [ { "backupStorageUuid": "bbc730b63081460198c1c7cb63025255", "createDate": "Mar 10, 2018 2:35:09 PM", "imageUuid": "2402b660b6f1582bb65246597b2f47f2", "installPath": "zstore://2402b660b6f1582bb65246597b2f47f2/2ab567b512cc696f2207cf0e3260baa4982e1c02", "lastOpDate": "Mar 10, 2018 2:35:09 PM", "status": "Ready" } ], "createDate": "Mar 10, 2018 2:35:09 PM", "description": "", "format": "qcow2", "lastOpDate": "Mar 10, 2018 2:35:10 PM", "md5Sum": "f0fde821df71aaec63063bef1fb0a46a231e5a3fbb37ed5671eabee7563eb3f8", "mediaType": "RootVolumeTemplate", "name": "Image-1", "platform": "Linux", "size": 12682240, "state": "Enabled", "status": "Ready", "system": false, "type": "zstack", "url": "file:///opt/zstack-dvd/zstack-image-1.4.qcow2", "uuid": "2402b660b6f1582bb65246597b2f47f2" } ], "success": true }
SDK示例
Java SDK
QueryImageAction action = new QueryImageAction(); action.conditions = asList("uuid=02928c0d94a847b0b785bc9830f931c6"); action.sessionId = "512102357b3e44c7a1704240176c8661"; QueryImageAction.Result res = action.call();
Python SDK
QueryImageAction action = QueryImageAction() action.conditions = ["uuid=4d4b95071b09499e9e15a206714d1586"] action.sessionId = "893c8fe44f5b4b799b095c54ee7ae075" QueryImageAction.Result res = action.call()
Parent topic: 镜像相关接口
恢复镜像(RecoverImage)
恢复被删除(但未彻底删除)的镜像。
API请求
URLs
PUT zstack/v1/images/{imageUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "backupStorageUuids": [ "b63989ade2194ce8b8f1823083395681" ] }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 5ab0e924388a44d7aa96b9e7df9d8df3" \ -X PUT -d '{"recoverImage":{"backupStorageUuids":["29849ef8f0fe3abeb8fff5e6d947d002"]}}' \ http://localhost:8080/zstack/v1/images/e55bb56eee93338cad8d7d1048a6b0c3/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |imageUuid|String|url|镜像UUID| |0.6| |backupStorageUuids (可选)|List|body(包含在params结构中)|镜像服务器UUID列表| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "c019173f2b5742868058049be43033a1", "name": "TinyLinux", "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "qcow2", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "c019173f2b5742868058049be43033a1", "backupStorageUuid": "609d29fb59ee414f90cedbc3a71038c6", "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
RecoverImageAction action = new RecoverImageAction(); action.imageUuid = "3220b5ea2ae24883a4eb847634e3e349"; action.backupStorageUuids = asList("ad4dcd853b894362bfd18c06779ed758"); action.sessionId = "66ba41da8526424d9ab70ed0072b8d22"; RecoverImageAction.Result res = action.call();
Python SDK
RecoverImageAction action = RecoverImageAction() action.imageUuid = "7f8bb365b8d3413ab5d09f6d381552c3" action.backupStorageUuids = [14d99a1ade5a431ea254902c808d7319] action.sessionId = "044d56deddd849a092ff02ae54386cf1" RecoverImageAction.Result res = action.call()
Parent topic: 镜像相关接口
修改镜像状态(ChangeImageState)
API请求
URLs
PUT zstack/v1/images/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "stateEvent": "disable" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"changeImageState":{"stateEvent":"disable"}}' \ http://localhost:8080/zstack/v1/images/5a4e7e1f1a653505925da09d0a64936b/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|镜像的UUID,唯一标示该镜像| |0.6| |stateEvent|String|body(包含在params结构中)|镜像的状态| - enable - disable
|0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "e4891e6ef3a64ea08ce91ab379a5c856", "name": "TinyLinux", "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "qcow2", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "e4891e6ef3a64ea08ce91ab379a5c856", "backupStorageUuid": "8bf8f2f17e7c4cca8d684ae5d89eee9e", "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
ChangeImageStateAction action = new ChangeImageStateAction(); action.uuid = "d6d3cf3feace41ae9fe519fcfdf337e1"; action.stateEvent = "disable"; action.sessionId = "e510317dfbf64f7c9423652cefba6583"; ChangeImageStateAction.Result res = action.call();
Python SDK
ChangeImageStateAction action = ChangeImageStateAction() action.uuid = "d33d29f7695a4376a9a37a094f89d9f2" action.stateEvent = "disable" action.sessionId = "ae3587d0cbf844c2921a97798d4dc37b" ChangeImageStateAction.Result res = action.call()
Parent topic: 镜像相关接口
更新镜像信息(UpdateImage)
API请求
URLs
PUT zstack/v1/images/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "platform": "Windows" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth d65a4f9a1ebb47ba8096fe2907ac9573" \ -X PUT -d '{"updateImage":{"platform":"Windows"}}' \ http://localhost:8080/zstack/v1/images/38549d5d5a3d3c5caefc18d8a9e0aa13/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|镜像的UUID,唯一标示该镜像| |0.6| |name (可选)|String|body(包含在params结构中)|镜像名称| |0.6| |description (可选)|String|body(包含在params结构中)|镜像的详细描述| |0.6| |guestOsType (可选)|String|body(包含在params结构中)|镜像对应的客户机操作系统类型| |0.6| |mediaType (可选)|String|body(包含在params结构中)|镜像的类型| - RootVolumeTemplate - DataVolumeTemplate - ISO
|0.6| |format (可选)|String|body(包含在params结构中)|镜像的格式| - raw - qcow2 - iso
|0.6| |system (可选)|Boolean|body(包含在params结构中)|标识是否为系统镜像| |0.6| |platform (可选)|String|body(包含在params结构中)|镜像的系统平台| - Linux - Windows - WindowsVirtio - Other - Paravirtualization
|0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "d5ca308361114717afd4be8a37dfab04", "name": "TinyLinux", "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "platform": "Windows", "format": "qcow2", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "d5ca308361114717afd4be8a37dfab04", "backupStorageUuid": "4e647183fb654deba813abccda78ba46", "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
UpdateImageAction action = new UpdateImageAction(); action.uuid = "c6acc2794b7041c6a85337be4ebd17f0"; action.platform = "Windows"; action.sessionId = "977f2b55bc8c4d9188c7cc2393537bb5"; UpdateImageAction.Result res = action.call();
Python SDK
UpdateImageAction action = UpdateImageAction() action.uuid = "6489ec9973064194a0eefff21d9abd60" action.platform = "Windows" action.sessionId = "4f116a43a544444aade62ce76310c551" UpdateImageAction.Result res = action.call()
Parent topic: 镜像相关接口
刷新镜像大小信息(SyncImageSize)
API请求
URLs
PUT zstack/v1/images/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "syncImageSize": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 3a29210c52824730884918d670745453" \ -X PUT -d '{"syncImageSize":{}}' \ http://localhost:8080/zstack/v1/images/7d0fb69a716330bba16a3ee557ee0ab2/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|镜像的UUID,唯一标示该镜像| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "a5288a2598074daabb0450db1eaf0e69", "name": "TinyLinux", "size": 2.097152E8, "actualSize": 2329057.0, "url": "http://192.168.1.20/share/images/tinylinux.qcow2", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "qcow2", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "a5288a2598074daabb0450db1eaf0e69", "backupStorageUuid": "1a917c0b47c6475a996ed678f230419d", "installPath": "ceph://zs-images/f0b149e053b34c7eb7fe694b182ebffd", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
SyncImageSizeAction action = new SyncImageSizeAction(); action.uuid = "46638764dfcb47b2bf916bce60d50f9f"; action.sessionId = "557e2989aa7d4178861c4fcacb85e40c"; SyncImageSizeAction.Result res = action.call();
Python SDK
SyncImageSizeAction action = SyncImageSizeAction() action.uuid = "0073e30d1fd84cd0b47896e5bb22b205" action.sessionId = "e6896c8311824d718e330908ec04d9a6" SyncImageSizeAction.Result res = action.call()
Parent topic: 镜像相关接口
获取镜像服务器候选(GetCandidateBackupStorageForCreatingImage)
获取创建镜像的镜像服务器候选。
API请求
URLs
GET zstack/v1/images/volumes/{volumeUuid}/candidate-backup-storage GET zstack/v1/images/volume-snapshots/{volumeSnapshotUuid}/candidate-backup-storage
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 146b6ded7a9744068ba57b87ca1bd0c0" \ -X GET http://localhost:8080/zstack/v1/images/volumes/1e816db3824f489a944f1f6c6beb83cc/candidate-backup-storage?\ volumeUuid=1e816db3824f489a944f1f6c6beb83cc&volumeSnapshotUuid=223f7f53ce544036a916a73116a484f8
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth dcd0948b7a90449ba8b09270ad3041d2" \ -X GET http://localhost:8080/zstack/v1/images/volume-snapshots/98fcb829c80a4b08b700fb3e43c2d8ce/candidate-backup-storage?\ volumeUuid=17d1d7becabf4800937b23d2f505a56d&volumeSnapshotUuid=98fcb829c80a4b08b700fb3e43c2d8ce
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |volumeUuid (可选)|String|query|云盘UUID| |0.6| |volumeSnapshotUuid (可选)|String|query|云盘快照UUID| |0.6| |systemTags (可选)|List|query|系统标签| |0.6| |userTags (可选)|List|query|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
GetCandidateBackupStorageForCreatingImageAction action = new GetCandidateBackupStorageForCreatingImageAction(); action.volumeUuid = "77e77779b5f94617af0a8b08b4a50129"; action.volumeSnapshotUuid = "4a5220b5b1f044f8826520eb506d0f98"; action.sessionId = "45b0a87571c2476ba2fe6623daaa79cf"; GetCandidateBackupStorageForCreatingImageAction.Result res = action.call();
Python SDK
GetCandidateBackupStorageForCreatingImageAction action = GetCandidateBackupStorageForCreatingImageAction() action.volumeUuid = "83792660358b4e14b266c5d0920b8b21" action.volumeSnapshotUuid = "3d562e4325cc42ce8bd3115b48f79ae4" action.sessionId = "2ba3d333ac284a20adc782766f597330" GetCandidateBackupStorageForCreatingImageAction.Result res = action.call()
Parent topic: 镜像相关接口
从根云盘创建根云盘镜像(CreateRootVolumeTemplateFromRootVolume)
API请求
URLs
POST zstack/v1/images/root-volume-templates/from/volumes/{rootVolumeUuid}
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "My Root Volume Template", "backupStorageUuids": [ "e67b9791a8204b31842c3b36457ce56c" ], "platform": "Linux", "system": false }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"My Root Volume Template","backupStorageUuids":["a3cb55d45fb63d1da4911b9d16273a55"],"platform":"Linux","system":false}}' \ http://localhost:8080/zstack/v1/images/root-volume-templates/from/volumes/3bfc6f9eaf243299b8515382310be47b
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|根云盘镜像名称| |0.6| |description (可选)|String|body(包含在params结构中)|根云盘镜像的详细描述| |0.6| |guestOsType (可选)|String|body(包含在params结构中)|根云盘镜像对应客户机操作系统类型| |0.6| |backupStorageUuids (可选)|List|body(包含在params结构中)|镜像服务器UUID列表| |0.6| |rootVolumeUuid|String|body(包含在params结构中)|根云盘UUID| |0.6| |platform (可选)|String|body(包含在params结构中)|根云盘镜像对应的系统平台| - Linux - Windows - WindowsVirtio - Other - Paravirtualization
|0.6| |system (可选)|boolean|body(包含在params结构中)|是否系统根云盘镜像| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|根云盘镜像UUID。若指定,根云盘镜像会使用该字段值作为UUID。| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "1411ab3a70b5418784e529d74510af5d", "name": "My Root Volume Template", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "raw", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "1411ab3a70b5418784e529d74510af5d", "backupStorageUuid": "32a3978a6da0412fbdd4c9b487637f9b", "installPath": "ceph://zs-images/0cd599ec519249489475112a058bb93a", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
CreateRootVolumeTemplateFromRootVolumeAction action = new CreateRootVolumeTemplateFromRootVolumeAction(); action.name = "My Root Volume Template"; action.backupStorageUuids = asList("76fc4abc5650483fa1b2028fcd6ac64d"); action.rootVolumeUuid = "f368c5b20a0a4ab08ffe4e94f535ffb5"; action.platform = "Linux"; action.system = false; action.sessionId = "50f84f52a23342a4aab43f2288a187dc"; CreateRootVolumeTemplateFromRootVolumeAction.Result res = action.call();
Python SDK
CreateRootVolumeTemplateFromRootVolumeAction action = CreateRootVolumeTemplateFromRootVolumeAction() action.name = "My Root Volume Template" action.backupStorageUuids = [f9dc4b8cc4254836ae46713b88e1e763] action.rootVolumeUuid = "c89cf9d298084680a0240b49015806a6" action.platform = "Linux" action.system = false action.sessionId = "ca2d794d080a4686adf31758d82926c8" CreateRootVolumeTemplateFromRootVolumeAction.Result res = action.call()
Parent topic: 镜像相关接口
创建根云盘镜像(CreateRootVolumeTemplateFromVolumeSnapshot)
从云盘快照创建根云盘镜像。
API请求
URLs
POST zstack/v1/images/root-volume-templates/from/volume-snapshots/{snapshotUuid}
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "My Root Volume Template", "backupStorageUuids": [ "0d793ede7b47471cbd53eb38ce890e79" ], "system": false }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"My Root Volume Template","backupStorageUuids":["41a9753ebf8031ef83b41ebed095b783"],"system":false}}' \ http://localhost:8080/zstack/v1/images/root-volume-templates/from/volume-snapshots/f31fda67d1be32998cef3f3d9a280e1c
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |snapshotUuid|String|url|快照UUID| |0.6| |name|String|body(包含在params结构中)|根云盘镜像名称| |0.6| |description (可选)|String|body(包含在params
结构中)|根云盘镜像的详细描述| |0.6| |guestOsType (可选)|String|body(包含在params
结构中)|根云盘客户机操作系统类型| |0.6| |backupStorageUuids|List|body(包含在params
结构中)|镜像服务器UUID列表| |0.6| |platform (可选)|String|body(包含在params
结构中)|根云盘镜像对应的系统平台| - Linux - Windows - WindowsVirtio - Other - Paravirtualization
|0.6| |system (可选)|boolean|body(包含在params
结构中)|是否系统根云盘镜像| |0.6| |resourceUuid (可选)|String|body(包含在params
结构中)|根云盘镜像UUID。若指定,根云盘镜像会使用该字段值作为UUID。| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "200e14e0f67d4b7a87fbaa6821c3a250", "name": "My Root Volume Template", "mediaType": "RootVolumeTemplate", "platform": "Linux", "format": "raw", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "200e14e0f67d4b7a87fbaa6821c3a250", "backupStorageUuid": "9b24855411df4652a521ca4d1d4e86f2", "installPath": "ceph://zs-images/0cd599ec519249489475112a058bb93a", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6| |failures|List|详情参考failures|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
#failures
|名字|类型|描述|起始版本| |--|--|--|----| |backupStorageUuid|String|镜像存储UUID|0.6| |error|ErrorCode|详情参考error|0.6|
SDK示例
Java SDK
CreateRootVolumeTemplateFromVolumeSnapshotAction action = new CreateRootVolumeTemplateFromVolumeSnapshotAction(); action.snapshotUuid = "5d10e4111e0c44f58ee13d3584110c8d"; action.name = "My Root Volume Template"; action.backupStorageUuids = asList("49a984343c554f6aa9cac7b038494f5d"); action.system = false; action.sessionId = "bac023f582c24fc9af1097392ce1d12b"; CreateRootVolumeTemplateFromVolumeSnapshotAction.Result res = action.call();
Python SDK
CreateRootVolumeTemplateFromVolumeSnapshotAction action = CreateRootVolumeTemplateFromVolumeSnapshotAction() action.snapshotUuid = "6dd726f9727a4358ab2aaf8cdd4675d3" action.name = "My Root Volume Template" action.backupStorageUuids = [c653cb53d5154a48b53d95a36e7dbae6] action.system = false action.sessionId = "edd92cba4301455fb15532b8bbf43459" CreateRootVolumeTemplateFromVolumeSnapshotAction.Result res = action.call()
Parent topic: 镜像相关接口
从云盘创建数据云盘镜像(CreateDataVolumeTemplateFromVolume)
API请求
URLs
POST zstack/v1/images/data-volume-templates/from/volumes/{volumeUuid}
Hearders
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "My Data Volume Template", "backupStorageUuids": [ "7fd08286addc4b388fac61935892acd7" ] }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"My Data Volume Template","backupStorageUuids":["08e337886b873e8685991d1c7ba4d1ab"]}}' \ http://localhost:8080/zstack/v1/images/data-volume-templates/from/volumes/4c941eb9faeb3976803fce2f3609a475
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|数据云盘镜像名称| |0.6| |description (可选)|String|body(包含在params结构中)|数据云盘镜像的详细描述| |0.6| |volumeUuid|String|body(包含在params结构中)|起始云盘UUID| |0.6| |backupStorageUuids (可选)|List|body(包含在params结构中)|镜像服务器UUID列表| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|数据云盘镜像UUID。若指定,数据云盘镜像会使用该字段值作为UUID。| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "7247cf569e2b4104832071822cf845c5", "name": "My Data Volume Template", "mediaType": "DataVolumeTemplate", "platform": "Linux", "format": "raw", "backupStorageRefs": [ { "id": 0.0, "imageUuid": "7247cf569e2b4104832071822cf845c5", "backupStorageUuid": "1b8ab68b7e224a30aa31f00f1db2b5a6", "installPath": "ceph://zs-data-volume/0cd599ec519249489475112a058bb93a", "status": "Ready" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|ImageInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |exportUrl|String| |0.6| |state|String| |0.6| |status|String| |0.6| |size|Long| |0.6| |actualSize|Long| |0.6| |md5Sum|String| |0.6| |url|String| |0.6| |mediaType|String| |0.6| |guestOsType|String| |0.6| |type|String| |0.6| |platform|String| |0.6| |format|String| |0.6| |system|Boolean| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |backupStorageRefs|List|详情参考backupStorageRefs|0.6|
#backupStorageRefs
|名字|类型|描述|起始版本| |--|--|--|----| |imageUuid|String|镜像UUID|0.6| |backupStorageUuid|String|镜像存储UUID|0.6| |installPath|String| |0.6| |status|String| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6|
SDK示例
Java SDK
CreateDataVolumeTemplateFromVolumeAction action = new CreateDataVolumeTemplateFromVolumeAction(); action.name = "My Data Volume Template"; action.volumeUuid = "816fb7184ae2498189000d7c0fe66112"; action.backupStorageUuids = asList("26b9d22ef1af4bdb880c3d77a8b1feda"); action.sessionId = "c17620d57db14c9383fbdd2650c80a73"; CreateDataVolumeTemplateFromVolumeAction.Result res = action.call();
Python SDK
CreateDataVolumeTemplateFromVolumeAction action = CreateDataVolumeTemplateFromVolumeAction() action.name = "My Data Volume Template" action.volumeUuid = "38b644a29b2d498ebc5b50d1d212d904" action.backupStorageUuids = [1954c35eb0a844d8bb6a64f9963be0f5] action.sessionId = "343ff2f080414010adb1a35957f8b700" CreateDataVolumeTemplateFromVolumeAction.Result res = action.call()
Parent topic: 镜像相关接口
获取镜像Qga(GetImageQga)
API请求
URLs
GET zstack/v1/images/{uuid}/qga
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth e74211f026f741c1898d4377ecf58bd1" \ -X GET http://localhost:8080/zstack/v1/images/34a5bf0cc1014286bd944771c77e1c07/qga
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |systemTags (可选)|List|query| | |0.6| |userTags (可选)|List|query| | |0.6|
API返回
返回示例
{ "enable": false }
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |enable|boolean| |0.6| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6|
#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
GetImageQgaAction action = new GetImageQgaAction(); action.uuid = "0d7b698ccb174702ae5fa7f15bce8612"; action.sessionId = "3e59586b589d4dbeb0afd078bb887655"; GetImageQgaAction.Result res = action.call();
Python SDK
GetImageQgaAction action = GetImageQgaAction() action.uuid = "82a89e52f2c54fab9b73f095e23ddecb" action.sessionId = "fc8ea8bda61143cea7db98957ccd026f" GetImageQgaAction.Result res = action.call()
Parent topic: 镜像相关接口
设置镜像Qga(SetImageQga)
API请求
URLs
PUT zstack/v1/images/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "setImageQga": { "enable": true }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"setImageQga":{"enable":true}}' \ http://localhost:8080/zstack/v1/images/f85a077c64883070ac3ba72079edc804/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |enable|boolean|body(包含在setImageQga结构中)| | |0.6| |systemTags (可选)|List|body| | |0.6| |userTags (可选)|List|body| | |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
SetImageQgaAction action = new SetImageQgaAction(); action.uuid = "0eca41aa133a43d2b8d14958cd3b3f26"; action.enable = true; action.sessionId = "a05d7d13fb514bb5bd16060c7584d6e6"; SetImageQgaAction.Result res = action.call();
Python SDK
SetImageQgaAction action = SetImageQgaAction() action.uuid = "f397649bf07049efb0be7836962d03fe" action.enable = true action.sessionId = "0bfcd0ef201142bcb00ab5903b178da5" SetImageQgaAction.Result res = action.call()
Parent topic: 镜像相关接口
亲和组相关接口
创建亲和组(CreateAffinityGroup)
API请求
URLs
POST zstack/v1/affinity-groups
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "vm-affinity-group", "description": "vm affinity group for test vms", "policy": "antiSoft", "type": "host" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"vm-affinity-group","description":"vm affinity group for test vms","policy":"antiSoft","type":"host"}}' \ http://localhost:8080/zstack/v1/affinity-groups
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|资源名称| |2.3| |description (可选)|String|body(包含在params结构中)|资源的详细描述| |2.3| |policy|String|body(包含在params结构中)|亲和组策略| - antiSoft
|2.3| |type (可选)|String|body(包含在params结构中)|亲和组类型- 目前支持物理机亲和 - 未来将增加网络亲和、路由器亲和、数据中心或机架亲和等多种类型
| - host
|2.3| |resourceUuid (可选)|String|body(包含在params结构中)|资源UUID| |2.3| |systemTags (可选)|List|body|系统标签| |2.3| |userTags (可选)|List|body|用户标签| |2.3|
API返回
返回示例
{ "inventory": { "uuid": "05ad02be7c5f4a6a9b6d164cb2980be6", "name": "affinity-group-test", "description": "affinity group for test", "policy": "ANTISOFT", "version": "1.0", "type": "HOST" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.3| |inventory|AffinityGroupInventory|详情参考inventory|2.3|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.3| |description|String|错误的概要描述|2.3| |details|String|错误的详细信息|2.3| |elaboration|String|保留字段,默认为null|2.3| |opaque|LinkedHashMap|保留字段,默认为null|2.3| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.3|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.3| |name|String|资源名称|2.3| |description|String|资源的详细描述|2.3| |policy|String|亲和组策略|2.3| |version|String|亲和组分配算法的版本|2.3| |type|String|亲和组类型- 当前为物理机亲和 - 未来将增加网络亲和、路由器亲和、数据中心或机架亲和等多种类型
|2.3| |appliance|String|亲和组使用者标识|2.3| |state|String| |2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3| |usages|List|详情参考usages|2.3|
#usages
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|亲和组与资源绑定关系的UUID|2.3| |affinityGroupUuid|String|亲和组UUID|2.3| |resourceUuid|String|加入亲和组的资源UUID|2.3| |resourceType|String|加入亲和组的资源类型|2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3|
SDK示例
Java SDK
CreateAffinityGroupAction action = new CreateAffinityGroupAction(); action.name = "vm-affinity-group"; action.description = "vm affinity group for test vms"; action.policy = "antiSoft"; action.type = "host"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; CreateAffinityGroupAction.Result res = action.call();
Python SDK
CreateAffinityGroupAction action = CreateAffinityGroupAction() action.name = "vm-affinity-group" action.description = "vm affinity group for test vms" action.policy = "antiSoft" action.type = "host" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" CreateAffinityGroupAction.Result res = action.call()
Parent topic: 亲和组相关接口
删除亲和组(DeleteAffinityGroup)
API请求
URLs
DELETE zstack/v1/affinity-groups/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X DELETE http://localhost:8080/zstack/v1/affinity-groups/ed0b2f029cc53ca385adc19dd36b51be?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.2| |deleteMode (可选)|String|body|删除模式| |2.2| |systemTags (可选)|List|body|系统标签| |2.2| |userTags (可选)|List|body|用户标签| |2.2|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteAffinityGroupAction action = new DeleteAffinityGroupAction(); action.uuid = "ed0b2f029cc53ca385adc19dd36b51be"; action.deleteMode = "Permissive"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; DeleteAffinityGroupAction.Result res = action.call();
Python SDK
DeleteAffinityGroupAction action = DeleteAffinityGroupAction() action.uuid = "ed0b2f029cc53ca385adc19dd36b51be" action.deleteMode = "Permissive" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" DeleteAffinityGroupAction.Result res = action.call()
Parent topic: 亲和组相关接口
查询亲和组(QueryAffinityGroup)
API请求
URLs
GET zstack/v1/affinity-groups GET zstack/v1/affinity-groups/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/affinity-groups?q=uuid=656ebc992c3333fea209c6c90e6a76cf
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X GET http://localhost:8080/zstack/v1/affinity-groups/b49759dff8593098a1d106c8129974cf
可查询字段
运行zstack-cli命令行工具,输入QueryAffinityGroup
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{ "inventories": [ { "uuid": "99fa95af4aac4eaabd320dbdd6d36ef8", "name": "affinity-group-test", "description": "affinity group for test", "policy": "ANTISOFT", "version": "1.0", "type": "HOST", "usages": [ { "resourceUuid": "acedd8848c874cd7b1c68df7c593f6c1", "resourceType": "HOST" } ] } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.3| |inventories|List|详情参考inventories|2.3|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.3| |description|String|错误的概要描述|2.3| |details|String|错误的详细信息|2.3| |elaboration|String|保留字段,默认为null|2.3| |opaque|LinkedHashMap|保留字段,默认为null|2.3| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.3|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.3| |name|String|资源名称|2.3| |description|String|资源的详细描述|2.3| |policy|String|亲和组策略|2.3| |version|String|亲和组分配算法的版本|2.3| |type|String|亲和组类型- 当前为物理机亲和 - 未来将增加网络亲和、路由器亲和、数据中心或机架亲和等多种类型
|2.3| |appliance|String|亲和组使用者标识|2.3| |state|String| |2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3| |usages|List|详情参考usages|2.3|
#usages
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|亲和组与资源绑定关系的UUID|2.3| |affinityGroupUuid|String|亲和组UUID|2.3| |resourceUuid|String|加入亲和组的资源UUID|2.3| |resourceType|String|加入亲和组的资源类型|2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3|
SDK示例
Java SDK
QueryAffinityGroupAction action = new QueryAffinityGroupAction(); action.conditions = asList("uuid=bceb37906e673f37bb425933bdf2df46"); action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; QueryAffinityGroupAction.Result res = action.call();
Python SDK
QueryAffinityGroupAction action = QueryAffinityGroupAction() action.conditions = ["uuid=3714ccec7a933aba94c073fcba6e52bd"] action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" QueryAffinityGroupAction.Result res = action.call()
Parent topic: 亲和组相关接口
更新亲和组(UpdateAffinityGroup)
API请求
URLs
PUT zstack/v1/affinity-groups/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "updateAffinityGroup": { "name": "new name", "description": "desc" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"updateAffinityGroup":{"name":"new name","description":"desc"}}' \ http://localhost:8080/zstack/v1/affinity-groups/f287ad59b76c34b0917fa9f897b63d69/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.3| |name (可选)|String|body(包含在updateAffinityGroup结构中)|资源名称| |2.3| |description (可选)|String|body(包含在updateAffinityGroup结构中)|资源的详细描述| |2.3| |systemTags (可选)|List|body|系统标签| |2.3| |userTags (可选)|List|body|用户标签| |2.3|
API返回
返回示例
{ "inventory": { "uuid": "f8c3b350df9a3bfd960359f302a4fba2", "name": "affinity group", "description": "affinity group for test", "policy": "ANTISOFT", "type": "HOST" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.3| |inventory|AffinityGroupInventory|详情参考inventory|2.3|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.3| |description|String|错误的概要描述|2.3| |details|String|错误的详细信息|2.3| |elaboration|String|保留字段,默认为null|2.3| |opaque|LinkedHashMap|保留字段,默认为null|2.3| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.3|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.3| |name|String|资源名称|2.3| |description|String|资源的详细描述|2.3| |policy|String|亲和组策略|2.3| |version|String|亲和组分配算法的版本|2.3| |type|String|亲和组类型- 当前为物理机亲和 - 未来将增加网络亲和、路由器亲和、数据中心或机架亲和等多种类型
|2.3| |appliance|String|亲和组使用者标识|2.3| |state|String| |2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3| |usages|List|详情参考usages|2.3|
#usages
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|亲和组与资源绑定关系的UUID|2.3| |affinityGroupUuid|String|亲和组UUID|2.3| |resourceUuid|String|加入亲和组的资源UUID|2.3| |resourceType|String|加入亲和组的资源类型|2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3|
SDK示例
Java SDK
UpdateAffinityGroupAction action = new UpdateAffinityGroupAction(); action.uuid = "f287ad59b76c34b0917fa9f897b63d69"; action.name = "new name"; action.description = "desc"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; UpdateAffinityGroupAction.Result res = action.call();
Python SDK
UpdateAffinityGroupAction action = UpdateAffinityGroupAction() action.uuid = "f287ad59b76c34b0917fa9f897b63d69" action.name = "new name" action.description = "desc" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" UpdateAffinityGroupAction.Result res = action.call()
Parent topic: 亲和组相关接口
添加云主机到亲和组(AddVmToAffinityGroup)
API请求
URLs
POST zstack/v1/affinity-groups/{affinityGroupUuid}/vm-instances/{uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": {}, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{}}' \ http://localhost:8080/zstack/v1/affinity-groups/8e9398e9841b399693ab71fb722ea144/vm-instances/f67763f0793832619a22e2c53c66e7d8
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |affinityGroupUuid|String|url|亲和组UUID| |2.3| |uuid|String|url|资源的UUID,唯一标示该资源| |2.3| |systemTags (可选)|List|body|系统标签| |2.3| |userTags (可选)|List|body|用户标签| |2.3|
API返回
返回示例
{ "inventory": { "uuid": "cb4dee8a47d74f9986b4641648a4c85d", "name": "affinity-group-test", "description": "affinity group for test", "policy": "ANTISOFT", "version": "1.0", "type": "HOST", "usages": [ { "uuid": "cb4dee8a47d74f9986b4641648a4c85d", "resourceUuid": "cf44d25659f24cefafbadbf8ad9a207d", "resourceType": "HOST" } ] } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。详情参考error|2.3| |inventory|AffinityGroupInventory|详情参考inventory|2.3|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.2| |description|String|错误的概要描述|2.2| |details|String|错误的详细信息|2.2| |elaboration|String|保留字段,默认为null|2.2| |opaque|LinkedHashMap|保留字段,默认为null|2.2| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.2|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |name|String|资源名称|2.2| |description|String|资源的详细描述|2.2| |policy|String|亲和组策略|2.2| |version|String|亲和组分配算法的版本|2.2| |type|String|亲和组类型- 当前为物理机亲和 - 未来将增加网络亲和、路由器亲和、数据中心或机架亲和等多种类型
|2.2| |appliance|String|亲和组使用者标识|2.2| |state|String| |2.3| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2| |usages|List|详情参考usages|2.2|
#usages
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|亲和组与资源绑定关系的UUID|2.2| |affinityGroupUuid|String|亲和组UUID|2.2| |resourceUuid|String|加入亲和组的资源UUID|2.2| |resourceType|String|加入亲和组的资源类型|2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2|
SDK示例
Java SDK
AddVmToAffinityGroupAction action = new AddVmToAffinityGroupAction(); action.affinityGroupUuid = "8e9398e9841b399693ab71fb722ea144"; action.uuid = "f67763f0793832619a22e2c53c66e7d8"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; AddVmToAffinityGroupAction.Result res = action.call();
Python SDK
AddVmToAffinityGroupAction action = AddVmToAffinityGroupAction() action.affinityGroupUuid = "8e9398e9841b399693ab71fb722ea144" action.uuid = "f67763f0793832619a22e2c53c66e7d8" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" AddVmToAffinityGroupAction.Result res = action.call()
Parent topic: 亲和组相关接口
从亲和组移除云主机(RemoveVmFromAffinityGroup)
API请求
URLs
DELETE zstack/v1/affinity-groups/{affinityGroupUuid}/vm-instances
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X DELETE http://localhost:8080/zstack/v1/affinity-groups/6d1e8b61e30e38ceb8300ed722c6a85a/vm-instances?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |affinityGroupUuid|String|url|亲和组UUID| |2.3| |uuid|String|body|资源的UUID,唯一标示该资源| |2.3| |systemTags (可选)|List|body|系统标签| |2.3| |userTags (可选)|List|body|用户标签| |2.3|
API返回
返回示例
{ "inventory": { "uuid": "15b102d8d08947e6b38fc619c71a5cfe", "name": "affinity-group-test", "description": "affinity group for test", "policy": "ANTISOFT", "version": "1.0", "type": "HOST" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.3| |inventory|AffinityGroupInventory|详情参考inventory|2.3|
#error
|名字|类型|描述|起始版本| |--|--|--|----| |code|String|错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001|2.3| |description|String|错误的概要描述|2.3| |details|String|错误的详细信息|2.3| |elaboration|String|保留字段,默认为null|2.3| |opaque|LinkedHashMap|保留字段,默认为null|2.3| |cause|ErrorCode|根错误,引发当前错误的源错误,若无原错误,该字段为null|2.3|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.3| |name|String|资源名称|2.3| |description|String|资源的详细描述|2.3| |policy|String|亲和组策略|2.3| |version|String|亲和组分配算法的版本|2.3| |type|String|亲和组类型- 当前为物理机亲和 - 未来将增加网络亲和、路由器亲和、数据中心或机架亲和等多种类型
|2.3| |appliance|String|亲和组使用者标识|2.3| |state|String| |2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3| |usages|List|详情参考usages|2.3|
#usages
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|亲和组与资源绑定关系的UUID|2.3| |affinityGroupUuid|String|亲和组UUID|2.3| |resourceUuid|String|加入亲和组的资源UUID|2.3| |resourceType|String|加入亲和组的资源类型|2.3| |createDate|Timestamp|创建时间|2.3| |lastOpDate|Timestamp|最后一次修改时间|2.3|
SDK示例
Java SDK
RemoveVmFromAffinityGroupAction action = new RemoveVmFromAffinityGroupAction(); action.affinityGroupUuid = "6d1e8b61e30e38ceb8300ed722c6a85a"; action.uuid = "2736c4e5c4f3301e8a9ee7cc64847033"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; RemoveVmFromAffinityGroupAction.Result res = action.call();
Python SDK
RemoveVmFromAffinityGroupAction action = RemoveVmFromAffinityGroupAction() action.affinityGroupUuid = "6d1e8b61e30e38ceb8300ed722c6a85a" action.uuid = "2736c4e5c4f3301e8a9ee7cc64847033" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" RemoveVmFromAffinityGroupAction.Result res = action.call()
Parent topic: 亲和组相关接口
改变亲和组的使用状态(ChangeAffinityGroupState)
API请求
URLs
PUT zstack/v1/affinity-groups/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "changeAffinityGroupState": { "stateEvent": "enable" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"changeAffinityGroupState":{"stateEvent":"enable"}}' \ http://localhost:8080/zstack/v1/affinity-groups/f32fd1a910d439d7ab93cd4660a02837/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |2.3| |stateEvent|String|body(包含在changeAffinityGroupState结构中)| | - enable - disable
|2.3| |systemTags (可选)|List|body| | |2.3| |userTags (可选)|List|body| | |2.3|
API返回
返回示例
{ "inventory": { "uuid": "034e3ef3798f3374b85d414057313a3c", "name": "Test-AffinityGroup", "description": "Test-AffinityGroup", "version": "1.0", "type": "HOST", "appliance": "CUSTOMER", "createDate": "Nov 14, 2017 10:20:57 PM", "lastOpDate": "Nov 14, 2017 10:20:57 PM" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|2.3| |inventory|AffinityGroupInventory|详情参考inventory|2.3|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |name|String|资源名称|2.2| |description|String|资源的详细描述|2.2| |policy|String| |2.2| |version|String| |2.2| |type|String| |2.2| |appliance|String| |2.2| |state|String| |2.3| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2| |usages|List|详情参考usages|2.2|
#usages
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|2.2| |affinityGroupUuid|String| |2.2| |resourceUuid|String| |2.2| |resourceType|String| |2.2| |createDate|Timestamp|创建时间|2.2| |lastOpDate|Timestamp|最后一次修改时间|2.2|
SDK示例
Java SDK
ChangeAffinityGroupStateAction action = new ChangeAffinityGroupStateAction(); action.uuid = "f32fd1a910d439d7ab93cd4660a02837"; action.stateEvent = "enable"; action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"; ChangeAffinityGroupStateAction.Result res = action.call();
Python SDK
ChangeAffinityGroupStateAction action = ChangeAffinityGroupStateAction() action.uuid = "f32fd1a910d439d7ab93cd4660a02837" action.stateEvent = "enable" action.sessionId = "b86c9016b4f24953a9edefb53ca0678c" ChangeAffinityGroupStateAction.Result res = action.call()
Parent topic: 亲和组相关接口
计算规格相关接口
创建云主机规格(CreateInstanceOffering)
API请求
URLs
POST zstack/v1/instance-offerings
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "instanceOffering", "cpuNum": 2.0, "memorySize": 2097152.0, "sortKey": 0.0, "type": "UserVm" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"instanceOffering","cpuNum":2.0,"memorySize":2097152.0,"sortKey":0.0,"type":"UserVm"}}' \ http://localhost:8080/zstack/v1/instance-offerings
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|资源名称| |0.6| |description (可选)|String|body(包含在params结构中)|资源的详细描述| |0.6| |cpuNum|int|body(包含在params结构中)|CPU数目| |0.6| |memorySize|long|body(包含在params结构中)|内存大小, 单位Byte| |0.6| |allocatorStrategy (可选)|String|body(包含在params结构中)|分配策略| |0.6| |sortKey (可选)|int|body(包含在params结构中)|排序键| |0.6| |type (可选)|String|body(包含在params结构中)|类型| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|资源UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "d04e02a97d6c4ad0b0acee2a2f6c7084", "name": "instanceOffering1", "cpuNum": 2.0, "cpuSpeed": 1.0, "type": "UserVm", "allocatorStrategy": "Mevoco", "createDate": "Jun 7, 2017 9:20:40 PM", "lastOpDate": "Jun 7, 2017 9:20:40 PM", "state": "Enabled" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|InstanceOfferingInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |cpuNum|Integer|CPU数量|0.6| |cpuSpeed|Integer|CPU速度|0.6| |memorySize|Long|内存大小|0.6| |type|String|类型|0.6| |allocatorStrategy|String|分配策略|0.6| |sortKey|Integer| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String|状态(启用,禁用)|0.6|
SDK示例
Java SDK
CreateInstanceOfferingAction action = new CreateInstanceOfferingAction(); action.name = "instanceOffering"; action.cpuNum = 2.0; action.memorySize = 2097152.0; action.sortKey = 0.0; action.type = "UserVm"; action.sessionId = "1567ec4024724d2ea60eba29b957158c"; CreateInstanceOfferingAction.Result res = action.call();
Python SDK
CreateInstanceOfferingAction action = CreateInstanceOfferingAction() action.name = "instanceOffering" action.cpuNum = 2.0 action.memorySize = 2097152.0 action.sortKey = 0.0 action.type = "UserVm" action.sessionId = "427dd2d091a54a0999e7e31eac07fc83" CreateInstanceOfferingAction.Result res = action.call()
Parent topic: 计算规格相关接口
删除云主机规格(DeleteInstanceOffering)
API请求
URLs
DELETE zstack/v1/instance-offerings/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth cd94b78dc89842c19ea248ddb04816c0" \ -X DELETE http://localhost:8080/zstack/v1/instance-offerings/d4061032ef3940b990ba671acd1221fc?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |deleteMode (可选)|String|body|删除模式| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteInstanceOfferingAction action = new DeleteInstanceOfferingAction(); action.uuid = "07ce817b8d9d4f629c2bd65daae9b7bb"; action.deleteMode = "Permissive"; action.sessionId = "fd2aa30babca411780c7df97d3ae6f9f"; DeleteInstanceOfferingAction.Result res = action.call();
Python SDK
DeleteInstanceOfferingAction action = DeleteInstanceOfferingAction() action.uuid = "694e24b4a64d4b45936a9bbcf878078b" action.deleteMode = "Permissive" action.sessionId = "a13ac6edf7f546e48c4dbfea66429610" DeleteInstanceOfferingAction.Result res = action.call()
Parent topic: 计算规格相关接口
查询云主机规格(QueryInstanceOffering)
API请求
URLs
GET zstack/v1/instance-offerings GET zstack/v1/instance-offerings/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth d4743a8bc4eb4dd7a827c58e20437e85" \ -X GET http://localhost:8080/zstack/v1/instance-offerings?q=uuid=3695f87b54594284b9ce542b2b653fb7
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth e053145ce7d74cad8686d9b2a91e2754" \ -X GET http://localhost:8080/zstack/v1/instance-offerings/b1c967830a5f4b198b291d7f22cc8a2f
可查询字段
运行zstack-cli命令行工具,输入QueryInstanceOffering
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{ "inventories": [ { "uuid": "4f7e7eff5bb04f7cacc33a18006a0c72", "name": "instanceOffering1", "cpuNum": 2.0, "cpuSpeed": 1.0, "type": "UserVm", "allocatorStrategy": "Mevoco", "createDate": "Jun 7, 2017 9:20:13 PM", "lastOpDate": "Jun 7, 2017 9:20:13 PM", "state": "Enabled" } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |cpuNum|Integer|CPU数量|0.6| |cpuSpeed|Integer|CPU速度|0.6| |memorySize|Long|内存大小|0.6| |type|String|类型|0.6| |allocatorStrategy|String|分配策略|0.6| |sortKey|Integer| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String|状态(启用,禁用)|0.6|
SDK示例
Java SDK
QueryInstanceOfferingAction action = new QueryInstanceOfferingAction(); action.conditions = asList("uuid=8c77205cdc114a9090bc5d978b9d5285"); action.sessionId = "7d91852598ca41ca904539b34396c2ec"; QueryInstanceOfferingAction.Result res = action.call();
Python SDK
QueryInstanceOfferingAction action = QueryInstanceOfferingAction() action.conditions = ["uuid=6539c13e7a8843b7860ebc53c3f7e892"] action.sessionId = "8700ab8ae22e48fb81a793b9a51e970a" QueryInstanceOfferingAction.Result res = action.call()
Parent topic: 计算规格相关接口
更改云主机规格(ChangeInstanceOffering)
API请求
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "changeInstanceOffering": { "instanceOfferingUuid": "818e8cad0af948baa9b8e7d8d7116abb" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"changeInstanceOffering":{"instanceOfferingUuid":"7c46b8e59bf63b5f94fda63fce797581"}}' \ http://localhost:8080/zstack/v1/vm-instances/6b322ba8e03136e6bf200431e550d1a6/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |vmInstanceUuid|String|url|云主机UUID| |0.6| |instanceOfferingUuid|String|body(包含在changeInstanceOffering结构中)|计算规格UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
ChangeInstanceOfferingAction action = new ChangeInstanceOfferingAction(); action.vmInstanceUuid = "c63937d254e24da1b06afc433b0e27ff"; action.instanceOfferingUuid = "3186c364b49f485ba14591f81387010a"; action.sessionId = "3d53ea4d8e914d56ae795e9592a63317"; ChangeInstanceOfferingAction.Result res = action.call();
Python SDK
ChangeInstanceOfferingAction action = ChangeInstanceOfferingAction() action.vmInstanceUuid = "5783bd4c68c04d9f9fe20783d92fa822" action.instanceOfferingUuid = "8a9f3296030948b6bcda8c75a05458c9" action.sessionId = "a19417648f9440c5b84b6ee4280dcefc" ChangeInstanceOfferingAction.Result res = action.call()
Parent topic: 计算规格相关接口
更新云主机规格(UpdateInstanceOffering)
API请求
URLs
PUT zstack/v1/instance-offerings/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "updateInstanceOffering": { "name": "new name" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"updateInstanceOffering":{"name":"new name"}}' \ http://localhost:8080/zstack/v1/instance-offerings/d071c5278471319291f6d1b44522a044/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |name (可选)|String|body(包含在updateInstanceOffering结构中)|资源名称| |0.6| |description (可选)|String|body(包含在updateInstanceOffering结构中)|资源的详细描述| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6| |allocatorStrategy (可选)|String|body(包含在updateInstanceOffering结构中)| | |2.3|
API返回
返回示例
{ "inventory": { "uuid": "341367815c8e45209787b2361837109e", "name": "instanceOffering1", "cpuNum": 2.0, "cpuSpeed": 1.0, "type": "UserVm", "allocatorStrategy": "Mevoco", "createDate": "Jun 7, 2017 9:20:13 PM", "lastOpDate": "Jun 7, 2017 9:20:13 PM", "state": "Enabled" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|InstanceOfferingInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |cpuNum|Integer|CPU数量|0.6| |cpuSpeed|Integer|CPU速度|0.6| |memorySize|Long|内存大小|0.6| |type|String|类型|0.6| |allocatorStrategy|String|分配策略|0.6| |sortKey|Integer| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String|状态(启用,禁用)|0.6|
SDK示例
Java SDK
UpdateInstanceOfferingAction action = new UpdateInstanceOfferingAction(); action.uuid = "0d71c980598b4c7b8a8eeef3148ced95"; action.name = "new name"; action.sessionId = "12bf1da37d444e2fbb6de5dc98f8d5f0"; UpdateInstanceOfferingAction.Result res = action.call();
Python SDK
UpdateInstanceOfferingAction action = UpdateInstanceOfferingAction() action.uuid = "bbe8cd1494d2413a8951623657a4f9c0" action.name = "new name" action.sessionId = "9251753d64fa477aa7cdd3956a94ff18" UpdateInstanceOfferingAction.Result res = action.call()
Parent topic: 计算规格相关接口
更改云主机规格的启用状态(ChangeInstanceOfferingState)
API请求
URLs
PUT zstack/v1/instance-offerings/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "changeInstanceOfferingState": { "stateEvent": "enable" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 318fe86dc2c2424c863623942dcf8e6f" \ -X PUT http://localhost:8080/zstack/v1/instance-offerings/049d4fa0268549c9b3e3e84f4c280d09/actions?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |stateEvent|String|body(包含在changeInstanceOfferingState结构中)|状态事件| - enable - disable
|0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "372d111a940b46b39da8c32c5629ba66", "name": "instanceOffering1", "cpuNum": 2.0, "cpuSpeed": 1.0, "type": "UserVm", "allocatorStrategy": "Mevoco", "createDate": "Jun 7, 2017 9:20:36 PM", "lastOpDate": "Jun 7, 2017 9:20:36 PM", "state": "Enabled" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|InstanceOfferingInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |cpuNum|Integer|CPU数量|0.6| |cpuSpeed|Integer|CPU速度|0.6| |memorySize|Long|内存大小|0.6| |type|String|类型|0.6| |allocatorStrategy|String|分配策略|0.6| |sortKey|Integer| |0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |state|String|状态(启用,禁用)|0.6|
SDK示例
Java SDK
ChangeInstanceOfferingStateAction action = new ChangeInstanceOfferingStateAction(); action.uuid = "ca7a911366f74e9b8e4222785cf963a1"; action.stateEvent = "enable"; action.sessionId = "86cf8ce78421434eb9458504f7449c64"; ChangeInstanceOfferingStateAction.Result res = action.call();
Python SDK
ChangeInstanceOfferingStateAction action = ChangeInstanceOfferingStateAction() action.uuid = "5cfc5009c0b74319855ccd197fa04a16" action.stateEvent = "enable" action.sessionId = "c593d4f452fd498cb60679a0956f1929" ChangeInstanceOfferingStateAction.Result res = action.call()
Parent topic: 计算规格相关接口
云盘规格相关接口
创建云盘规格(CreateDiskOffering)
API请求
URLs
POST zstack/v1/disk-offerings
Headers
Authorization: OAuth the-session-uuid
Body
{ "params": { "name": "diskOffering1", "diskSize": 100.0, "sortKey": 0.0 }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X POST -d '{"params":{"name":"diskOffering1","diskSize":100.0,"sortKey":0.0}}' \ http://localhost:8080/zstack/v1/disk-offerings
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |name|String|body(包含在params结构中)|资源名称| |0.6| |description (可选)|String|body(包含在params结构中)|资源的详细描述| |0.6| |diskSize|long|body(包含在params结构中)|云盘大小| |0.6| |sortKey (可选)|int|body(包含在params结构中)|排序key| |0.6| |allocationStrategy (可选)|String|body(包含在params结构中)|分配策略| |0.6| |type (可选)|String|body(包含在params结构中)|类型| |0.6| |resourceUuid (可选)|String|body(包含在params结构中)|资源UUID| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "e7a865815cd34dd29812d335dc1019bf", "name": "diskOffering1", "diskSize": 100.0, "state": "Enabled", "type": "DefaultDiskOfferingType", "allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|DiskOfferingInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |diskSize|Long|云盘大小|0.6| |sortKey|Integer| |0.6| |state|String|状态(启动,禁用)|0.6| |type|String|类型|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |allocatorStrategy|String|分配策略|0.6|
SDK示例
Java SDK
CreateDiskOfferingAction action = new CreateDiskOfferingAction(); action.name = "diskOffering1"; action.diskSize = 100.0; action.sortKey = 0.0; action.sessionId = "5c780b5178c0432b9f86a758c4c75ea1"; CreateDiskOfferingAction.Result res = action.call();
Python SDK
CreateDiskOfferingAction action = CreateDiskOfferingAction() action.name = "diskOffering1" action.diskSize = 100.0 action.sortKey = 0.0 action.sessionId = "f930e0f78ce948778c8c3f1cbcd0c4ec" CreateDiskOfferingAction.Result res = action.call()
Parent topic: 云盘规格相关接口
删除云盘规格(DeleteDiskOffering)
API请求
URLs
DELETE/v1/disk-offerings/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth e12cbd12fbd54afd96c463c093ce1ed9" \ -X DELETE http://localhost:8080/zstack/v1/disk-offerings/6313fb03124a4aa6b7f77d8d153c0bcb?
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |deleteMode (可选)|String|body|删除模式| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{ "error": { "code": "SYS.1001", "description": "A message or a operation timeout", "details": "Create VM on KVM timeout after 300s" } }
SDK示例
Java SDK
DeleteDiskOfferingAction action = new DeleteDiskOfferingAction(); action.uuid = "1d4e09f16c7c45abaab80be172b26cc1"; action.deleteMode = "Permissive"; action.sessionId = "1a31abeeef7e4ab5bc538168be6deb05"; DeleteDiskOfferingAction.Result res = action.call();
Python SDK
DeleteDiskOfferingAction action = DeleteDiskOfferingAction() action.uuid = "4f0d2dc3a8f34685ad8543834bf4cfd8" action.deleteMode = "Permissive" action.sessionId = "dce93830769b427ca6edf3bda25f65f6" DeleteDiskOfferingAction.Result res = action.call()
Parent topic: 云盘规格相关接口
查询云盘规格(QueryDiskOffering)
API请求
URLs
GET zstack/v1/disk-offerings GET zstack/v1/disk-offerings/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth d6550daa638547498b8075f3ebd1e240" \ -X GET http://localhost:8080/zstack/v1/disk-offerings?q=uuid=85c065f24d024bf3920766692da392eb
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth 3b32284bc5344692a8bc77a43610f460" \ -X GET http://localhost:8080/zstack/v1/disk-offerings/2f25294896e24c89b63edb7a209ebb85
可查询字段
运行zstack-cli命令行工具,输入QueryDiskOffering
并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{ "inventories": [ { "uuid": "7bd03741125a48d485255601b639318b", "name": "diskOffering1", "diskSize": 100.0, "state": "Enabled", "type": "DefaultDiskOfferingType", "allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy" } ] }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventories|List|详情参考inventories|0.6|
#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|
#inventories
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |diskSize|Long|云盘大小|0.6| |sortKey|Integer| |0.6| |state|String|状态(启动,禁用)|0.6| |type|String|类型|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |allocatorStrategy|String|分配策略|0.6|
SDK示例
Java SDK
QueryDiskOfferingAction action = new QueryDiskOfferingAction(); action.conditions = asList("uuid=e01b8a266d05425ba2d0c05308763db8"); action.sessionId = "d8a3f3b62d8c4affab7c5d491f95d4de"; QueryDiskOfferingAction.Result res = action.call();
Python SDK
QueryDiskOfferingAction action = QueryDiskOfferingAction() action.conditions = ["uuid=a1f7f68522e64783a37095a862f9bc28"] action.sessionId = "593740538236497183e065e1251b6937" QueryDiskOfferingAction.Result res = action.call()
Parent topic: 云盘规格相关接口
更改云盘规格的启用状态(ChangeDiskOfferingState)
API请求
URLs
PUT zstack/v1/disk-offerings/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "changeDiskOfferingState": { "stateEvent": "enable" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"changeDiskOfferingState":{"stateEvent":"enable"}}' \ http://localhost:8080/zstack/v1/disk-offerings/39c32ae614e23ce2a6877797a09037fd/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |stateEvent|String|body(包含在changeDiskOfferingState结构中)|状态事件| - enable - disable
|0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "5e84d8a44b2941eb96d9eec31e0524be", "name": "diskOffering1", "diskSize": 100.0, "state": "Enabled", "type": "DefaultDiskOfferingType", "allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|DiskOfferingInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |diskSize|Long|云盘大小|0.6| |sortKey|Integer| |0.6| |state|String|状态(启动,禁用)|0.6| |type|String|类型|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |allocatorStrategy|String|分配策略|0.6|
SDK示例
Java SDK
ChangeDiskOfferingStateAction action = new ChangeDiskOfferingStateAction(); action.uuid = "b99744228d4943959881b051cecb376d"; action.stateEvent = "enable"; action.sessionId = "8733eb947ada42bb8769ad170f889e98"; ChangeDiskOfferingStateAction.Result res = action.call();
Python SDK
ChangeDiskOfferingStateAction action = ChangeDiskOfferingStateAction() action.uuid = "521d538a214c42e39d16cef5a1e13cc9" action.stateEvent = "enable" action.sessionId = "7e7ba75914814242a268026ca77163e5" ChangeDiskOfferingStateAction.Result res = action.call()
Parent topic: 云盘规格相关接口
更新云盘规格(UpdateDiskOffering)
API请求
URLs
PUT zstack/v1/disk-offerings/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{ "updateDiskOffering": { "name": "new name" }, "systemTags": [], "userTags": [] }
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \ -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \ -X PUT -d '{"updateDiskOffering":{"name":"new name"}}' \ http://localhost:8080/zstack/v1/disk-offerings/1a2b9698ee163ad69374f765f6234f02/actions
参数列表
|名字|类型|位置|描述|可选值|起始版本| |--|--|--|--|---|----| |uuid|String|url|资源的UUID,唯一标示该资源| |0.6| |name (可选)|String|body(包含在updateDiskOffering结构中)|资源名称| |0.6| |description (可选)|String|body(包含在updateDiskOffering结构中)|资源的详细描述| |0.6| |systemTags (可选)|List|body|系统标签| |0.6| |userTags (可选)|List|body|用户标签| |0.6|
API返回
返回示例
{ "inventory": { "uuid": "a156bb54daa544628f2abff419c76977", "name": "new name", "diskSize": 100.0, "state": "Enabled", "type": "DefaultDiskOfferingType", "allocatorStrategy": "DefaultPrimaryStorageAllocationStrategy" } }
|名字|类型|描述|起始版本| |--|--|--|----| |error|ErrorCode|错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error|0.6| |inventory|DiskOfferingInventory|详情参考inventory|0.6|
#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|
#inventory
|名字|类型|描述|起始版本| |--|--|--|----| |uuid|String|资源的UUID,唯一标示该资源|0.6| |name|String|资源名称|0.6| |description|String|资源的详细描述|0.6| |diskSize|Long|云盘大小|0.6| |sortKey|Integer| |0.6| |state|String|状态(启动,禁用)|0.6| |type|String|类型|0.6| |createDate|Timestamp|创建时间|0.6| |lastOpDate|Timestamp|最后一次修改时间|0.6| |allocatorStrategy|String|分配策略|0.6|
SDK示例
Java SDK
UpdateDiskOfferingAction action = new UpdateDiskOfferingAction(); action.uuid = "21226fe14a8042d2ad1d37640c8a8594"; action.name = "new name"; action.sessionId = "c8e71fd622614f15b3452a8fa451d037"; UpdateDiskOfferingAction.Result res = action.call();
Python SDK
UpdateDiskOfferingAction action = UpdateDiskOfferingAction() action.uuid = "30d4acc261f34c55a297a203fed852e2" action.name = "new name" action.sessionId = "0236ee9dd5d440de84f867e9d550172c" UpdateDiskOfferingAction.Result res = action.call()
Parent topic: 云盘规格相关接口
术语表
区域(Zone)
ZStack中较大的一个资源定义,包括集群、二层网络、主存储等资源。
集群(Cluster)
一个集群是类似物理主机(Host)组成的逻辑组。在同一个集群中的物理主机必须安装相同的操作系统(虚拟机管理程序,Hypervisor),拥有相同的二层网络连接,可以访问相同的主存储。在实际的数据中心,一个集群通常对应一个机架(Rack)。
管理节点(Management Node)
安装系统的物理主机,提供UI管理、云平台部署功能。
计算节点(Compute Node)
也称之为物理主机(或物理机),为云主机实例提供计算、网络、存储等资源的物理主机。
主存储(Primary Storage)
用于存储云主机磁盘文件的存储服务器。支持本地存储、NFS、 Ceph、FusionStor、Shared Mount Point等类型。
镜像服务器(Backup Storage)
也称之为备份存储服务器,主要用于保存镜像模板文件。建议单独部署镜像服务器。
镜像仓库(Image Store)
镜像服务器的一种类型,可以为正在运行的云主机快速创建镜像,高效管理云主机镜像的版本变迁以及发布,实现快速上传、下载镜像,镜像快照,以及导出镜像的操作。
云主机(VM Instance)
运行在物理机上的虚拟机实例,具有独立的IP地址,可以访问公共网络,运行应用服务。
镜像(Image)
云主机或云盘使用的镜像模板文件,镜像模板包括系统云盘镜像和数据云盘镜像。
云盘(Volume)
云主机的数据盘,给云主机提供额外的存储空间,共享云盘可挂载到一个或多个云主机共同使用。
计算规格(Instance Offering)
启动云主机涉及到的CPU数量、内存、网络设置等规格定义。
云盘规格(Disk Offering)
创建云盘容量大小的规格定义。
二层网络(L2 Network)
二层网络对应于一个二层广播域,进行二层相关的隔离。一般用物理网络的设备名称标识。
三层网络(L3 Network)
云主机使用的网络配置,包括IP地址范围、网关、DNS等。
公有网络(Public Network)
由因特网信息中心分配的公有IP地址或者可以连接到外部互联网的IP地址。
私有网络(Private Network)
云主机连接和使用的内部网络。
L2NoVlanNetwork
物理主机的网络连接不采用Vlan设置。
L2VlanNetwork
物理主机节点的网络连接采用Vlan设置,Vlan需要在交换机端提前进行设置。
VXLAN网络池(VXLAN Network Pool)
VXLAN网络中的 Underlay 网络,一个 VXLAN 网络池可以创建多个 VXLAN Overlay 网络(即 VXLAN 网络),这些 Overlay 网络运行在同一组 Underlay 网络设施上。
VXLAN网络(VXLAN)
使用 VXLAN 协议封装的二层网络,单个 VXLAN 网络需从属于一个大的 VXLAN 网络池,不同 VXLAN 网络间相互二层隔离。
云路由(vRouter)
云路由通过定制的Linux云主机来实现的多种网络服务。
安全组(Security Group)
针对云主机进行第三层网络的防火墙控制,对IP地址、网络包类型或网络包流向等可以设置不同的安全规则。
弹性IP(EIP)
公有网络接入到私有网络的IP地址。
快照(Snapshot)
某一个时间点上某一个磁盘的数据备份。包括自动快照和手动快照两种类型。