mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 02:18:39 +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:
parent
fc9b77c672
commit
674bb7e9f8
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
namespace LibreNMS\Util;
|
namespace LibreNMS\Util;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
class Snmpsim extends Process
|
class Snmpsim extends Process
|
||||||
@ -75,15 +76,25 @@ class Snmpsim extends Process
|
|||||||
$snmpsim_venv_path = $this->getVenvPath();
|
$snmpsim_venv_path = $this->getVenvPath();
|
||||||
|
|
||||||
if (! $this->isVenvSetUp()) {
|
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 = new Process(['python', '-m', 'venv', $snmpsim_venv_path]);
|
||||||
$setupProcess->setTty($print_output);
|
$setupProcess->setTty($print_output);
|
||||||
$setupProcess->run();
|
$setupProcess->run();
|
||||||
|
|
||||||
|
if (! $setupProcess->isSuccessful()) {
|
||||||
|
Log::info($setupProcess->getOutput());
|
||||||
|
Log::error($setupProcess->getErrorOutput());
|
||||||
|
}
|
||||||
|
|
||||||
$installProcess = new Process([$snmpsim_venv_path . '/bin/pip', 'install', 'snmpsim']);
|
$installProcess = new Process([$snmpsim_venv_path . '/bin/pip', 'install', 'snmpsim']);
|
||||||
$installProcess->setTty($print_output);
|
$installProcess->setTty($print_output);
|
||||||
$installProcess->run();
|
$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);
|
$os_list = ModuleTestHelper::findOsWithData($modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($os_list)) {
|
||||||
|
echo "No matching snmprec(s) found.\n";
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['f'])) {
|
if (isset($options['f'])) {
|
||||||
if (count($os_list) != 1) {
|
if (count($os_list) != 1) {
|
||||||
echo "Failed to create test data, -f/--file option can be used with one os/variant combination.\n";
|
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
|
// Now use the saved data to update the saved database data
|
||||||
$snmpsim = new Snmpsim();
|
$snmpsim = new Snmpsim();
|
||||||
$snmpsim->setupVenv();
|
$snmpsim->setupVenv(true);
|
||||||
$snmpsim->start();
|
$snmpsim->start();
|
||||||
echo "Waiting for snmpsim to initialize...\n";
|
echo "Waiting for snmpsim to initialize...\n";
|
||||||
$snmpsim->waitForStartup();
|
$snmpsim->waitForStartup();
|
||||||
|
Loading…
Reference in New Issue
Block a user