From 63732422cc6647a6b0bb718e626e9feaa982e7fe Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Tue, 11 Dec 2018 11:29:16 +0100 Subject: [PATCH] fix proxmox ve (#1270) --- apps/proxmox/ve/restapi/custom/api.pm | 7 +++++-- apps/proxmox/ve/restapi/mode/listnodes.pm | 6 +++--- apps/proxmox/ve/restapi/mode/liststorages.pm | 8 ++++---- apps/proxmox/ve/restapi/mode/listvms.pm | 10 +++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/apps/proxmox/ve/restapi/custom/api.pm b/apps/proxmox/ve/restapi/custom/api.pm index 2ab741aab..02ab53215 100644 --- a/apps/proxmox/ve/restapi/custom/api.pm +++ b/apps/proxmox/ve/restapi/custom/api.pm @@ -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 { @@ -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'; @@ -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(); } diff --git a/apps/proxmox/ve/restapi/mode/listnodes.pm b/apps/proxmox/ve/restapi/mode/listnodes.pm index 9d292d27c..3c213c63b 100644 --- a/apps/proxmox/ve/restapi/mode/listnodes.pm +++ b/apps/proxmox/ve/restapi/mode/listnodes.pm @@ -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} . "']" ); } diff --git a/apps/proxmox/ve/restapi/mode/liststorages.pm b/apps/proxmox/ve/restapi/mode/liststorages.pm index e33508c07..f1fa4fb5e 100644 --- a/apps/proxmox/ve/restapi/mode/liststorages.pm +++ b/apps/proxmox/ve/restapi/mode/liststorages.pm @@ -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} . "']" ); } diff --git a/apps/proxmox/ve/restapi/mode/listvms.pm b/apps/proxmox/ve/restapi/mode/listvms.pm index e486d2162..82d2db5d8 100644 --- a/apps/proxmox/ve/restapi/mode/listvms.pm +++ b/apps/proxmox/ve/restapi/mode/listvms.pm @@ -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} . "']" ); }