创建虚拟机
测试中
POST
/api/v1/{nodeType}/cerateVM
最后修改时间:2025-01-01 01:50:37
责任人:mryunqi
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Basic 之后拼接空格,以及经过 Base64 编码的 username:password
示例:
Authorization: Basic *****************
Path 参数
nodeType
string
必需
示例值:
pve
Body 参数application/json
nodeid
integer
节点ID
hostname
string | null
虚拟机名
configureTemplateId
integer | null
配置模板ID
sockets
integer | null
插槽数,默认为1
cores
integer | null
核心,默认1
threads
integer | null
线程数,默认1
devirtualization
boolean | null
可选
kvm
boolean | null
可选
cpuModel
integer | null
cpu信息模型ID
modelGroup
integer | null
可选
nested
boolean | null
可选
cpu
string | null
可选
cpuUnits
integer | null
可选
bwlimit
integer | null
可选
flowLimit
integer | null
可选
usedFlow
number | null
可选
arch
string | null
可选
acpi
string | null
可选
memory
integer | null
可选
storage
string | null
可选
systemDiskSize
integer | null
可选
mbpsRd
integer | null
可选
mbpsRdMax
integer | null
可选
mbpsWr
integer | null
可选
mbpsWrMax
integer | null
可选
iopsRd
integer | null
可选
iopsRdMax
integer | null
可选
iopsWr
integer | null
可选
iopsWrMax
integer | null
可选
dataDisk
可选
bridge
string | null
网桥
ipConfig
可选
os
string
必需
osType
string | null
可选
bandwidth
integer | null
带宽,单位Mbps
onBoot
integer | null
可选
username
string | null
虚拟机登录用户名
password
string | null
虚拟机登录密码
expirationTime
integer | null
到期时间,时间戳
ifnat
integer | null
是否开启nat
natnum
integer | null
nat端口转发数量
示例
{
"nodeid": 1,
"hostname": "cloud-test01",
"sockets": 1,
"cores": 2,
"threads": 2,
"nested": false,
"modelGroup": 2,
"cpu": "host",
"arch": "x86_64",
"memory": 512,
"storage": "auto",
"systemDiskSize": 40,
"os": "CentOS-8-Stream-x64.qcow2",
"osType": "linux",
"bandwidth": 100,
"ipConfig": {
"1": ""
},
"dataDisk": {
"1": 40
},
"onBoot": 1,
"username": "root",
"password": "123456",
"ifnat": 1,
"natnum": 10
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST '/api/v1/pve/cerateVM' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic Og==' \
--data-raw '{
"nodeid": 1,
"hostname": "cloud-test01",
"sockets": 1,
"cores": 2,
"threads": 2,
"nested": false,
"modelGroup": 2,
"cpu": "host",
"arch": "x86_64",
"memory": 512,
"storage": "auto",
"systemDiskSize": 40,
"os": "CentOS-8-Stream-x64.qcow2",
"osType": "linux",
"bandwidth": 100,
"ipConfig": {
"1": ""
},
"dataDisk": {
"1": 40
},
"onBoot": 1,
"username": "root",
"password": "123456",
"ifnat": 1,
"natnum": 10
}'
返回响应
🟢200成功
application/json
Body
code
integer
必需
message
string
必需
data
object
必需
nodeid
integer
必需
hostid
integer
必需
vmid
integer
必需
hostname
string
必需
configureTemplateId
null
必需
sockets
integer
必需
cores
integer
必需
threads
integer
必需
nested
boolean
必需
devirtualization
boolean
必需
kvm
boolean
必需
cpuModel
null
必需
modelGroup
integer
必需
cpu
string
必需
cpuUnits
integer
必需
args
null
必需
arch
string
必需
acpi
integer
必需
memory
integer
必需
swap
null
必需
storage
string
必需
systemDiskSize
integer
必需
dataDisk
object
必需
bridge
string
必需
ipConfig
object
必需
dns1
string
必需
os
string
必需
osType
string
必需
iso
null
必需
template
null
必需
onBoot
integer
必需
bandwidth
integer
必需
username
string
必需
password
string
必需
task
null
必需
status
null
必需
expirationTime
null
必需
示例
{
"code": 20000,
"message": "请求成功",
"data": {
"nodeid": 1,
"hostid": 34,
"vmid": 102,
"hostname": "cloud-test01",
"configureTemplateId": null,
"sockets": 1,
"cores": 2,
"threads": 2,
"nested": false,
"devirtualization": false,
"kvm": true,
"cpuModel": null,
"modelGroup": 2,
"cpu": "host",
"cpuUnits": 1024,
"args": null,
"arch": "x86_64",
"acpi": 1,
"memory": 512,
"swap": null,
"storage": "local-lvm",
"systemDiskSize": 40,
"dataDisk": {
"1": 40
},
"bridge": "vmbr0",
"ipConfig": {
"1": "ip=192.168.36.1/24,gw=192.168.36.2"
},
"dns1": "114.114.114.114",
"os": "CentOS-8-Stream-x64.qcow2",
"osType": "linux",
"iso": null,
"template": null,
"onBoot": 1,
"bandwidth": 100,
"username": "root",
"password": "123456",
"task": null,
"status": null,
"expirationTime": null
}
}
修改于 2025-01-01 01:50:37