Provide backward compatibility for configuration.
This commit is contained in:
parent
2be88d0f34
commit
4ceaaa9fa2
4 changed files with 63 additions and 37 deletions
|
|
@ -65,7 +65,7 @@
|
|||
other:
|
||||
- org.jgrapes.webconlet.oidclogin.LoginConlet
|
||||
"/ComponentCollector":
|
||||
"/VmViewer":
|
||||
"/VmAccess":
|
||||
displayResource:
|
||||
preferredIpVersion: ipv4
|
||||
syncPreviewsFor:
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ patches:
|
|||
other:
|
||||
- org.jgrapes.webconlet.locallogin.LoginConlet
|
||||
"/ComponentCollector":
|
||||
"/VmViewer":
|
||||
"/VmAccess":
|
||||
displayResource:
|
||||
preferredIpVersion: ipv4
|
||||
syncPreviewsFor:
|
||||
|
|
|
|||
|
|
@ -152,44 +152,57 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ViewerModel> {
|
|||
@SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" })
|
||||
@Handler
|
||||
public void onConfigurationUpdate(ConfigurationUpdate event) {
|
||||
event.structured(componentPath()).ifPresent(c -> {
|
||||
try {
|
||||
var dispRes = (Map<String, Object>) 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<String, Object>) 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<Map<String, String>>) 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<Map<String, String>>) 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<Map<String, String>>) 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<Map<String, String>>) 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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue