Skip to content

Commit

Permalink
fix: Add --timeout option support to glpi-esx
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Nov 28, 2023
1 parent 02766fe commit aa33b4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ netdiscovery/netinventory:

esx:
* Fix first connection timeout support
* Added --timeout option support to glpi-esx

toolbox:
* fix #533: Fix Toolbox export buttons in inventory results
Expand Down
9 changes: 9 additions & 0 deletions bin/glpi-esx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GetOptions(
'password=s',
'directory=s', # deprecated in favour of path or stdout
'path=s',
't|timeout=i',
'stdout',
'tag=s',
'debug+',
Expand Down Expand Up @@ -67,6 +68,9 @@ my $esx = GLPI::Agent::Task::ESX->new(
),
);

# Set timeout to use during first http connection attempt
$esx->timeout($config->{timeout}) if $options->{timeout};

inventory_from_dump($options->{dumpfile})
if $options->{dumpfile};

Expand All @@ -91,6 +95,10 @@ if (!$esx->connect(
die "Connection failure: ".$esx->lastError()."\n";
}

# Reset timeout to a minimum value for inventory related requests
my $safe_timeout = $config->{'backend-collect-timeout'} // 60;
$esx->timeout($safe_timeout) if $options->{timeout} && $options->{timeout} < $safe_timeout;

$esx->serverInventory($options->{path}, $options->{dump} ? \&dump_from_hostfullinfo : undef);

exit($esx->lastError ? 1 : 0);
Expand Down Expand Up @@ -195,6 +203,7 @@ glpi-esx --host <host> --user <user> --password <password> --path <directory or
--user username user name
--password xxxx user password
--path path output directory or file
-t --timeout sec connection attempt timeout in seconds (defaults to 180)
--stdout dump inventory on stdout (enabled by default if no path is set)
--tag tag tag for the inventoried machine
--json use json as format for generated inventories
Expand Down

0 comments on commit aa33b4a

Please sign in to comment.