Skip to content

Commit

Permalink
fix: Fix wrong 'n/a' ko status report to tasks managed by GLPI Invent…
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Dec 20, 2023
1 parent b556f8a commit 4c1cad8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ netdiscovery/netinventory:
esx:
* Fix first connection timeout support
* Added --timeout option support to glpi-esx
* Fix wrong 'n/a' ko status report to tasks managed by GLPI Inventory plugin

toolbox:
* fix #533: Fix Toolbox export buttons in inventory results
Expand Down
12 changes: 9 additions & 3 deletions lib/GLPI/Agent/SOAP/VMware.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ sub timeout {
return $self->{ua}->timeout($timeout);
}

sub lastError {
my ($self) = @_;

return $self->{_lastError} // '';
}

sub _send {
my ( $self, $action, $xmlToSend ) = @_;

Expand Down Expand Up @@ -69,7 +75,7 @@ sub _send {
if ( $tmpRef && $tmpRef->{faultstring} ) {
$errorString .= ": " . $tmpRef->{faultstring};
}
$self->{lastError} = $errorString;
$self->{_lastError} = $errorString;
return;
}

Expand Down Expand Up @@ -116,13 +122,13 @@ sub connect {
my ( $self, $user, $password ) = @_;

unless ($user) {
$self->{lastError} = "No user".($self->{lastError} ? "" : " and password").
$self->{_lastError} = "No user".($self->{lastError} ? "" : " and password").
" provided for ESX connection";
return;
}

unless ($password) {
$self->{lastError} = "No password provided for ESX connection";
$self->{_lastError} = "No password provided for ESX connection";
return;
}

Expand Down
7 changes: 5 additions & 2 deletions lib/GLPI/Agent/Task/ESX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sub connect {
timeout => $self->timeout(),
);
if ( !$vpbs->connect( $params{user}, $params{password} ) ) {
$self->lastError($vpbs->{lastError});
$self->lastError($vpbs->lastError() || "Connection failure");
return;
}

Expand Down Expand Up @@ -330,9 +330,12 @@ sub serverInventory {
sub lastError {
my ($self, $error) = @_;

$self->{lastError} = $self->{esx}->lastError()
if $self->{esx};

$self->{lastError} = $error if $error;

return $self->{lastError} || "n/a";
return $self->{lastError};
}

sub timeout {
Expand Down
1 change: 0 additions & 1 deletion lib/GLPI/Agent/Task/NetDiscovery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,6 @@ sub _scanAddressByRemote {
} else {
$error = $esxscan->lastError();
my %errors = (
'n/a' => '',
'405 Method Not Allowed' => 'not supporting VMWare SOAP API'
);
$error = $errors{$error} if $errors{$error};
Expand Down

0 comments on commit 4c1cad8

Please sign in to comment.