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));
// Make sure that a newly assigned VM is running.
chosenVm.pipeline().fire(new ModifyVm(vmDef.name(),
"state", "Running", chosenVm));
chosenVm.fire(new ModifyVm(vmDef.name(), "state", "Running"));
return;
}
}

View file

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

View file

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