Automated VM creation using API

  • Thread starter Thread starter kusman
  • Start date Start date
K

kusman

Guest
I require a way to create new VMs (openVZ) from templates automatically using proxmox API. I looked at the openVZ section of the API and I couldn't find a possibility to create new VMs. Is this possible? If yes, what is the API call to do it?

Thanks.
 
PUSH /nodes/{node}/openvz -ostemplate <string> -vmid <integer> [OPTIONS]

Thank you very much. I have checked the api page and indeed the POST method has this, I was looking at GET options only. This is very nice.
 
You can use 'pvesh' for testing the api:

# pvesh help /nodes/localhost/openvz
help [path] [--verbose]
cd [path]
ls [path]

create /nodes/{node}/openvz -ostemplate <string> -vmid <integer> [OPTIONS]
delete /nodes/{node}/openvz/{vmid}

To create container 555 use:

# pvesh create /nodes/localhost/openvz -ostemplate local:vztmpl/debian-6.0-standard_6.0-4_i386.tar.gz -vmid 555

To list all templates on local storage:

# pvesm list local -content vztmpl
local:vztmpl/centos-5-standard_5.6-1_i386.tar.gz tgz 181390534
local:vztmpl/debian-6.0-joomla_1.6-3_i386.tar.gz tgz 182693140
local:vztmpl/debian-6.0-standard_6.0-4_i386.tar.gz tgz 143694277

And finally delete the container:

# pvesh delete /nodes/localhost/openvz/555
 
You can use 'pvesh' for testing the api:

# pvesh help /nodes/localhost/openvz
help [path] [--verbose]
cd [path]
ls [path]

create /nodes/{node}/openvz -ostemplate <string> -vmid <integer> [OPTIONS]
delete /nodes/{node}/openvz/{vmid}

To create container 555 use:

# pvesh create /nodes/localhost/openvz -ostemplate local:vztmpl/debian-6.0-standard_6.0-4_i386.tar.gz -vmid 555

To list all templates on local storage:

# pvesm list local -content vztmpl
local:vztmpl/centos-5-standard_5.6-1_i386.tar.gz tgz 181390534
local:vztmpl/debian-6.0-joomla_1.6-3_i386.tar.gz tgz 182693140
local:vztmpl/debian-6.0-standard_6.0-4_i386.tar.gz tgz 143694277

And finally delete the container:

# pvesh delete /nodes/localhost/openvz/555

Thank you, this is extremely helpful. I have reviewed the POST api a bit more with pvesh as well and it seems to be full featured and a lot is possible.

Your support is also top notch, thank you for helping.