Skip to main content

虚拟机模板

2.9.1虚拟机模板创建

接口地址

POST  /NSphere/api/vm-template-resource

接口描述

虚拟机模板创建,虚拟机ID或者UUID其中一个必填。

请求数据类型

application/json

响应数据类型

application/json

请求示例

{

"id": null,

"uuid": null,

"title": "",

"desc": null,

"opType": 2,

"disConnect": false,

"templateStoragePath": "/vms/images",

"scope": 0,

"saveOnHost": false

}

请求参数

参数名称

参数说明

请求类型

必须

数据类型

schema

apiAddTemplateDTO

增加虚拟机模板实体

body

true

ApiAddTemplateDTO

ApiAddTemplateDTO

id

虚拟机ID。

false

integer(int64)

uuid

虚拟机UUID,没有虚拟机ID时,必须。

false

string

title

虚拟机模板显示名称。

true

string

desc

虚拟机模板描述信息。

false

string

opType

创建虚拟机模板形式。1 克隆为模板 2 转换为模板。 当虚拟机处于运行或暂停状态时,不允许转换为模板。

true

integer(int32)

disConnect

是否断开虚拟机光驱/软驱。true:自动断开光驱/软驱;false:不会自动断开光驱/软驱,如果挂载光驱/软驱,则无法创建模板。默认为false。

false

boolean

templateStoragePath

模板存储目录。

true

string

scope

虚拟机模板的可见范围,默认为私有。0 私有 1 公有

false

integer(int32)

saveOnHost

是否主机存储,默认false。

true

boolean

响应状态

状态码

说明

schema

200

OK

ApiResponseApiTaskMsgVO

响应参数

参数名称

参数说明

类型

schema

state

状态码 0: 成功, 1: 失败, 2: 部分成功

integer(int32)

integer(int32)

errorCode

错误码 当不为0表示业务发生错误

integer(int32)

integer(int32)

successMessage

成功消息

string

failureMessage

错误消息,失败或者部分成功时有效.

string

data

响应数据,如果状态码为0表示正常的数据返回,如果非0且非空则代表引起异常的必要数据

ApiTaskMsgVO

ApiTaskMsgVO

msgId

消息ID,可用于查询任务进度。

integer(int64)

targetId

任务执行对象ID

integer(int64)

targetName

任务执行对象名称

string

响应示例

{

"state": 0,

"errorCode": 0,

"successMessage": null,

"failureMessage": null,

"data": {

"msgId": 0,

"targetId": null,

"targetName": null

}

}

2.9.2修改虚拟机模板

接口地址

PUT  /NSphere/api/vm-template-resource

接口描述

修改虚拟机模板。快速部署后的模板将无法修改其名称及磁盘大小。

请求数据类型

application/json

响应数据类型

application/json

请求示例

{

"id": 0,

"title": "",

"description": null,

"cpuCore": 0,

"cpuSocket": 0,

"memoryInit": 0,

"memoryUnit": "GB",

"templetStoragePath": "",

"storageList": [

{

"id": 0,

"storeFile": "",

"capacity": 0

}

]

}

请求参数

参数名称

参数说明

请求类型

必须

数据类型

schema

apiModifyTemplateDTO

修改虚拟机模板实体信息。

body

true

ApiModifyTemplateDTO

ApiModifyTemplateDTO

id

虚拟机模板ID。

true

integer(int64)

title

虚拟机模板显示名称。

true

string

description

虚拟机模板描述信息。

false

string

cpuCore

虚拟机CPU核数。

true

integer(int32)

cpuSocket

虚拟机CPU个数。

true

integer(int32)

memoryInit

虚拟机内存值,memoryUnit为MB,内存范围:512 ~ 2097152;memoryUnit为GB,内存范围:1 ~ 2048。

true

integer(int32)

memoryUnit

虚拟机内存单位,允许使用MB和GB。

true

string

templetStoragePath

模板存放路径。

true

string

storageList

true

array

Storage

id

存储ID。

true

integer(int64)

storeFile

存储路径。

true

string

capacity

存储容量,单位:MB。范围:当前存储最小值 ~ 16776192。

