mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
save-test-data.php: Print a message when we encounter a bad module name (#8274)
* Print a message when we encounter a bad module name (likely a typo) * Raise exception for invalid module name and handle it.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use LibreNMS\Exceptions\InvalidModuleException;
|
||||
use LibreNMS\Util\ModuleTestHelper;
|
||||
use LibreNMS\Util\Snmpsim;
|
||||
|
||||
@@ -106,21 +107,26 @@ if (!$snmpsim->isRunning()) {
|
||||
}
|
||||
|
||||
|
||||
$no_save = isset($options['n']) || isset($options['no-save']);
|
||||
foreach ($os_list as $full_os_name => $parts) {
|
||||
list($target_os, $target_variant) = $parts;
|
||||
echo "OS: $target_os\n";
|
||||
echo "Module: $modules_input\n";
|
||||
if ($target_variant) {
|
||||
echo "Variant: $target_variant\n";
|
||||
}
|
||||
echo PHP_EOL;
|
||||
|
||||
$tester = new ModuleTestHelper($modules, $target_os, $target_variant);
|
||||
|
||||
$test_data = $tester->generateTestData($snmpsim, $no_save);
|
||||
|
||||
if ($no_save) {
|
||||
print_r($test_data);
|
||||
try {
|
||||
$no_save = isset($options['n']) || isset($options['no-save']);
|
||||
foreach ($os_list as $full_os_name => $parts) {
|
||||
list($target_os, $target_variant) = $parts;
|
||||
echo "OS: $target_os\n";
|
||||
echo "Module: $modules_input\n";
|
||||
if ($target_variant) {
|
||||
echo "Variant: $target_variant\n";
|
||||
}
|
||||
echo PHP_EOL;
|
||||
|
||||
|
||||
$tester = new ModuleTestHelper($modules, $target_os, $target_variant);
|
||||
|
||||
$test_data = $tester->generateTestData($snmpsim, $no_save);
|
||||
|
||||
if ($no_save) {
|
||||
print_r($test_data);
|
||||
}
|
||||
}
|
||||
} catch (InvalidModuleException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user