summaryrefslogtreecommitdiffstats
path: root/modules-available/vmstore
diff options
context:
space:
mode:
authorSimon Rettberg2023-11-14 14:47:55 +0100
committerSimon Rettberg2023-11-14 14:47:55 +0100
commit06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 (patch)
tree7e5493b102074672d8cfd8fe1a61e49f080edbe8 /modules-available/vmstore
parentUpdate phpstorm config (diff)
downloadslx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.gz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.xz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.zip
Add function param/return types, fix a lot more phpstorm complaints
Diffstat (limited to 'modules-available/vmstore')
-rw-r--r--modules-available/vmstore/baseconfig/getconfig.inc.php4
-rw-r--r--modules-available/vmstore/inc/vmstorebenchmark.inc.php6
-rw-r--r--modules-available/vmstore/page.inc.php16
3 files changed, 16 insertions, 10 deletions
diff --git a/modules-available/vmstore/baseconfig/getconfig.inc.php b/modules-available/vmstore/baseconfig/getconfig.inc.php
index 3bad16e1..d239a3d7 100644
--- a/modules-available/vmstore/baseconfig/getconfig.inc.php
+++ b/modules-available/vmstore/baseconfig/getconfig.inc.php
@@ -1,5 +1,8 @@
<?php
+/** @var ?string $uuid */
+/** @var ?string $ip */
+
// VMStore path and type
$vmstore = Property::getVmStoreConfig();
if (is_array($vmstore) && isset($vmstore['storetype'])) {
@@ -21,6 +24,7 @@ if (is_array($vmstore) && isset($vmstore['storetype'])) {
ConfigHolder::add("SLX_VM_NFS_OPTS", $vmstore['cifsopts']);
}
break;
+ default:
}
}
diff --git a/modules-available/vmstore/inc/vmstorebenchmark.inc.php b/modules-available/vmstore/inc/vmstorebenchmark.inc.php
index b13f4e37..b819ef8a 100644
--- a/modules-available/vmstore/inc/vmstorebenchmark.inc.php
+++ b/modules-available/vmstore/inc/vmstorebenchmark.inc.php
@@ -24,13 +24,12 @@ class VmStoreBenchmark
}
/**
- * @param array $machineUuids
* @param string $image relative path/name of image
* @param string $serverOrMode IP address of DNBD3 server, OR 'auto' for all servers known to client, or 'nfs' for NFS
* @param int $start timestamp when the clients should start
* @return ?string taskId, or null on error
*/
- public static function start(string $id, array $machineUuids, string $image, string $serverOrMode, int &$start)
+ public static function start(string $id, array $machineUuids, string $image, string $serverOrMode, int &$start): ?string
{
Module::isAvailable('rebootcontrol');
$clients = Database::queryAll('SELECT machineuuid, clientip FROM machine WHERE machineuuid IN (:uuids)',
@@ -68,6 +67,9 @@ COMMAND;
return $task['id'] ?? null;
}
+ /**
+ * @return array{cpu: array, net: array}
+ */
public static function parseBenchLine(string $line): array
{
$out = ['cpu' => [], 'net' => []];
diff --git a/modules-available/vmstore/page.inc.php b/modules-available/vmstore/page.inc.php
index cf0487f1..b27d47ce 100644
--- a/modules-available/vmstore/page.inc.php
+++ b/modules-available/vmstore/page.inc.php
@@ -12,10 +12,10 @@ class Page_VmStore extends Page
User::load();
if (User::hasPermission('edit')) {
- Dashboard::addSubmenu('?do=vmstore', Dictionary::translate('menu_edit', true));
+ Dashboard::addSubmenu('?do=vmstore', Dictionary::translate('menu_edit'));
}
if (User::hasPermission('benchmark')) {
- Dashboard::addSubmenu('?do=vmstore&show=benchmark', Dictionary::translate('menu_benchmark', true));
+ Dashboard::addSubmenu('?do=vmstore&show=benchmark', Dictionary::translate('menu_benchmark'));
}
if (Request::any('show') === 'benchmark') {
@@ -71,12 +71,12 @@ class Page_VmStore extends Page
Util::redirect('?do=VmStore');
}
// Validate syntax of nfs/cifs
- if ($storetype === 'nfs' && !preg_match('#^\S+:\S+$#is', $vmstore['nfsaddr'])) {
+ if ($storetype === 'nfs' && !preg_match('#^\S+:\S+$#i', $vmstore['nfsaddr'])) {
Message::addError('main.value-invalid', 'nfsaddr', $vmstore['nfsaddr']);
Util::redirect('?do=VmStore');
}
$vmstore['cifsaddr'] = str_replace('\\', '/', $vmstore['cifsaddr']);
- if ($storetype === 'cifs' && !preg_match('#^//\S+/.+$#is', $vmstore['cifsaddr'])) {
+ if ($storetype === 'cifs' && !preg_match('#^//\S+/.+$#i', $vmstore['cifsaddr'])) {
Message::addError('main.value-invalid', 'nfsaddr', $vmstore['nfsaddr']);
Util::redirect('?do=VmStore');
}
@@ -91,7 +91,7 @@ class Page_VmStore extends Page
if (!Module::isAvailable('rebootcontrol')) {
ErrorHandler::traceError('rebootcontrol module not enabled');
}
- Render::setTitle(Dictionary::translate('page-title-benchmark', true));
+ Render::setTitle(Dictionary::translate('page-title-benchmark'));
if (Request::post('action') === 'start') {
$this->benchmarkActionStart();
}
@@ -111,7 +111,7 @@ class Page_VmStore extends Page
}
}
- private function getJobFromId(int $id)
+ private function getJobFromId(int $id): ?array
{
$data = Property::getListEntry(VmStoreBenchmark::PROP_LIST_KEY, $id);
if ($data !== null) {
@@ -202,7 +202,7 @@ class Page_VmStore extends Page
$servers = [];
if (Dnbd3::isEnabled()) {
$servers[] = ['idx' => 'auto',
- 'server' => Dictionary::translate('dnbd3-all-loadbalance', true)];
+ 'server' => Dictionary::translate('dnbd3-all-loadbalance')];
foreach ($lookup as $ip => $idx) {
$servers[] = ['idx' => $idx, 'server' => $ip];
}
@@ -251,7 +251,7 @@ class Page_VmStore extends Page
];
if ($remaining > 0) {
$args['remaining'] = $remaining;
- $args['refresh'] = $refresh;
+ $args['refresh'] = $refresh ?? 60;
}
Module::isAvailable('js_chart');
Render::addTemplate('benchmark-result', $args);