true

integer(int64)

响应状态

状态码

说明

schema

200

OK

ApiResponseApiTaskMsgVO

响应参数

参数名称

参数说明

类型

schema

state

状态码 0: 成功, 1: 失败, 2: 部分成功

integer(int32)

integer(int32)

errorCode

错误码 当不为0表示业务发生错误

integer(int32)

integer(int32)

successMessage

成功消息

string

failureMessage

错误消息,失败或者部分成功时有效.

string

data

响应数据,如果状态码为0表示正常的数据返回,如果非0且非空则代表引起异常的必要数据

ApiTaskMsgVO

ApiTaskMsgVO

msgId

消息ID,可用于查询任务进度。

integer(int64)

targetId

任务执行对象ID

integer(int64)

targetName

任务执行对象名称

string

响应示例

{

"state": 0,

"errorCode": 0,

"successMessage": null,

"failureMessage": null,

"data": {

"msgId": 0,

"targetId": null,

"targetName": null

}

}

2.9.3删除虚拟机模板

接口地址

DELETE  /NSphere/api/vm-template-resource

接口描述

虚拟机模板ID或者UUID其中一个必填,创建任务成功,则返回任务ID。

请求数据类型

application/x-www-form-urlencoded

响应数据类型

application/json

请求参数

参数名称

参数说明

请求类型

必须

数据类型

schema

id

虚拟机模板ID。

query

false

integer(int64)

uuid

虚拟机模板UUID,没有虚拟机模板ID时,必须。

query

false

string

响应状态

状态码

说明

schema

200

OK

ApiResponseLong

响应参数

参数名称

参数说明

类型

schema

state

状态码 0: 成功, 1: 失败, 2: 部分成功

integer(int32)

integer(int32)

errorCode

错误码 当不为0表示业务发生错误

integer(int32)

integer(int32)

successMessage

成功消息

string

failureMessage

错误消息,失败或者部分成功时有效.

string

data

响应数据,如果状态码为0表示正常的数据返回,如果非0且非空则代表引起异常的必要数据

integer(int64)

integer(int64)

响应示例

{

"state": 0,

"errorCode": 0,

"successMessage": null,

"failureMessage": null,

"data": null

}

2.9.4查询虚拟机模板详情

接口地址

GET  /NSphere/api/vm-template-resource/{id}

接口描述

查询虚拟机模板详情。E0930版本有变更,变更详情:新增返回虚拟机模板网络信息。

请求数据类型

application/x-www-form-urlencoded

响应数据类型

application/json

请求参数

参数名称

参数说明

请求类型

必须

数据类型

schema

id

虚拟机模板ID。

path

true

integer(int64)

响应状态

状态码

说明

schema

200

OK

ApiResponseApiVmTemplateDetailVO

响应参数

参数名称

参数说明

类型

schema

state

状态码 0: 成功, 1: 失败, 2: 部分成功

integer(int32)

integer(int32)

errorCode

错误码 当不为0表示业务发生错误

integer(int32)

integer(int32)

successMessage

成功消息

string

failureMessage

错误消息,失败或者部分成功时有效.

string

data

响应数据,如果状态码为0表示正常的数据返回,如果非0且非空则代表引起异常的必要数据

ApiVmTemplateDetailVO

ApiVmTemplateDetailVO

id

虚拟机模板ID。

integer(int64)

uuid

虚拟机模板UUID。

string

name

虚拟机模板名称。

string

title

虚拟机模板显示名称。

string

description

虚拟机模板描述信息。

string

status

虚拟机模板状态,0:正常;1:维护。开启镜像更新的模板会进入维护状态。

integer(int32)

cpu

虚拟机虚拟CPU个数(CPU个数 * CPU核数)。

integer(int32)

createDate

虚拟机模板创建时间。

string(date-time)

memory

内存,单位MB。

integer(int64)

memoryFormat

内存(带单位展示)

string

memoryInit

显示内存。

number(double)

memoryUnit

内存单位。

string

osVersion

虚拟机模板操作系统信息。

string

storageCapacity

