From 48846297dcd1f6f5ae4b09c295b69f2958cf4713 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 3 Nov 2022 16:17:53 +0100 Subject: [dozmod] Add field to configure maximum VM image size --- modules-available/dozmod/lang/de/template-tags.json | 1 + modules-available/dozmod/lang/en/template-tags.json | 5 +++-- modules-available/dozmod/pages/runtimeconfig.inc.php | 6 +++++- modules-available/dozmod/templates/runtimeconfig.html | 6 ++++++ 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 @@ + + {{lang_maxVmHddSizeGb}} + + + +
-- cgit v1.2.3-55-g7522