From 93f341a06743f93c6dc7da0a34e607fc93b5b4d4 Mon Sep 17 00:00:00 2001 From: Guillaume Bougard Date: Tue, 3 Oct 2023 17:50:13 +0200 Subject: [PATCH] feat: Run esx inventory after esx discovery --- lib/GLPI/Agent/Task/NetDiscovery.pm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/GLPI/Agent/Task/NetDiscovery.pm b/lib/GLPI/Agent/Task/NetDiscovery.pm index 644d0425f..3347872b1 100644 --- a/lib/GLPI/Agent/Task/NetDiscovery.pm +++ b/lib/GLPI/Agent/Task/NetDiscovery.pm @@ -430,15 +430,19 @@ sub run { $inventory->run(); } elsif ($authremote) { - my $credentials = [ - grep { $_->{ID} eq $authremote } @{$jobaddress->{remote_credentials}} - ]; - if ($credentials->{TYPE} eq 'esx') { - # As we still have run the connection part in _scanAddressByRemote(), we reuse the connected object - $esxscan->serverInventory(); - } else { - GLPI::Agent::Task::RemoteInventory->require(); - # TODO Support RemoteInventory task run + my $credentials = first { $_->{ID} eq $authremote } @{$jobaddress->{remote_credentials}}; + if ($credentials) { + my $path; + $path = $self->{target}->getPath() if $self->{target}->isType('local'); + # When target path is agent folder, inventory should be saved in inventory subfolder + $path .= '/inventory' if $path eq '.'; + if ($credentials->{TYPE} eq 'esx' && $esxscan) { + # As we still have run the connection part in _scanAddressByRemote(), we reuse the connected object + $esxscan->serverInventory($path); + } else { + GLPI::Agent::Task::RemoteInventory->require(); + # TODO Support RemoteInventory task run + } } }