模板存储大小,单位:MB。

integer(int64)

storageCapacityFormat

存储大小(带单位展示)。

string

system

虚拟机模板安装的操作系统。取值:0:Windows;1:Linux;2:BSD

integer(int32)

templetStoragePath

模板存放路径。

string

hugePage

是否开启大页。

boolean

kernelType

虚拟机内核类型。 1:aarch64,0:i686(32位)或x86_64。

integer(int32)

cpuSocket

虚拟机CPU个数。

integer(int32)

cpuCore

虚拟机CPU核数。

integer(int32)

scope

虚拟机模板的可见范围。0 私有 1 公有。

integer(int32)

hostId

虚拟机模板所在主机

integer(int64)

hostName

虚拟机模板所在主机名称

string

hostKernelType

虚拟机模板所在主机内核类型。1:arm,0: x86。

integer(int32)

enableUltra

虚拟机是否开启Ultra模式。1:启用,0或空为不启用。

integer(int32)

clusterId

集群ID。 E0930版本新增属性。

integer(int64)

type

虚拟机模板外部云资源类型(通常=2,即CVM)。 E0930版本新增属性。

integer(int32)

deployed

是否快速部署过。

boolean

encryptPw

是否带有加密磁盘。

boolean

storageList

虚拟机模板存储实体。

array

ApiVmTemplateStorageVO

id

存储ID。

integer(int64)

storeFile

存储文件名。

string

capacity

容量。单位:MB。

integer(int64)

targetBus

总线类型:ide:IDE硬盘, scsi:SCSI硬盘, usb:USB硬盘, virtio:高速硬盘,virtioScsi:高速SCSI硬盘。

string

type

存储类型:file:文件类型,block:块设备, network:网络设备。

string

device

设备名称,如vda,vdb。

string

format

访问格式:Read-Write(Read-Writ)、Read-ForceWrite、Read-Only。

string

driveType

存储卷类型。raw、qcow2。

string

assignType

分配类型:0指定 1动态分配。

integer(int32)

diskDevice

磁盘类型,disk:硬盘, cdrom:光驱, floppy:软驱。

string

mode

预分配格式。取值:0:延迟置零、1:置零、2 精简。

integer(int32)

diskSecret

磁盘是否加密。

boolean

diskSecUuid

加密磁盘UUID。

string

networkList

虚拟机模板网络实体。E0930版本新增属性。

array

ApiVmTemplateNetworkVO

id

网络ID。

integer(int64)

mac

网卡mac地址。

string

vswitchName

虚拟交换机名称。

string

vlan

VLAN值。

string

outAvgBand

出方向平均带宽,单位:Kbps。

integer(int64)

inAvgBand

入方向平均带宽,单位:Kbps。

integer(int64)

inBurst

入方向突发缓冲大小,单位:KBytes。

integer(int64)

outBurst

出方向突发缓冲大小,单位:KBytes。

integer(int64)

mode

网卡转发模式,可能的值有:vepa,dvs,veb,server。

string

profileName

网络策略模板名称。

string

portgroupUUID

VXLAN端口组UUID。

string

networkPortGroupId

端口组ID。

integer(int64)

networkPortGroupName

端口组名称。

string

netLimitProfileId

网络限速策略ID。

integer(int64)

netLimitProfileName

网络限速策略名称。

string

isDpdk

是否开启DPDK。

boolean

响应示例

