summaryrefslogtreecommitdiffstats
path: root/modules-available/dozmod
diff options
context:
space:
mode:
authorSimon Rettberg2022-11-03 16:17:53 +0100
committerSimon Rettberg2022-11-03 16:17:53 +0100
commit48846297dcd1f6f5ae4b09c295b69f2958cf4713 (patch)
tree6b0143969e389722c4fd3cb3216e2f9716bf2151 /modules-available/dozmod
parent[dozmod] Fix typo in html (diff)
downloadslx-admin-48846297dcd1f6f5ae4b09c295b69f2958cf4713.tar.gz
slx-admin-48846297dcd1f6f5ae4b09c295b69f2958cf4713.tar.xz
slx-admin-48846297dcd1f6f5ae4b09c295b69f2958cf4713.zip
[dozmod] Add field to configure maximum VM image size
Diffstat (limited to 'modules-available/dozmod')
-rw-r--r--modules-available/dozmod/lang/de/template-tags.json1
-rw-r--r--modules-available/dozmod/lang/en/template-tags.json5
-rw-r--r--modules-available/dozmod/pages/runtimeconfig.inc.php6
-rw-r--r--modules-available/dozmod/templates/runtimeconfig.html6
4 files changed, 15 insertions, 3 deletions
diff --git a/modules-available/dozmod/lang/de/template-tags.json b/modules-available/dozmod/lang/de/template-tags.json
index 8f8b06e1..338e8e42 100644
--- a/modules-available/dozmod/lang/de/template-tags.json
+++ b/modules-available/dozmod/lang/de/template-tags.json
@@ -70,6 +70,7 @@
"lang_maxLectureVisibility": "Sp\u00e4testes Enddatum einer Veranstaltung (Tage in der Zukunft)",
"lang_maxLocationsPerLecture": "Max. explizite Orte pro Veranstaltung",
"lang_maxTransfers": "Maximale Zahl gleichzeitiger Up-\/Downloads pro Benutzer",
+ "lang_maxVmHddSizeGb": "Maximale VM-Gr\u00f6\u00dfe (GiB, 0 = kein Limit)",
"lang_minimized": "Minimiert",
"lang_miscOptions": "Verschiedene Einstellungen",
"lang_modified": "Modifiziert",
diff --git a/modules-available/dozmod/lang/en/template-tags.json b/modules-available/dozmod/lang/en/template-tags.json
index c052551c..b741e03d 100644
--- a/modules-available/dozmod/lang/en/template-tags.json
+++ b/modules-available/dozmod/lang/en/template-tags.json
@@ -67,9 +67,10 @@
"lang_mailDescription": "Fill in the following fields if you want to notify tutors\/professors\/lecturers about expiring VMs and lectures. If you leave one of the required fields blank, the feature will be disabled.",
"lang_mailTemplates": "E-Mail Templates",
"lang_maxImageValidity": "New VM validity (days)",
- "lang_maxLectureVisibility": "Max time lecture end date may lie in the future (days)",
+ "lang_maxLectureVisibility": "Max. time lecture end date may lie in the future (days)",
"lang_maxLocationsPerLecture": "Max. explicit locations per lecture",
- "lang_maxTransfers": "Max concurrent transfers per user",
+ "lang_maxTransfers": "Max. concurrent transfers per user",
+ "lang_maxVmHddSizeGb": "Max. VM size (GiB, 0 = unlimited)",
"lang_minimized": "Minimized",
"lang_miscOptions": "Misc options",
"lang_modified": "modified",
diff --git a/modules-available/dozmod/pages/runtimeconfig.inc.php b/modules-available/dozmod/pages/runtimeconfig.inc.php
index 50023414..5f441980 100644
--- a/modules-available/dozmod/pages/runtimeconfig.inc.php
+++ b/modules-available/dozmod/pages/runtimeconfig.inc.php
@@ -37,7 +37,7 @@ class SubPage
];
foreach ($params as $type => $list) {
foreach ($list as $field => $limits) {
- $default = isset($limits['default']) ? $limits['default'] : false;
+ $default = $limits['default'] ?? false;
$value = Request::post($field, $default, $type);
if (isset($limits['min']) && $value < $limits['min']) {
$value = $limits['min'];
@@ -53,6 +53,8 @@ class SubPage
if (!in_array($data['serverSideCopy'], ['OFF', 'ON', 'AUTO', 'USER'])) {
$data['serverSideCopy'] = 'OFF';
}
+ // VM size limit
+ $data['vmSizeLimit'] = ceil(max(0, Request::post('vmSizeLimit', '0', 'float') * 1024 * 1024 * 1024));
/* ensure types */
settype($data['defaultLecturePermissions']['edit'], 'boolean');
@@ -62,6 +64,7 @@ class SubPage
settype($data['defaultImagePermissions']['link'], 'boolean');
settype($data['defaultImagePermissions']['download'], 'boolean');
+ // Write to DB - java server app wil reload this periodically
$data = json_encode($data);
Database::exec('INSERT INTO sat.configuration (parameter, value)'
. ' VALUES (:param, :value)'
@@ -110,6 +113,7 @@ class SubPage
if (isset($runtimeConf['serverSideCopy'])) {
$runtimeConf[$runtimeConf['serverSideCopy'] . '_selected'] = 'selected';
}
+ $runtimeConf['vmSizeLimit'] = ceil(($runtimeConf['vmSizeLimit'] ?? 0) / (1024 * 1024 * 1024));
}
$runtimeConf['allowedSave'] = User::hasPermission("runtimeconfig.save");
Render::addTemplate('runtimeconfig', $runtimeConf);
diff --git a/modules-available/dozmod/templates/runtimeconfig.html b/modules-available/dozmod/templates/runtimeconfig.html
index db895f6d..1540042d 100644
--- a/modules-available/dozmod/templates/runtimeconfig.html
+++ b/modules-available/dozmod/templates/runtimeconfig.html
@@ -94,6 +94,12 @@
<input name="maxTransfers" class="form-control" type="number" value="{{maxTransfers}}" min="1" max="10" pattern="^\d+$">
</td>
</tr>
+ <tr class="input-group">
+ <td class="input-group-addon">{{lang_maxVmHddSizeGb}}</td>
+ <td>
+ <input name="vmSizeLimit" class="form-control" type="number" value="{{vmSizeLimit}}" min="0" max="65535" pattern="\d+">
+ </td>
+ </tr>
</table>
</fieldset>
<br>