From 4ceaaa9fa2371360c59c97e6f4e4a56ec0e77c68 Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Sat, 23 Nov 2024 14:08:01 +0100 Subject: [PATCH] Provide backward compatibility for configuration. --- dev-example/config.yaml | 2 +- dev-example/kustomization.yaml | 2 +- .../jdrupes/vmoperator/vmaccess/VmAccess.java | 83 +++++++++++-------- webpages/vm-operator/upgrading.md | 13 +++ 4 files changed, 63 insertions(+), 37 deletions(-) diff --git a/dev-example/config.yaml b/dev-example/config.yaml index 1c80ab8..f2e0563 100644 --- a/dev-example/config.yaml +++ b/dev-example/config.yaml @@ -65,7 +65,7 @@ other: - org.jgrapes.webconlet.oidclogin.LoginConlet "/ComponentCollector": - "/VmViewer": + "/VmAccess": displayResource: preferredIpVersion: ipv4 syncPreviewsFor: diff --git a/dev-example/kustomization.yaml b/dev-example/kustomization.yaml index f6e51b8..7dc4a15 100644 --- a/dev-example/kustomization.yaml +++ b/dev-example/kustomization.yaml @@ -79,7 +79,7 @@ patches: other: - org.jgrapes.webconlet.locallogin.LoginConlet "/ComponentCollector": - "/VmViewer": + "/VmAccess": displayResource: preferredIpVersion: ipv4 syncPreviewsFor: diff --git a/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java b/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java index b323084..e1a41ef 100644 --- a/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java +++ b/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java @@ -152,44 +152,57 @@ public class VmAccess extends FreeMarkerConlet { @SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" }) @Handler public void onConfigurationUpdate(ConfigurationUpdate event) { - event.structured(componentPath()).ifPresent(c -> { - try { - var dispRes = (Map) c - .getOrDefault("displayResource", Collections.emptyMap()); - switch ((String) dispRes.getOrDefault("preferredIpVersion", - "")) { - case "ipv6": - preferredIpVersion = Inet6Address.class; - break; - case "ipv4": - default: - preferredIpVersion = Inet4Address.class; - break; + event.structured(componentPath()) + .or(() -> { + var oldConfig = event.structured("/Manager/GuiHttpServer" + + "/ConsoleWeblet/WebConsole/ComponentCollector/VmViewer"); + if (oldConfig.isPresent()) { + logger.warning(() -> "Using configuration with old " + + "component name \"VmViewer\", please update to " + + "\"VmAccess\""); } + return oldConfig; + }) + .ifPresent(c -> { + try { + var dispRes = (Map) c + .getOrDefault("displayResource", + Collections.emptyMap()); + switch ((String) dispRes.getOrDefault("preferredIpVersion", + "")) { + case "ipv6": + preferredIpVersion = Inet6Address.class; + break; + case "ipv4": + default: + preferredIpVersion = Inet4Address.class; + break; + } - // Delete connection file - deleteConnectionFile - = Optional.ofNullable(c.get("deleteConnectionFile")) - .filter(v -> v instanceof String).map(v -> (String) v) - .map(Boolean::parseBoolean).orElse(true); + // Delete connection file + deleteConnectionFile + = Optional.ofNullable(c.get("deleteConnectionFile")) + .filter(v -> v instanceof String) + .map(v -> (String) v) + .map(Boolean::parseBoolean).orElse(true); - // Users or roles for which previews should be synchronized - syncUsers = ((List>) c.getOrDefault( - "syncPreviewsFor", Collections.emptyList())).stream() - .map(m -> m.get("user")) - .filter(s -> s != null).collect(Collectors.toSet()); - logger.finest(() -> "Syncing previews for users: " - + syncUsers.toString()); - syncRoles = ((List>) c.getOrDefault( - "syncPreviewsFor", Collections.emptyList())).stream() - .map(m -> m.get("role")) - .filter(s -> s != null).collect(Collectors.toSet()); - logger.finest(() -> "Syncing previews for roles: " - + syncRoles.toString()); - } catch (ClassCastException e) { - logger.config("Malformed configuration: " + e.getMessage()); - } - }); + // Users or roles for which previews should be synchronized + syncUsers = ((List>) c.getOrDefault( + "syncPreviewsFor", Collections.emptyList())).stream() + .map(m -> m.get("user")) + .filter(s -> s != null).collect(Collectors.toSet()); + logger.finest(() -> "Syncing previews for users: " + + syncUsers.toString()); + syncRoles = ((List>) c.getOrDefault( + "syncPreviewsFor", Collections.emptyList())).stream() + .map(m -> m.get("role")) + .filter(s -> s != null).collect(Collectors.toSet()); + logger.finest(() -> "Syncing previews for roles: " + + syncRoles.toString()); + } catch (ClassCastException e) { + logger.config("Malformed configuration: " + e.getMessage()); + } + }); } private boolean syncPreviews(Session session) { diff --git a/webpages/vm-operator/upgrading.md b/webpages/vm-operator/upgrading.md index ec5da7e..a794ab6 100644 --- a/webpages/vm-operator/upgrading.md +++ b/webpages/vm-operator/upgrading.md @@ -5,6 +5,19 @@ layout: vm-operator # Upgrading +## To version 4.0.0 + +The VmViewer conlet has been renamed to VmAccess. This affects the +[configuration](https://jdrupes.org/vm-operator/user-gui.html). Configuration information using the old path +"/Manager/GuiHttpServer/ConsoleWeblet/WebConsole/ComponentCollector/VmViewer" +is still accepted for backward compatibility, but should be updated. + +The change of name also causes conlets added to the overview page by +users to "disappear" from the GUI. They have to be re-added. + +The latter behavior also applies to the VmConlet conlet which has been +renamed to VmMgmt. + ## To version 3.4.0 Starting with this version, the VM-Operator no longer uses a stateful set