{

"state": 0,

"errorCode": 0,

"successMessage": null,

"failureMessage": null,

"data": {

"id": null,

"uuid": null,

"name": null,

"title": null,

"description": null,

"status": null,

"cpu": null,

"createDate": null,

"memory": null,

"memoryFormat": null,

"memoryInit": null,

"memoryUnit": null,

"osVersion": null,

"storageCapacity": null,

"storageCapacityFormat": null,

"system": null,

"templetStoragePath": null,

"hugePage": true,

"kernelType": null,

"cpuSocket": null,

"cpuCore": null,

"scope": null,

"hostId": null,

"hostName": null,

"hostKernelType": null,

"enableUltra": null,

"clusterId": null,

"type": null,

"deployed": true,

"encryptPw": true,

"storageList": [

{

"id": null,

"storeFile": null,

"capacity": null,

"targetBus": null,

"type": null,

"device": null,

"format": null,

"driveType": null,

"assignType": null,

"diskDevice": null,

"mode": null,

"diskSecret": true,

"diskSecUuid": null

}

],

"networkList": [

{

"id": null,

"mac": null,

"vswitchName": null,

"vlan": null,

"outAvgBand": null,

"inAvgBand": null,

"inBurst": null,

"outBurst": null,

"mode": null,

"profileName": null,

"portgroupUUID": null,

"networkPortGroupId": null,

"networkPortGroupName": null,

"netLimitProfileId": null,

"netLimitProfileName": null,

"isDpdk": true

}

]

}

}

2.9.5分发虚拟机模板

接口地址

PUT  /NSphere/api/vm-template-resource/distribution

接口描述

分发虚拟机模板。

请求数据类型

application/json

响应数据类型

application/json

请求示例

{

"id": 0,

"targetHostId": 0,

"storagePoolName": "",

"storagePoolTitle": "",

"cover": true

}

请求参数

参数名称

参数说明

请求类型

必须

数据类型

schema

apiTemplateDistributionParaDTO

分发虚拟机模板实体信息。

body

true

ApiTemplateDistributionParaDTO

ApiTemplateDistributionParaDTO

id

虚拟机模板ID。

true

integer(int64)

targetHostId

目的主机ID。

true

integer(int64)

storagePoolName

目的存储池名称。

true

string

storagePoolTitle

目的存储池显示名称。

true

string

cover

是否覆盖。true 覆盖 false 不覆盖

true

boolean

响应状态

状态码

说明

schema

200

OK

ApiResponseApiTaskMsgVO

响应参数

参数名称

参数说明

类型

schema

state

状态码 0: 成功, 1: 失败, 2: 部分成功

integer(int32)

integer(int32)

errorCode

错误码 当不为0表示业务发生错误

integer(int32)

integer(int32)

successMessage

成功消息

string

failureMessage

错误消息,失败或者部分成功时有效.

string

data

响应数据,如果状态码为0表示正常的数据返回,如果非0且非空则代表引起异常的必要数据

ApiTaskMsgVO

ApiTaskMsgVO

msgId

消息ID,可用于查询任务进度。

integer(int64)

targetId

任务执行对象ID

integer(int64)

targetName

任务执行对象名称

string

响应示例

{

"state": 0,

"errorCode": 0,

"successMessage": null,

"failureMessage": null,

"data": {

"msgId": 0,

"targetId": null,

"targetName": null

}

}

2.9.6查询虚拟机模板列表

接口地址

GET  /NSphere/api/vm-template-resource/list

接口描述

查询虚拟机模板列表。E0930版本接口新增参数和返回属性。

请求数据类型

application/x-www-form-urlencoded

响应数据类型

application/json

请求参数

参数名称

参数说明

请求类型

必须

数据类型

schema

offset

偏移量。指定从第几条记录开始返回。默认0。

query

false

integer(int32)

limit

每页返回的最大记录数。默认10。

query

false

integer(int32)

sortDir

排序类型,0:不排序,1:升序,2:降序,sortField不为空时默认不排序。

query

false

integer(int32)

sortField

排序字段。支持字段:title,description,cpu,memory,system,kernelType,templetStoragePath,scope,createDate。

query

false

string

hostId

主机ID。E0930版本新增参数。

query

false

integer(int64)

title

虚拟机模板显示名称,支持模糊搜索。E0930版本新增参数。

query

false

string

domainName

虚拟机模板名称,支持模糊搜索。E0930版本新增参数。

query

false

string

description

虚拟机模板描述信息,支持模糊搜索。E0930版本新增参数。

query

false

string

operTimeFrom

虚拟机模板起始创建时间。E0930版本新增参数。

query

false

string

operTimeTo

虚拟机模板截止创建时间。E0930版本新增参数。

query

false

string

kernelType

虚拟机内核类型。 1:aarch64,0:i686(32位)或x86_64。E0930版本新增参数。

