Create LXC via API

x86

New Member
Aug 19, 2014
21
0
1
Hi,

I am trying to create a LXC via PHP API but I get a error ...
'HTTP Error - HTTP/1.1 500 can't find file 'debian-8.0-CUSTOM_8.0-1_amd64''.
But I am sure that the template exists.

I guess that my script is not correct, as there are no api examples ...
PHP:
$sTemplateName = 'debian-8.0-CUSTOM_8.0-1_amd64'; // .tar.gz
$sNodeName     = 'ns3302305';
$aServerSpecs  = array ( );

// Specs
$aServerSpecs [ 'ostemplate' ] = $sTemplateName;
$aServerSpecs [ 'vmid' ]       = $pApi->get_next_vmid ( );
$aServerSpecs [ 'hostname' ]   = 'MyServer';
$aServerSpecs [ 'password' ]   = 'ByeBye321';

// CPU
$aServerSpecs [ 'arch' ]     = 'amd64';
$aServerSpecs [ 'cpulimit' ] = 1;
$aServerSpecs [ 'cpuunits' ] = 1000;

// Memory
$aServerSpecs [ 'memory' ] = '512';
$aServerSpecs [ 'swap' ]   = '512';

// HDD
$aServerSpecs [ 'rootfs' ]  = 'volume=local:10,format=raw'; // ?
//$aServerSpecs [ 'storage' ] = ''; // ?

// Network
$aServerSpecs [ 'net0' ] = 'bridge=vmbr3,hwaddr=12:34:56:78:90:AB,ip=dhcp,ip6=dhcp,name=eth0,type=veth';


// Create
var_dump ( $pApi->post ( '/nodes/' . $sNodeName . '/lxc', $aServerSpecs ) );

I hope someone can help me, thanks!
 
You must provide either the full path or include a storage (eg: `local:iso/debian-foo.tar.gz') and include the file extension
 
Still doesn't work, tried:
"local:template/cache/debian-8.0-CUSTOM_8.0-1_amd64.tar.gz"
"local:template/debian-8.0-CUSTOM_8.0-1_amd64.tar.gz"
"local:cache/debian-8.0-CUSTOM_8.0-1_amd64.tar.gz"
"local:iso/debian-8.0-CUSTOM_8.0-1_amd64.tar.gz"

The file is located here:
/var/lib/vz/template/cache/debian-8.0-CUSTOM_8.0-1_amd64.tar.gz
 
Fixed it by using:
local:vztmpl/debian-8.0-CUSTOM_8.0-1_amd64.tar.gz
Strange that 'template' doesn't work.

'rootfs' parameter should be a number (afaik) to define how big the HDD should be, i.e.:
'rootfs' = '10';
This will create a 10GB raw HDD.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!