mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
save-test-data.php improvements (#16367)
* save-test-data.php improvements Message when snmprec data is not found Output when venv setup fails * Apply fixes from StyleCI --------- Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
|
||||
namespace LibreNMS\Util;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class Snmpsim extends Process
|
||||
@ -75,15 +76,25 @@ class Snmpsim extends Process
|
||||
$snmpsim_venv_path = $this->getVenvPath();
|
||||
|
||||
if (! $this->isVenvSetUp()) {
|
||||
\Log::info('Setting up snmpsim virtual env in ' . $snmpsim_venv_path);
|
||||
Log::info('Setting up snmpsim virtual env in ' . $snmpsim_venv_path);
|
||||
|
||||
$setupProcess = new Process(['python', '-m', 'venv', $snmpsim_venv_path]);
|
||||
$setupProcess->setTty($print_output);
|
||||
$setupProcess->run();
|
||||
|
||||
if (! $setupProcess->isSuccessful()) {
|
||||
Log::info($setupProcess->getOutput());
|
||||
Log::error($setupProcess->getErrorOutput());
|
||||
}
|
||||
|
||||
$installProcess = new Process([$snmpsim_venv_path . '/bin/pip', 'install', 'snmpsim']);
|
||||
$installProcess->setTty($print_output);
|
||||
$installProcess->run();
|
||||
|
||||
if (! $installProcess->isSuccessful()) {
|
||||
Log::info($installProcess->getOutput());
|
||||
Log::error($installProcess->getErrorOutput());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,12 @@ if (isset($os_name) && isset($variant)) {
|
||||
$os_list = ModuleTestHelper::findOsWithData($modules);
|
||||
}
|
||||
|
||||
if (empty($os_list)) {
|
||||
echo "No matching snmprec(s) found.\n";
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($options['f'])) {
|
||||
if (count($os_list) != 1) {
|
||||
echo "Failed to create test data, -f/--file option can be used with one os/variant combination.\n";
|
||||
@ -113,7 +119,7 @@ if (isset($options['f'])) {
|
||||
|
||||
// Now use the saved data to update the saved database data
|
||||
$snmpsim = new Snmpsim();
|
||||
$snmpsim->setupVenv();
|
||||
$snmpsim->setupVenv(true);
|
||||
$snmpsim->start();
|
||||
echo "Waiting for snmpsim to initialize...\n";
|
||||
$snmpsim->waitForStartup();
|
||||
|
Reference in New Issue
Block a user