query

false

integer(int32)

scope

虚拟机模板的所有者。0 私有 1 公有。E0930版本新增参数。

query

false

integer(int32)

enableUltra

虚拟机是否开启Ultra模式。1:启用,0:不启用。E0930版本新增参数。

query

false

integer(int32)

kaasVm

是否为容器虚拟机模板。E0930版本新增参数。

query

false

boolean

响应状态

状态码

说明

schema

200

OK

ApiResponseApiPagingListResultApiVmTemplateBasicVO

响应参数

参数名称

参数说明

类型

schema

state

状态码 0: 成功, 1: 失败, 2: 部分成功

integer(int32)

integer(int32)

errorCode

错误码 当不为0表示业务发生错误

integer(int32)

integer(int32)

successMessage

成功消息

string

failureMessage

错误消息,失败或者部分成功时有效.

string

data

响应数据,如果状态码为0表示正常的数据返回,如果非0且非空则代表引起异常的必要数据

ApiPagingListResultApiVmTemplateBasicVO

ApiPagingListResultApiVmTemplateBasicVO

data

虚拟机模板概要信息。

array

ApiVmTemplateBasicVO

id

虚拟机模板ID。

integer(int64)

uuid

虚拟机模板UUID。

string

name

虚拟机模板名称。

string

title

虚拟机模板显示名称。

string

description

虚拟机模板描述信息。

string

status

虚拟机模板状态,0:正常;1:维护。开启镜像更新的模板会进入维护状态。

integer(int32)

cpu

虚拟机虚拟CPU个数(CPU个数 * CPU核数)。

integer(int32)

createDate

虚拟机模板创建时间。

string(date-time)

memory

内存,单位MB。

integer(int64)

memoryFormat

内存(带单位展示)

string

memoryInit

显示内存。

number(double)

memoryUnit

内存单位。

string

osVersion

虚拟机模板操作系统信息。

string

storageCapacity

模板存储大小,单位:MB。

integer(int64)

storageCapacityFormat

存储大小(带单位展示)。

string

system

虚拟机模板安装的操作系统。取值:0:Windows;1:Linux;2:BSD

integer(int32)

templetStoragePath

模板存放路径。

string

hugePage

是否开启大页。

boolean

kernelType

虚拟机内核类型。 1:aarch64,0:i686(32位)或x86_64。

integer(int32)

cpuSocket

虚拟机CPU个数。

integer(int32)

cpuCore

虚拟机CPU核数。

integer(int32)

scope

虚拟机模板的可见范围。0 私有 1 公有。

integer(int32)

hostId

虚拟机模板所在主机

integer(int64)

hostName

虚拟机模板所在主机名称

string

hostKernelType

虚拟机模板所在主机内核类型。1:arm,0: x86。

integer(int32)

enableUltra

虚拟机是否开启Ultra模式。1:启用,0或空为不启用。

integer(int32)

clusterId

集群ID。 E0930版本新增属性。

integer(int64)

type

虚拟机模板外部云资源类型(通常=2,即CVM)。 E0930版本新增属性。

integer(int32)

offset

偏移量。指定从第几条记录开始返回。

integer(int32)

size

当前返回的记录数。

integer(int32)

total

数据总量

integer(int64)

响应示例

{

"state": 0,

"errorCode": 0,

"successMessage": null,

"failureMessage": null,

"data": {

"data": [

{

"id": null,

"uuid": null,

"name": null,

"title": null,

"description": null,

"status": null,

"cpu": null,

"createDate": null,

"memory": null,

"memoryFormat": null,

"memoryInit": null,

"memoryUnit": null,

"osVersion": null,

"storageCapacity": null,

"storageCapacityFormat": null,

"system": null,

"templetStoragePath": null,

"hugePage": true,

"kernelType": null,

"cpuSocket": null,

"cpuCore": null,

"scope": null,

"hostId": null,

"hostName": null,

"hostKernelType": null,

"enableUltra": null,

"clusterId": null,

"type": null

}

],

"offset": null,

"size": null,

"total": null

}

}