PVE development library/documentation ?

adoII

Renowned Member
Jan 28, 2010
174
17
83
Hi,
I begin to really like proxmox ve. For our Systems Administration I need to write some scripts e.g. for my own backup routines, for nagios monitoring etc.

For example I need to find out:
Which vms (ids) are running on my cluster
What vm-name has the vm with id xxx
On which node vm xxx is running
If vm xxx is running somewhere in the cluster or not
Physical Disk usage, how big is the qcow2 file of vm xxx

Before I start reiventing the wheel and code all this from scratch, is there a library and/or documentation how I could gather all this information ?
 
Before I start reiventing the wheel and code all this from scratch, is there a library and/or documentation how I could gather all this information ?

We have no stable API, sorry. But you can download the pve-manager sources. There are some very small perl examples in pve-manager/bin/test/ which shows how to connect to the SOAP server (testrpc.pl).

SOAP/perl is quite easy to use. You can simply call all function from lib/PVE/ConfigServer.pm.

For exampl, to get a list of vms:

Code:
#!/usr/bin/perl -w
use strict;
use PVE::Utils;
use PVE::ConfigServer;
use Data::Dumper;
 
my $secret = PVE::Utils::load_auth_secret();
my $ticket = PVE::Utils::create_auth_ticket ($secret, 'root', 'root');
my $conn = PVE::ConfigClient::connect ($ticket);
my $res = $conn->vzlist()->result;
print Dumper($res);

hope that helps.
 
Hmm... And how to find out the ip/hostname of the cluster member where vmid xxx is running ?
 
Using perl code in this thread I've got the next free veid number:

Code:
use strict;
use PVE::Utils;
use PVE::ConfigServer;
use PVE::Cluster;
 
my $secret = PVE::Utils::load_auth_secret();
my $ticket = PVE::Utils::create_auth_ticket ($secret, 'root', 'root');
my $conn = PVE::ConfigClient::connect ($ticket);

my $vzlist = $conn->cluster_vzlist()->result;
my $vmops = PVE::Config::read_file ("vmops");
my $nextveid = PVE::Cluster::get_nextid($vzlist, $vmops);

print $nextveid;

But there is a problem with cluster sync: sometimes straight after I create a machine on a slave node, it return the same VEID, it mean that master isn't update.

My question: how to force master update from perl script?
 
Last edited:

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!