Skip to content

Commit

Permalink
NetInventory PROLOG answer optimization (#451)
Browse files Browse the repository at this point in the history
* feat: Skip netinventory option with no data in XML response to PROLOG

* feat: Limit provided credentials to only the used one for netinventory

* test: Fix unittest
  • Loading branch information
g-bougard committed Dec 12, 2023
1 parent 8a2742b commit 2db75a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 4 additions & 1 deletion inc/networkinventory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ public function run($jobstate)
1,
"Device have no ip"
);
// Return an empty list to avoid adding an option with no data in the joblist
return [];
} else {
// Use general config when threads number is set to 0 on the agent
$param_attrs['THREADS_QUERY'] = $agent->fields["threads_networkinventory"] == 0 ?
Expand Down Expand Up @@ -435,7 +437,8 @@ public function run($jobstate)
"Merged with " . $changestate
);
}
$snmpauthlist = $credentials->find();
// Only keep required snmp credentials
$snmpauthlist = $credentials->find(['id' => $a_extended['snmpcredentials_id']]);
foreach ($snmpauthlist as $snmpauth) {
$auth_node = $pfToolbox->addAuth($snmpauth['id']);
if (count($auth_node)) {
Expand Down
6 changes: 0 additions & 6 deletions tests/Integration/Tasks/NetworkInventoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,6 @@ public function PrinterToInventoryWithIp()
'IP' => '192.168.200.124',
'AUTHSNMP_ID' => 2
]
], [
'AUTHENTICATION' => [
'ID' => 1,
'VERSION' => 1,
'COMMUNITY' => 'public'
]
], [
'AUTHENTICATION' => [
'ID' => 2,
Expand Down

0 comments on commit 2db75a1

Please sign in to comment.