Clarify pipeline usage.

This commit is contained in:
Michael Lipp 2025-03-20 18:02:14 +01:00
parent 16a15bc9ad
commit 359b1fdb84
3 changed files with 14 additions and 16 deletions

View file

@ -310,8 +310,7 @@ public class VmMonitor extends
event.setResult(new VmData(vmDef, chosenVm)); event.setResult(new VmData(vmDef, chosenVm));
// Make sure that a newly assigned VM is running. // Make sure that a newly assigned VM is running.
chosenVm.pipeline().fire(new ModifyVm(vmDef.name(), chosenVm.fire(new ModifyVm(vmDef.name(), "state", "Running"));
"state", "Running", chosenVm));
return; return;
} }
} }

View file

@ -129,6 +129,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
private EventPipeline appPipeline; private EventPipeline appPipeline;
private static ObjectMapper objectMapper private static ObjectMapper objectMapper
= new ObjectMapper().registerModule(new JavaTimeModule()); = new ObjectMapper().registerModule(new JavaTimeModule());
private Class<?> preferredIpVersion = Inet4Address.class; private Class<?> preferredIpVersion = Inet4Address.class;
private Set<String> syncUsers = Collections.emptySet(); private Set<String> syncUsers = Collections.emptySet();
private Set<String> syncRoles = Collections.emptySet(); private Set<String> syncRoles = Collections.emptySet();
@ -785,12 +786,12 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
switch (event.method()) { switch (event.method()) {
case "start": case "start":
if (perms.contains(VmDefinition.Permission.START)) { if (perms.contains(VmDefinition.Permission.START)) {
fire(new ModifyVm(vmName, "state", "Running", vmChannel)); vmChannel.fire(new ModifyVm(vmName, "state", "Running"));
} }
break; break;
case "stop": case "stop":
if (perms.contains(VmDefinition.Permission.STOP)) { if (perms.contains(VmDefinition.Permission.STOP)) {
fire(new ModifyVm(vmName, "state", "Stopped", vmChannel)); vmChannel.fire(new ModifyVm(vmName, "state", "Stopped"));
} }
break; break;
case "reset": case "reset":
@ -800,7 +801,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
break; break;
case "resetConfirmed": case "resetConfirmed":
if (perms.contains(VmDefinition.Permission.RESET)) { if (perms.contains(VmDefinition.Permission.RESET)) {
fire(new ResetVm(vmName), vmChannel); vmChannel.fire(new ResetVm(vmName));
} }
break; break;
case "openConsole": case "openConsole":
@ -838,7 +839,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
} }
var pwQuery = Event.onCompletion(new GetDisplaySecret(vmDef, user), var pwQuery = Event.onCompletion(new GetDisplaySecret(vmDef, user),
e -> gotPassword(channel, model, vmDef, e)); e -> gotPassword(channel, model, vmDef, e));
fire(pwQuery, vmChannel); vmChannel.fire(pwQuery);
} }
private void gotPassword(ConsoleConnection channel, ResourceModel model, private void gotPassword(ConsoleConnection channel, ResourceModel model,

View file

@ -423,12 +423,12 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
switch (event.method()) { switch (event.method()) {
case "start": case "start":
if (perms.contains(VmDefinition.Permission.START)) { if (perms.contains(VmDefinition.Permission.START)) {
fire(new ModifyVm(vmName, "state", "Running", vmChannel)); vmChannel.fire(new ModifyVm(vmName, "state", "Running"));
} }
break; break;
case "stop": case "stop":
if (perms.contains(VmDefinition.Permission.STOP)) { if (perms.contains(VmDefinition.Permission.STOP)) {
fire(new ModifyVm(vmName, "state", "Stopped", vmChannel)); vmChannel.fire(new ModifyVm(vmName, "state", "Stopped"));
} }
break; break;
case "reset": case "reset":
@ -438,22 +438,20 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
break; break;
case "resetConfirmed": case "resetConfirmed":
if (perms.contains(VmDefinition.Permission.RESET)) { if (perms.contains(VmDefinition.Permission.RESET)) {
fire(new ResetVm(vmName), vmChannel); vmChannel.fire(new ResetVm(vmName));
} }
break; break;
case "openConsole": case "openConsole":
openConsole(channel, model, vmChannel, vmDef, user, perms); openConsole(channel, model, vmChannel, vmDef, user, perms);
break; break;
case "cpus": case "cpus":
fire(new ModifyVm(vmName, "currentCpus", vmChannel.fire(new ModifyVm(vmName, "currentCpus",
new BigDecimal(event.param(1).toString()).toBigInteger(), new BigDecimal(event.param(1).toString()).toBigInteger()));
vmChannel));
break; break;
case "ram": case "ram":
fire(new ModifyVm(vmName, "currentRam", vmChannel.fire(new ModifyVm(vmName, "currentRam",
new Quantity(new BigDecimal(event.param(1).toString()), new Quantity(new BigDecimal(event.param(1).toString()),
Format.BINARY_SI).toSuffixedString(), Format.BINARY_SI).toSuffixedString()));
vmChannel));
break; break;
default:// ignore default:// ignore
break; break;
@ -488,7 +486,7 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
} }
var pwQuery = Event.onCompletion(new GetDisplaySecret(vmDef, user), var pwQuery = Event.onCompletion(new GetDisplaySecret(vmDef, user),
e -> gotPassword(channel, model, vmDef, e)); e -> gotPassword(channel, model, vmDef, e));
fire(pwQuery, vmChannel); vmChannel.fire(pwQuery);
} }
private void gotPassword(ConsoleConnection channel, VmsModel model, private void gotPassword(ConsoleConnection channel, VmsModel model,