Net::Proxmox::VE - Pure perl API for Proxmox virtualisation
version 0.33
use Net::Proxmox::VE; %args = ( host => 'proxmox.local.domain', password => 'barpassword', username => 'root', # optional port => 8006, # optional realm => 'pam', # optional ); $host = Net::Proxmox::VE->new(%args); $host->login() or die ('Couldn\'t log in to proxmox host');
This Class provides the framework for talking to Proxmox VE 2.0 API instances. This just provides a get/delete/put/post abstraction layer as methods on Proxmox VE REST API This also handles the ticket headers required for authentication
More details on the API can be found here: http://pve.proxmox.com/wiki/Proxmox_VE_API http://pve.proxmox.com/pve2-api-doc/
This class provides the building blocks for someone wanting to use PHP to talk to Proxmox 2.0. Relatively simple piece of code, just provides a get/put/post/delete abstraction layer as methods on top of Proxmox's REST API, while also handling the Login Ticket headers required for authentication.
We are still moving things around and trying to come up with something that makes sense. We havent yet implemented all the API functions, so far we only have a basic internal abstraction of the REST interface and a few modules for each function tree within the API.
Any enchancements are greatly appreciated ! (use github, link below)
Please dont be offended if we refactor and rework submissions. Perltidy with default settings is prefered style.
Oh, our tests are all against a running server. Care to help make them better?
This API would be far nicer if it returned nice objects representing different aspects of the system. Such an arrangement would be far better than how this module is currently layed out. It might also be less repetitive code.
This calls raw actions against your proxmox server. Ideally you don't use this directly.
Returns the API version of the proxmox server we are talking to
Checks that the api we are talking to is at least version 2.0
Returns true if the api version is at least 2.0 (perl style true or false)
Has a single optional argument of 1 or 0 representing enable or disable debugging.
Undef (ie no argument) leaves the debug status untouched, making this method call simply a query.
Returns the resultant debug status (perl style true or false)
An action helper method that just takes a path as an argument and returns the value of action() with the DELETE method
An action helper method that just takes a path as an argument and returns the value of action with the GET method
Creates the Net::Proxmox::VE object and returns it.
Examples...
my $obj = Net::Proxmox::VE->new(%args); my $obj = Net::Proxmox::VE->new(\%args);
Valid arguments are...
Proxmox host instance to interact with. Required so no default.
User name used for authentication. Defaults to 'root', optional.
Pass word user for authentication. Required so no default.
TCP port number used to by the Proxmox host instance. Defaults to 8006, optional.
Authentication realm to request against. Defaults to 'pam' (local auth), optional.
If you're using a self-signed certificate, SSL verification is going to fail, and we need to tell IO::Socket::SSL not to attempt certificate verification.
IO::Socket::SSL
This option is passed on as ssl_opts options to LWP::UserAgent->new(), ultimately for IO::Socket::SSL.
ssl_opts
LWP::UserAgent->new()
Using it like this, causes LWP::UserAgent and IO::Socket::SSL not to attempt SSL verification:
LWP::UserAgent
use IO::Socket::SSL qw(SSL_VERIFY_NONE); .. %args = ( ... ssl_opts => { SSL_verify_mode => SSL_VERIFY_NONE, verify_hostname => 0 }, ... ); my $proxmox = Net::Proxmox::VE->new(%args);
Your connection will work now, but beware: you are now susceptible to a man-in-the-middle attack.
Enabling debugging of this API (not related to proxmox debugging in any way). Defaults to false, optional.
An action helper method that takes two parameters: $path, \%post_data $path to post to, hash ref to %post_data
You are returned what action() with the POST method returns
An action helper method that takes two parameters: path hash ref to post data your returned what post returns
returns the url prefix used in the rest api calls
http://www.proxmox.com
http://pve.proxmox.com/pve2-api-doc
Brendan Beveridge <brendan@nodeintegration.com.au>, Dean Hamstead <dean@bytefoundry.com.au>
This software is copyright (c) 2018 by Dean Hamstad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::Proxmox::VE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Proxmox::VE
CPAN shell
perl -MCPAN -e shell install Net::Proxmox::VE
For more information on module installation, please visit the detailed CPAN module installation guide.