Reflect display password changes in status.

This commit is contained in:
Michael Lipp 2024-03-28 16:46:58 +01:00
parent 9209ba0078
commit 383d1c5cca
4 changed files with 69 additions and 0 deletions

View file

@ -1411,6 +1411,11 @@ spec:
Amount of memory in use.
type: string
default: "0"
displayPasswordSerial:
description: >-
Counts changes of the display password.
type: integer
default: 0
conditions:
description: >-
List of component conditions observed

View file

@ -43,6 +43,7 @@ import org.jdrupes.vmoperator.common.K8sDynamicModel;
import org.jdrupes.vmoperator.common.K8sDynamicStub;
import org.jdrupes.vmoperator.runner.qemu.events.BalloonChangeEvent;
import org.jdrupes.vmoperator.runner.qemu.events.ConfigureQemu;
import org.jdrupes.vmoperator.runner.qemu.events.DisplayPasswordChanged;
import org.jdrupes.vmoperator.runner.qemu.events.Exit;
import org.jdrupes.vmoperator.runner.qemu.events.HotpluggableCpuStatus;
import org.jdrupes.vmoperator.runner.qemu.events.RunnerStateChange;
@ -321,6 +322,26 @@ public class StatusUpdater extends Component {
});
}
/**
* On ballon change.
*
* @param event the event
* @throws ApiException
*/
@Handler
public void onDisplayPasswordChanged(DisplayPasswordChanged event)
throws ApiException {
if (vmStub == null) {
return;
}
vmStub.updateStatus(from -> {
JsonObject status = from.status();
status.addProperty("displayPasswordSerial",
status.get("displayPasswordSerial").getAsLong() + 1);
return status;
});
}
/**
* On shutdown.
*

View file

@ -0,0 +1,39 @@
/*
* VM-Operator
* Copyright (C) 2024 Michael N. Lipp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jdrupes.vmoperator.runner.qemu.events;
import com.fasterxml.jackson.databind.JsonNode;
import org.jdrupes.vmoperator.runner.qemu.commands.QmpCommand;
/**
* A {@link MonitorResult} that indicates that the display password has changed.
*/
public class DisplayPasswordChanged extends MonitorResult {
/**
* Instantiates a new display password changed.
*
* @param command the command
* @param response the response
*/
public DisplayPasswordChanged(QmpCommand command, JsonNode response) {
super(command, response);
}
}

View file

@ -25,6 +25,7 @@ import org.jdrupes.vmoperator.runner.qemu.commands.QmpCapabilities;
import org.jdrupes.vmoperator.runner.qemu.commands.QmpCommand;
import org.jdrupes.vmoperator.runner.qemu.commands.QmpDelCpu;
import org.jdrupes.vmoperator.runner.qemu.commands.QmpQueryHotpluggableCpus;
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetDisplayPassword;
import org.jgrapes.core.Channel;
import org.jgrapes.core.Components;
import org.jgrapes.core.Event;
@ -57,6 +58,9 @@ public class MonitorResult extends Event<Void> {
if (command instanceof QmpDelCpu) {
return new CpuDeleted(command, response);
}
if (command instanceof QmpSetDisplayPassword) {
return new DisplayPasswordChanged(command, response);
}
return new MonitorResult(command, response);
}