proxmox-ve-api-perl's People
Forkers
elbandi dpiquet schatt pmorch japp-0xlabs p5i ebl manwar sauriol fampalio martijnlievaart poptixproxmox-ve-api-perl's Issues
login() API provides no way for caller to investigate error code/msg
The canonical way to login is to:
$host->login() or die ('Couldnt log in to proxmox host');
But what exactly failed? The caller has no idea. login()
should return an error that could be investigated or provide an error() API call for that purpose so proper diagnosis is possible without having to revert to
vi lib/Net/Proxmox/VE/Access.pm
and printf...
If login() changed and returned false on OK, but returned the HTTP::Response / $reponse
on error, one could:
if (my $error = $host->login()) {
die sprintf "Couldn't login. HTTP code: %d status line: %s",
$error->code(),
$error->status_line
}
(In our case,
printf("Code: %d\nStatus Line: %s\n",
$response->code,
$response->status_line
);
printed:
Code: 500
Status Line: 500 Can't connect to proxmox01:8006 (certificate verify failed)
but that is a separate issue - more on that later)
TODO: Implement cluster/backup-info
Net::Proxmox::VE::Cluster doesnt currently implement backup-info
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/backup-info
Json parsing error with threads
I am blocked by using this interesting module because it is unable is parse the JSON response. The parent script who is calling the API's are using threads.
use threads;
use threads::shared;
use Thread::Queue;
Sample error:
2023/08/01 02:31:37 PID5817[undef] WARN TA::Comm::Service::Proxmox::_connect(): 42 : Couldn't log in to proxmox host. ERROR: JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this) at /usr/local/share/perl/5.26.1/Net/Proxmox/VE/Access.pm line 435.
Suggested fix:
` if ( $response->is_success ) {
# my $content = $response->decoded_content;
+ $self->{ticket} = JSON->new->allow_nonref->decode($response->decoded_content)->{data};
- my $login_ticket_data = decode_json( $response->decoded_content );
- $self->{ticket} = $login_ticket_data->{data};
# We use request time as the time to get the json ticket is undetermined,
# id rather have a ticket a few seconds shorter than have a ticket that incorrectly
# says its valid for a couple more
$self->{ticket_timestamp} = $request_time;
print "DEBUG: login successful\n"
if $self->{params}->{debug};
return 1;
}
`
TODO: Implement cluster/nextid
Net::Proxmox::VE::Cluster doesnt currently implement nextid
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/nextid
Intent to relicense under MIT license
See also https://en.wikipedia.org/wiki/MIT_License and https://metacpan.org/pod/Software::License::MIT
Contributors need to sign off:
@mrproper yes
@dpiquet yes (via email)
@pmorch yes
@ebl yes (via email)
@sauriol n/a (code replaced)
@manwar yes
@japp-0xlabs n/a (change was reverting prior changes)
@p5i yes (via email)
TODO: Implement cluster/jobs
Net::Proxmox::VE::Cluster doesnt currently implement jobs
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/jobs
TODO: Implement cluster/metrics
Net::Proxmox::VE::Cluster doesnt currently implement metrics
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/metrcs
TODO: Implement cluster/firewall
Net::Proxmox::VE::Cluster doesnt currently implement firewall
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/firewall
Net::Proxmox::VE's sub action should not print warnings to STDOUT
sub action
has this:
sub action {
...
if ( $response->is_success ) {
...
}
else {
print "WARNING: request failed: " . $request->as_string . "\n";
print "WARNING: response status: " . $response->status_line . "\n";
}
return;
}
No. A library should never print to STDOUT or STDERR.
warn($warning)
is perfectly good for that. Or provide a possibility in the API to handle the warning. Or something other than silently and uncatchably print to STDOUT.
Also, isn't a get
that fails an error, not a warning?
(Actually - for the next person to stumble onto this - it can be caught like this:
my $interfaces;
my $stdout;
{
open local(*STDOUT),'>',\$stdout;
$interfaces = $proxmox->get(
$getVMURL(123) . '/agent/network-get-interfaces'
);
}
if ($stdout) {
# Handle anticipated errors
if ($stdout =~ /response status: 500 QEMU guest agent is not running/ ||
$stdout =~ /response status: 500 No QEMU guest agent configured/) {
return;
} else {
# die on other errors
chomp $stdout;
die sprintf "Got error from %s: %s",
$self->_getVMURL . '/agent/network-get-interfaces',
$stdout;
}
}
)
TODO: Implement cluster/config
Net::Proxmox::VE::Cluster doesnt currently implement config
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/config
TODO: Implement access/tfa
Net::Proxmox::VE::Access doesnt currently implement tfa
API reference https://pve.proxmox.com/pve-docs/api-viewer/index.html#/access/tfa
TODO: remove openvz handling in Nodes, add lxc
openvz has been gone for a while. so please remove it and add lxc support.
https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/lxc
TODO: Implement access/permissions
Net::Proxmox::VE::Access doesnt currently implement "get permissions"
API reference: https://pve.proxmox.com/pve-docs/api-viewer/index.html#/access/permissions
TODO: Implement cluster/replication
Net::Proxmox::VE::Cluster doesnt currently implement replication
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/replication
TODO: Implement cluster/ceph
Net::Proxmox::VE::Cluster doesnt currently implement ceph
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/ceph
TODO: Implement access/openid
Net::Proxmox::VE::Access doesnt currently implement openid
API reference: https://pve.proxmox.com/pve-docs/api-viewer/index.html#/access/openid
TODO: Implement cluster/sdn
Net::Proxmox::VE::Cluster doesnt currently implement sdn
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/sdn
TODO: Implement cluster/acme
Net::Proxmox::VE::Cluster doesnt currently implement acme
API reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/acme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.