Skip to content

Commit

Permalink
fix proxmox ve (centreon#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgagnaire authored and arnaud-michel committed Dec 18, 2018
1 parent 8270423 commit ef3b264
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
7 changes: 5 additions & 2 deletions apps/proxmox/ve/restapi/custom/api.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use strict;
use warnings;
use centreon::plugins::http;
use centreon::plugins::statefile;
use JSON:XS;
use JSON::XS;
use Digest::MD5 qw(md5_hex);

sub new {
Expand Down Expand Up @@ -98,6 +98,9 @@ sub check_options {
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef;
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8006;
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
$self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? $self->{option_results}->{proxyurl} : undef;
$self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef;
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : undef;
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : undef;
$self->{realm} = (defined($self->{option_results}->{realm})) ? $self->{option_results}->{realm} : 'pam';
Expand Down Expand Up @@ -185,7 +188,7 @@ sub get_ticket {
$self->{output}->option_exit();
}
if (!defined($decoded->{data}->{ticket})) {
$self->{output}->output_add(long_msg => $decoded, debug => 1);
$self->{output}->output_add(long_msg => $content, debug => 1);
$self->{output}->add_option_msg(short_msg => "Error retrieving ticket");
$self->{output}->option_exit();
}
Expand Down
6 changes: 3 additions & 3 deletions apps/proxmox/ve/restapi/mode/listnodes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ sub run {

$self->manage_selection(%options);
foreach my $node_id (sort keys %{$self->{nodes}}) {
$self->{output}->output_add(long_msg => '[id = ' . $node_id . "] " .
" [name = '" . $self->{nodes}->{$node_id}->{Name} . "']" .
" [state = '" . $self->{nodes}->{$node_id}->{State} . "']"
$self->{output}->output_add(long_msg => '[id = ' . $node_id . "]" .
"[name = '" . $self->{nodes}->{$node_id}->{Name} . "']" .
"[state = '" . $self->{nodes}->{$node_id}->{State} . "']"
);
}

Expand Down
8 changes: 4 additions & 4 deletions apps/proxmox/ve/restapi/mode/liststorages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ sub run {

$self->manage_selection(%options);
foreach my $storage_id (sort keys %{$self->{storages}}) {
$self->{output}->output_add(long_msg => '[id = ' . $storage_id . "] " .
" [name = '" . $self->{storages}->{$storage_id}->{Name} . "']" .
" [node = '" . $self->{storages}->{$storage_id}->{Node} . "']" .
" [state = '" . $self->{storages}->{$storage_id}->{State} . "']"
$self->{output}->output_add(long_msg => '[id = ' . $storage_id . "]" .
"[name = '" . $self->{storages}->{$storage_id}->{Name} . "']" .
"[node = '" . $self->{storages}->{$storage_id}->{Node} . "']" .
"[state = '" . $self->{storages}->{$storage_id}->{State} . "']"
);
}

Expand Down
10 changes: 5 additions & 5 deletions apps/proxmox/ve/restapi/mode/listvms.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ sub run {

$self->manage_selection(%options);
foreach my $vm_id (sort keys %{$self->{vms}}) {
$self->{output}->output_add(long_msg => '[id = ' . $vm_id . "] [name = '" . $self->{vms}->{$vm_id}->{Name} . "']" .
" [node = '" . $self->{vms}->{$vm_id}->{Node} . "']" .
" [state = '" . $self->{vms}->{$vm_id}->{State} . "']" .
" [vmid = '" . $self->{vms}->{$vm_id}->{Vmid} . "']" .
" [type = '" . $self->{vms}->{$vm_id}->{Type} . "']"
$self->{output}->output_add(long_msg => '[id = ' . $vm_id . "][name = '" . $self->{vms}->{$vm_id}->{Name} . "']" .
"[node = '" . $self->{vms}->{$vm_id}->{Node} . "']" .
"[state = '" . $self->{vms}->{$vm_id}->{State} . "']" .
"[vmid = '" . $self->{vms}->{$vm_id}->{Vmid} . "']" .
"[type = '" . $self->{vms}->{$vm_id}->{Type} . "']"
);
}

Expand Down

0 comments on commit ef3b264

Please sign in to comment.