mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -12,7 +12,7 @@ chdir($install_dir);
|
||||
|
||||
$options = getopt(
|
||||
'o:v:m:nf:dh',
|
||||
array(
|
||||
[
|
||||
'os:',
|
||||
'variant:',
|
||||
'modules:',
|
||||
@@ -21,26 +21,24 @@ $options = getopt(
|
||||
'debug',
|
||||
'snmpsim',
|
||||
'help',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$init_modules = array('discovery', 'polling');
|
||||
$init_modules = ['discovery', 'polling'];
|
||||
require $install_dir . '/includes/init.php';
|
||||
|
||||
$debug = (isset($options['d']) || isset($options['debug']));
|
||||
$vdebug = $debug;
|
||||
|
||||
|
||||
if (isset($options['snmpsim'])) {
|
||||
$snmpsim = new Snmpsim();
|
||||
$snmpsim->run();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if (isset($options['h'])
|
||||
|| isset($options['help'])
|
||||
|| !(isset($options['o']) || isset($options['os']) || isset($options['m']) || isset($options['modules']))
|
||||
|| ! (isset($options['o']) || isset($options['os']) || isset($options['m']) || isset($options['modules']))
|
||||
) {
|
||||
echo "Script to update test data. Database data is saved in tests/data.
|
||||
|
||||
@@ -73,7 +71,7 @@ if (isset($options['m'])) {
|
||||
$modules = explode(',', $modules_input);
|
||||
} else {
|
||||
$modules_input = 'all';
|
||||
$modules = array();
|
||||
$modules = [];
|
||||
}
|
||||
|
||||
$full_os_name = $os_name;
|
||||
@@ -86,7 +84,7 @@ if (isset($options['v'])) {
|
||||
$full_os_name = $os_name . '_' . $variant;
|
||||
}
|
||||
|
||||
$os_list = array();
|
||||
$os_list = [];
|
||||
|
||||
if ($os_name) {
|
||||
$os_list = [$full_os_name => [$os_name, $variant]];
|
||||
@@ -97,30 +95,28 @@ if ($os_name) {
|
||||
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";
|
||||
echo "Multiple combinations (".count($os_list).") found.\n";
|
||||
echo "Multiple combinations (" . count($os_list) . ") found.\n";
|
||||
exit(1);
|
||||
}
|
||||
$output_file = $options['f'];
|
||||
}
|
||||
|
||||
|
||||
// Now use the saved data to update the saved database data
|
||||
$snmpsim = new Snmpsim();
|
||||
$snmpsim->fork();
|
||||
$snmpsim_ip = $snmpsim->getIp();
|
||||
$snmpsim_port = $snmpsim->getPort();
|
||||
|
||||
if (!$snmpsim->isRunning()) {
|
||||
if (! $snmpsim->isRunning()) {
|
||||
echo "Failed to start snmpsim, make sure it is installed, working, and there are no bad snmprec files.\n";
|
||||
echo "Run ./scripts/save-test-data.php --snmpsim to see the log output\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$no_save = isset($options['n']) || isset($options['no-save']);
|
||||
foreach ($os_list as $full_os_name => $parts) {
|
||||
list($target_os, $target_variant) = $parts;
|
||||
[$target_os, $target_variant] = $parts;
|
||||
echo "OS: $target_os\n";
|
||||
echo "Module: $modules_input\n";
|
||||
if ($target_variant) {
|
||||
@@ -130,7 +126,7 @@ try {
|
||||
|
||||
\LibreNMS\Util\OS::updateCache(true); // Force update of OS Cache
|
||||
$tester = new ModuleTestHelper($modules, $target_os, $target_variant);
|
||||
if (!$no_save && !empty($output_file)) {
|
||||
if (! $no_save && ! empty($output_file)) {
|
||||
$tester->setJsonSavePath($output_file);
|
||||
}
|
||||
$test_data = $tester->generateTestData($snmpsim, $no_save);
|
||||
|
Reference in New Issue
Block a user