Compare commits
10 commits
5bcf0ba051
...
7b8df80828
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b8df80828 | |||
| fccf2a6b65 | |||
| 00e9affee4 | |||
| fa84110e1d | |||
| 76b579c404 | |||
| a5433c869b | |||
| 10f3028f06 | |||
| b7fad4614d | |||
| 7d298ce24b | |||
| 6ef4c2aaa2 |
17 changed files with 157 additions and 89 deletions
|
|
@ -24,7 +24,7 @@ stages:
|
|||
- "*/build"
|
||||
before_script:
|
||||
- echo -n $CI_REGISTRY_PASSWORD | podman login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
|
||||
- git switch $(git branch -r --sort="authordate" --contains $CI_COMMIT_SHA | head -1 | sed -e 's#[^/]*/##')
|
||||
- git switch $(git branch -r --sort="authordate" --contains $CI_COMMIT_SHA | head -1 | sed -e 's#.*/##')
|
||||
- git pull
|
||||
- git reset --hard $CI_COMMIT_SHA
|
||||
|
||||
|
|
|
|||
3
dev-example/vmop-agent/gdm/PostLogin/Default
Executable file
3
dev-example/vmop-agent/gdm/PostLogin/Default
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf
|
||||
|
|
@ -72,8 +72,8 @@ doLogin() {
|
|||
return
|
||||
fi
|
||||
|
||||
# Check if this user is already logged in on tty1
|
||||
curUser=$(loginctl -j | jq -r '.[] | select(.tty=="tty1") | .user')
|
||||
# Check if this user is already logged in on tty2
|
||||
curUser=$(loginctl -j | jq -r '.[] | select(.tty=="tty2") | .user')
|
||||
if [ "$curUser" = "$user" ]; then
|
||||
echo >&${con} "201 User already logged in"
|
||||
return
|
||||
|
|
@ -97,16 +97,13 @@ doLogin() {
|
|||
fi
|
||||
fi
|
||||
|
||||
# Start the desktop for the user
|
||||
systemd-run 2>$temperr \
|
||||
--unit vmop-user-desktop --uid=$uid --gid=$uid \
|
||||
--working-directory="/home/$user" -p TTYPath=/dev/tty1 \
|
||||
-p PAMName=login -p StandardInput=tty -p StandardOutput=journal \
|
||||
-p Conflicts="gdm.service getty@tty1.service" \
|
||||
-E XDG_RUNTIME_DIR="/run/user/$uid" \
|
||||
-E XDG_CURRENT_DESKTOP=GNOME \
|
||||
-p ExecStartPre="/usr/bin/chvt 1" \
|
||||
dbus-run-session -- gnome-shell --display-server --wayland
|
||||
# Configure user as auto login user
|
||||
sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf
|
||||
sed -i '/\[daemon\]/a AutomaticLoginEnable=true\nAutomaticLogin='$user \
|
||||
/etc/gdm/custom.conf
|
||||
|
||||
# Activate user
|
||||
systemctl restart gdm
|
||||
if [ $? -eq 0 ]; then
|
||||
echo >&${con} "201 User logged in successfully"
|
||||
else
|
||||
|
|
@ -117,14 +114,8 @@ doLogin() {
|
|||
# Attempt to log out a user currently using tty1. This is an intermediate
|
||||
# operation that can be invoked from other operations
|
||||
attemptLogout() {
|
||||
systemctl status vmop-user-desktop > /dev/null 2>&1
|
||||
if [ $? = 0 ]; then
|
||||
systemctl stop vmop-user-desktop
|
||||
fi
|
||||
loginctl -j | jq -r '.[] | select(.tty=="tty1") | .session' \
|
||||
| while read sid; do
|
||||
loginctl kill-session $sid
|
||||
done
|
||||
sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf
|
||||
systemctl stop gdm
|
||||
echo >&${con} "102 Desktop stopped"
|
||||
}
|
||||
|
||||
|
|
@ -133,15 +124,7 @@ attemptLogout() {
|
|||
# Also try to restart gdm, if it is not running.
|
||||
doLogout() {
|
||||
attemptLogout
|
||||
systemctl status gdm >/dev/null 2>&1
|
||||
if [ $? != 0 ]; then
|
||||
systemctl restart gdm 2>$temperr
|
||||
if [ $? -eq 0 ]; then
|
||||
echo >&${con} "102 gdm restarted"
|
||||
else
|
||||
echo >&${con} "102 Restarting gdm failed: $(tr '\n' ' ' <${temperr})"
|
||||
fi
|
||||
fi
|
||||
systemctl restart gdm
|
||||
echo >&${con} "202 User logged out"
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +136,7 @@ while read line <&${con}; do
|
|||
done
|
||||
|
||||
onExit() {
|
||||
attemptLogout
|
||||
doLogout
|
||||
if [ -n "$temperr" ]; then
|
||||
rm -f $temperr
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@ public class K8sClusterGenericStub<O extends KubernetesObject,
|
|||
* @param <L> the object list type
|
||||
* @param <R> the result type
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface GenericSupplier<O extends KubernetesObject,
|
||||
L extends KubernetesListObject,
|
||||
R extends K8sClusterGenericStub<O, L>> {
|
||||
|
|
|
|||
|
|
@ -359,6 +359,7 @@ public class K8sGenericStub<O extends KubernetesObject,
|
|||
* @param <L> the object list type
|
||||
* @param <R> the result type
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface GenericSupplier<O extends KubernetesObject,
|
||||
L extends KubernetesListObject, R extends K8sGenericStub<O, L>> {
|
||||
|
||||
|
|
|
|||
|
|
@ -118,14 +118,14 @@ public class VmExtraData {
|
|||
if (addr.isEmpty()) {
|
||||
logger
|
||||
.severe(() -> "Failed to find display IP for " + vmDef.name());
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
var port = vmDef.<Number> fromVm("display", "spice", "port")
|
||||
.map(Number::longValue);
|
||||
if (port.isEmpty()) {
|
||||
logger
|
||||
.severe(() -> "No port defined for display of " + vmDef.name());
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
StringBuffer data = new StringBuffer(100)
|
||||
.append("[virt-viewer]\ntype=spice\nhost=")
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ dependencies {
|
|||
implementation 'org.jgrapes:org.jgrapes.io:[2.12.1,3)'
|
||||
implementation 'org.jgrapes:org.jgrapes.http:[3.5.0,4)'
|
||||
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.2.0,3)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.3.0,3)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.vuejs:[1.8.0,2)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.rbac:[1.4.0,2)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconlet.oidclogin:[1.7.0,2)'
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ data:
|
|||
# The template to use. Resolved relative to /usr/share/vmrunner/templates.
|
||||
# template: "Standard-VM-latest.ftl.yaml"
|
||||
<#if spec.runnerTemplate?? && spec.runnerTemplate.source?? >
|
||||
template: ${ cm.spec().runnerTemplate.source }
|
||||
template: ${ spec.runnerTemplate.source }
|
||||
</#if>
|
||||
|
||||
# The template is copied to the data diretory when the VM starts for
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import org.jdrupes.vmoperator.manager.events.VmPoolChanged;
|
|||
import org.jdrupes.vmoperator.manager.events.VmResourceChanged;
|
||||
import org.jgrapes.core.Channel;
|
||||
import org.jgrapes.core.Component;
|
||||
import org.jgrapes.core.EventPipeline;
|
||||
import org.jgrapes.core.annotation.Handler;
|
||||
import org.jgrapes.core.events.HandlingError;
|
||||
import org.jgrapes.core.events.Start;
|
||||
|
|
@ -94,7 +95,7 @@ import org.jgrapes.util.events.ConfigurationUpdate;
|
|||
public class Controller extends Component {
|
||||
|
||||
private String namespace;
|
||||
private final ChannelManager<String, VmChannel, ?> chanMgr;
|
||||
private final ChannelManager<String, VmChannel, EventPipeline> chanMgr;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ import org.jose4j.base64url.Base64;
|
|||
* * `passwordValidity`: the validity of the random password in seconds.
|
||||
* Used to calculate the password expiry time in the generated secret.
|
||||
*/
|
||||
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.TooManyStaticImports" })
|
||||
public class DisplaySecretReconciler extends Component {
|
||||
|
||||
protected final Logger logger = Logger.getLogger(getClass().getName());
|
||||
|
|
@ -104,12 +103,15 @@ public class DisplaySecretReconciler extends Component {
|
|||
return oldConfig;
|
||||
}).ifPresent(c -> {
|
||||
try {
|
||||
if (c.containsKey("passwordValidity")) {
|
||||
passwordValidity = Integer
|
||||
.parseInt((String) c.get("passwordValidity"));
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
logger.config("Malformed configuration: " + e.getMessage());
|
||||
Optional.ofNullable(c.get("passwordValidity"))
|
||||
.map(p -> p instanceof Integer ? (Integer) p
|
||||
: Integer.valueOf((String) p))
|
||||
.ifPresent(p -> {
|
||||
passwordValidity = p;
|
||||
});
|
||||
} catch (NumberFormatException e) {
|
||||
logger.warning(
|
||||
() -> "Malformed configuration: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -190,7 +192,6 @@ public class DisplaySecretReconciler extends Component {
|
|||
* @throws ApiException the api exception
|
||||
*/
|
||||
@Handler
|
||||
@SuppressWarnings("PMD.StringInstantiation")
|
||||
public void onGetDisplaySecret(GetDisplaySecret event, VmChannel channel)
|
||||
throws ApiException {
|
||||
// Get VM definition and check if running
|
||||
|
|
@ -319,7 +320,6 @@ public class DisplaySecretReconciler extends Component {
|
|||
/**
|
||||
* The Class PendingGet.
|
||||
*/
|
||||
@SuppressWarnings("PMD.DataClass")
|
||||
private static class PendingRequest {
|
||||
public final GetDisplaySecret event;
|
||||
public final long expectedSerial;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.google.gson.JsonObject;
|
|||
import io.kubernetes.client.apimachinery.GroupVersionKind;
|
||||
import io.kubernetes.client.custom.V1Patch;
|
||||
import io.kubernetes.client.openapi.ApiException;
|
||||
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||
import io.kubernetes.client.util.Watch;
|
||||
import io.kubernetes.client.util.generic.options.ListOptions;
|
||||
import java.io.IOException;
|
||||
|
|
@ -32,7 +31,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import org.jdrupes.vmoperator.common.Constants.Crd;
|
||||
import org.jdrupes.vmoperator.common.Constants.Status;
|
||||
|
|
@ -57,16 +55,28 @@ import org.jdrupes.vmoperator.manager.events.VmResourceChanged;
|
|||
import org.jdrupes.vmoperator.util.GsonPtr;
|
||||
import org.jgrapes.core.Channel;
|
||||
import org.jgrapes.core.Event;
|
||||
import org.jgrapes.core.EventPipeline;
|
||||
import org.jgrapes.core.annotation.Handler;
|
||||
|
||||
/**
|
||||
* Watches for changes of VM definitions.
|
||||
* Watches for changes of VM definitions. When a VM definition (CR)
|
||||
* becomes known, is is registered with a {@link ChannelManager} and thus
|
||||
* gets an associated {@link VmChannel} and an associated
|
||||
* {@link EventPipeline}.
|
||||
*
|
||||
* The {@link EventPipeline} is used for submitting an action that processes
|
||||
* the change data from kubernetes, eventually transforming it to a
|
||||
* {@link VmResourceChanged} event that is handled by another
|
||||
* {@link EventPipeline} associated with the {@link VmChannel}. This
|
||||
* event pipeline should be used for all events related to changes of
|
||||
* a particular VM.
|
||||
*/
|
||||
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" })
|
||||
public class VmMonitor extends
|
||||
AbstractMonitor<VmDefinition, VmDefinitions, VmChannel> {
|
||||
|
||||
private final ChannelManager<String, VmChannel, ?> channelManager;
|
||||
private final ChannelManager<String, VmChannel,
|
||||
EventPipeline> channelManager;
|
||||
|
||||
/**
|
||||
* Instantiates a new VM definition watcher.
|
||||
|
|
@ -75,7 +85,7 @@ public class VmMonitor extends
|
|||
* @param channelManager the channel manager
|
||||
*/
|
||||
public VmMonitor(Channel componentChannel,
|
||||
ChannelManager<String, VmChannel, ?> channelManager) {
|
||||
ChannelManager<String, VmChannel, EventPipeline> channelManager) {
|
||||
super(componentChannel, VmDefinition.class,
|
||||
VmDefinitions.class);
|
||||
this.channelManager = channelManager;
|
||||
|
|
@ -122,14 +132,18 @@ public class VmMonitor extends
|
|||
@Override
|
||||
protected void handleChange(K8sClient client,
|
||||
Watch.Response<VmDefinition> response) {
|
||||
V1ObjectMeta metadata = response.object.getMetadata();
|
||||
AtomicBoolean toBeAdded = new AtomicBoolean(false);
|
||||
VmChannel channel = channelManager.channel(metadata.getName())
|
||||
.orElseGet(() -> {
|
||||
toBeAdded.set(true);
|
||||
return channelManager.createChannel(metadata.getName());
|
||||
});
|
||||
var name = response.object.getMetadata().getName();
|
||||
|
||||
// Process the response data on a VM specific pipeline to
|
||||
// increase concurrency when e.g. starting many VMs.
|
||||
var preparing = channelManager.associated(name)
|
||||
.orElseGet(() -> newEventPipeline());
|
||||
preparing.submit("VmChange[" + name + "]",
|
||||
() -> processChange(client, response, preparing));
|
||||
}
|
||||
|
||||
private void processChange(K8sClient client,
|
||||
Watch.Response<VmDefinition> response, EventPipeline preparing) {
|
||||
// Get full definition and associate with channel as backup
|
||||
var vmDef = response.object;
|
||||
if (vmDef.data() == null) {
|
||||
|
|
@ -137,6 +151,9 @@ public class VmMonitor extends
|
|||
// https://github.com/kubernetes-client/java/issues/3215
|
||||
vmDef = getModel(client, vmDef);
|
||||
}
|
||||
var name = response.object.getMetadata().getName();
|
||||
var channel = channelManager.channel(name)
|
||||
.orElseGet(() -> channelManager.createChannel(name));
|
||||
if (vmDef.data() != null) {
|
||||
// New data, augment and save
|
||||
addExtraData(vmDef, channel.vmDefinition());
|
||||
|
|
@ -150,9 +167,7 @@ public class VmMonitor extends
|
|||
+ response.object.getMetadata());
|
||||
return;
|
||||
}
|
||||
if (toBeAdded.get()) {
|
||||
channelManager.put(vmDef.name(), channel);
|
||||
}
|
||||
channelManager.put(name, channel, preparing);
|
||||
|
||||
// Create and fire changed event. Remove channel from channel
|
||||
// manager on completion.
|
||||
|
|
@ -199,9 +214,16 @@ public class VmMonitor extends
|
|||
@Handler
|
||||
public void onPodChanged(PodChanged event, VmChannel channel) {
|
||||
var vmDef = channel.vmDefinition();
|
||||
updateNodeInfo(event, vmDef);
|
||||
channel
|
||||
.fire(new VmResourceChanged(ResponseType.MODIFIED, vmDef, false, true));
|
||||
|
||||
// Make sure that this is properly sync'd with VM CR changes.
|
||||
channelManager.associated(vmDef.name())
|
||||
.orElseGet(() -> activeEventPipeline())
|
||||
.submit("NodeInfo[" + vmDef.name() + "]",
|
||||
() -> {
|
||||
updateNodeInfo(event, vmDef);
|
||||
channel.fire(new VmResourceChanged(ResponseType.MODIFIED,
|
||||
vmDef, false, true));
|
||||
});
|
||||
}
|
||||
|
||||
private void updateNodeInfo(PodChanged event, VmDefinition vmDef) {
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@ public class GuestAgentClient extends AgentConnector {
|
|||
*/
|
||||
@Override
|
||||
protected void agentConnected() {
|
||||
logger.fine(() -> "guest agent connected");
|
||||
logger.fine(() -> "Guest agent connected");
|
||||
connected = true;
|
||||
rep().fire(new GuestAgentCommand(new QmpGuestGetOsinfo()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void agentDisconnected() {
|
||||
logger.fine(() -> "guest agent disconnected");
|
||||
logger.fine(() -> "Guest agent disconnected");
|
||||
connected = false;
|
||||
}
|
||||
|
||||
|
|
@ -88,15 +88,16 @@ public class GuestAgentClient extends AgentConnector {
|
|||
*/
|
||||
@Override
|
||||
protected void processInput(String line) throws IOException {
|
||||
logger.fine(() -> "guest agent(in): " + line);
|
||||
logger.finer(() -> "guest agent(in): " + line);
|
||||
try {
|
||||
var response = mapper.readValue(line, ObjectNode.class);
|
||||
if (response.has("return") || response.has("error")) {
|
||||
QmpCommand executed = executing.poll();
|
||||
logger.fine(() -> String.format("(Previous \"guest agent(in)\""
|
||||
logger.finer(() -> String.format("(Previous \"guest agent(in)\""
|
||||
+ " is result from executing %s)", executed));
|
||||
if (executed instanceof QmpGuestGetOsinfo) {
|
||||
var osInfo = new OsinfoEvent(response.get("return"));
|
||||
logger.fine(() -> "Guest agent triggers: " + osInfo);
|
||||
rep().fire(osInfo);
|
||||
}
|
||||
}
|
||||
|
|
@ -120,10 +121,11 @@ public class GuestAgentClient extends AgentConnector {
|
|||
return;
|
||||
}
|
||||
var command = event.command();
|
||||
logger.fine(() -> "guest agent(out): " + command.toString());
|
||||
logger.fine(() -> "Guest handles: " + event);
|
||||
String asText;
|
||||
try {
|
||||
asText = command.asText();
|
||||
logger.finer(() -> "guest agent(out): " + asText);
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.log(Level.SEVERE, e,
|
||||
() -> "Cannot serialize Json: " + e.getMessage());
|
||||
|
|
@ -163,8 +165,8 @@ public class GuestAgentClient extends AgentConnector {
|
|||
}
|
||||
event.suspendHandling();
|
||||
suspendedStop = event;
|
||||
logger.fine(() -> "Sending powerdown command, waiting for"
|
||||
+ " termination until " + waitUntil);
|
||||
logger.fine(() -> "Attempting shutdown through guest agent,"
|
||||
+ " waiting for termination until " + waitUntil);
|
||||
powerdownTimer = Components.schedule(t -> {
|
||||
logger.fine(() -> "Powerdown timeout reached.");
|
||||
synchronized (this) {
|
||||
|
|
|
|||
|
|
@ -108,24 +108,30 @@ public class QemuMonitor extends QemuConnector {
|
|||
@Override
|
||||
protected void processInput(String line)
|
||||
throws IOException {
|
||||
logger.fine(() -> "monitor(in): " + line);
|
||||
logger.finer(() -> "monitor(in): " + line);
|
||||
try {
|
||||
var response = mapper.readValue(line, ObjectNode.class);
|
||||
if (response.has("QMP")) {
|
||||
monitorReady = true;
|
||||
logger.fine(() -> "QMP connection ready");
|
||||
rep().fire(new MonitorReady());
|
||||
return;
|
||||
}
|
||||
if (response.has("return") || response.has("error")) {
|
||||
QmpCommand executed = executing.poll();
|
||||
logger.fine(
|
||||
logger.finer(
|
||||
() -> String.format("(Previous \"monitor(in)\" is result "
|
||||
+ "from executing %s)", executed));
|
||||
rep().fire(MonitorResult.from(executed, response));
|
||||
var monRes = MonitorResult.from(executed, response);
|
||||
logger.fine(() -> "QMP triggers: " + monRes);
|
||||
rep().fire(monRes);
|
||||
return;
|
||||
}
|
||||
if (response.has("event")) {
|
||||
MonitorEvent.from(response).ifPresent(rep()::fire);
|
||||
MonitorEvent.from(response).ifPresent(me -> {
|
||||
logger.fine(() -> "QMP triggers: " + me);
|
||||
rep().fire(me);
|
||||
});
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new IOException(e);
|
||||
|
|
@ -141,7 +147,7 @@ public class QemuMonitor extends QemuConnector {
|
|||
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
||||
channel.associated(this, getClass()).ifPresent(qm -> {
|
||||
super.onClosed(event, channel);
|
||||
logger.finer(() -> "QMP socket closed.");
|
||||
logger.fine(() -> "QMP connection closed.");
|
||||
monitorReady = false;
|
||||
});
|
||||
}
|
||||
|
|
@ -158,7 +164,7 @@ public class QemuMonitor extends QemuConnector {
|
|||
public void onMonitorCommand(MonitorCommand event) throws IOException {
|
||||
// Check prerequisites
|
||||
if (!monitorReady && !(event.command() instanceof QmpCapabilities)) {
|
||||
logger.severe(() -> "Premature monitor command (not ready): "
|
||||
logger.severe(() -> "Premature QMP command (not ready): "
|
||||
+ event.command());
|
||||
rep().fire(new Stop());
|
||||
return;
|
||||
|
|
@ -166,10 +172,11 @@ public class QemuMonitor extends QemuConnector {
|
|||
|
||||
// Send the command
|
||||
var command = event.command();
|
||||
logger.fine(() -> "monitor(out): " + command.toString());
|
||||
logger.fine(() -> "QMP handles: " + event.toString());
|
||||
String asText;
|
||||
try {
|
||||
asText = command.asText();
|
||||
logger.finer(() -> "monitor(out): " + asText);
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.log(Level.SEVERE, e,
|
||||
() -> "Cannot serialize Json: " + e.getMessage());
|
||||
|
|
@ -192,8 +199,8 @@ public class QemuMonitor extends QemuConnector {
|
|||
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||
public void onStop(Stop event) {
|
||||
if (!monitorReady) {
|
||||
logger.fine(() -> "No QMP connection,"
|
||||
+ " cannot send powerdown command");
|
||||
logger.fine(() -> "Not sending QMP powerdown command"
|
||||
+ " because QMP connection is closed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,10 +59,14 @@ public class VmopAgentClient extends AgentConnector {
|
|||
*/
|
||||
@Handler
|
||||
public void onVmopAgentLogIn(VmopAgentLogIn event) throws IOException {
|
||||
logger.fine(() -> "vmop agent(out): login " + event.user());
|
||||
if (writer().isPresent()) {
|
||||
logger.fine(() -> "Vmop agent handles:" + event);
|
||||
executing.add(event);
|
||||
logger.finer(() -> "vmop agent(out): login " + event.user());
|
||||
sendCommand("login " + event.user());
|
||||
} else {
|
||||
logger
|
||||
.warning(() -> "No vmop agent connection for sending " + event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,9 +78,10 @@ public class VmopAgentClient extends AgentConnector {
|
|||
*/
|
||||
@Handler
|
||||
public void onVmopAgentLogout(VmopAgentLogOut event) throws IOException {
|
||||
logger.fine(() -> "vmop agent(out): logout");
|
||||
if (writer().isPresent()) {
|
||||
logger.fine(() -> "Vmop agent handles:" + event);
|
||||
executing.add(event);
|
||||
logger.finer(() -> "vmop agent(out): logout");
|
||||
sendCommand("logout");
|
||||
}
|
||||
}
|
||||
|
|
@ -85,23 +90,27 @@ public class VmopAgentClient extends AgentConnector {
|
|||
@SuppressWarnings({ "PMD.UnnecessaryReturn",
|
||||
"PMD.AvoidLiteralsInIfCondition" })
|
||||
protected void processInput(String line) throws IOException {
|
||||
logger.fine(() -> "vmop agent(in): " + line);
|
||||
logger.finer(() -> "vmop agent(in): " + line);
|
||||
|
||||
// Check validity
|
||||
if (line.isEmpty() || !Character.isDigit(line.charAt(0))) {
|
||||
logger.warning(() -> "Illegal response: " + line);
|
||||
logger.warning(() -> "Illegal vmop agent response: " + line);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check positive responses
|
||||
if (line.startsWith("220 ")) {
|
||||
rep().fire(new VmopAgentConnected());
|
||||
var evt = new VmopAgentConnected();
|
||||
logger.fine(() -> "Vmop agent triggers " + evt);
|
||||
rep().fire(evt);
|
||||
return;
|
||||
}
|
||||
if (line.startsWith("201 ")) {
|
||||
Event<?> cmd = executing.pop();
|
||||
if (cmd instanceof VmopAgentLogIn login) {
|
||||
rep().fire(new VmopAgentLoggedIn(login));
|
||||
var evt = new VmopAgentLoggedIn(login);
|
||||
logger.fine(() -> "Vmop agent triggers " + evt);
|
||||
rep().fire(evt);
|
||||
} else {
|
||||
logger.severe(() -> "Response " + line
|
||||
+ " does not match executing command " + cmd);
|
||||
|
|
@ -111,7 +120,9 @@ public class VmopAgentClient extends AgentConnector {
|
|||
if (line.startsWith("202 ")) {
|
||||
Event<?> cmd = executing.pop();
|
||||
if (cmd instanceof VmopAgentLogOut logout) {
|
||||
rep().fire(new VmopAgentLoggedOut(logout));
|
||||
var evt = new VmopAgentLoggedOut(logout);
|
||||
logger.fine(() -> "Vmop agent triggers " + evt);
|
||||
rep().fire(evt);
|
||||
} else {
|
||||
logger.severe(() -> "Response " + line
|
||||
+ "does not match executing command " + cmd);
|
||||
|
|
@ -125,7 +136,7 @@ public class VmopAgentClient extends AgentConnector {
|
|||
}
|
||||
|
||||
// Error
|
||||
logger.warning(() -> "Error response: " + line);
|
||||
logger.warning(() -> "Error response from vmop agent: " + line);
|
||||
executing.pop();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ package org.jdrupes.vmoperator.runner.qemu.events;
|
|||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import java.util.Optional;
|
||||
import org.jgrapes.core.Channel;
|
||||
import org.jgrapes.core.Components;
|
||||
import org.jgrapes.core.Event;
|
||||
|
||||
/**
|
||||
|
|
@ -112,4 +114,20 @@ public class MonitorEvent extends Event<Void> {
|
|||
public JsonNode data() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(Components.objectName(this)).append(" [").append(data);
|
||||
if (channels() != null) {
|
||||
builder.append(", channels=").append(Channel.toString(channels()));
|
||||
}
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
package org.jdrupes.vmoperator.runner.qemu.events;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.jgrapes.core.Channel;
|
||||
import org.jgrapes.core.Components;
|
||||
import org.jgrapes.core.Event;
|
||||
|
||||
/**
|
||||
|
|
@ -40,4 +42,21 @@ public class OsinfoEvent extends Event<Void> {
|
|||
public JsonNode osinfo() {
|
||||
return osinfo;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(Components.objectName(this)).append(" [")
|
||||
.append(osinfo);
|
||||
if (channels() != null) {
|
||||
builder.append(", channels=").append(Channel.toString(channels()));
|
||||
}
|
||||
builder.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="(entry, rowIndex) in filteredData">
|
||||
<template v-for="(entry, rowIndex) in filteredData" :key="entry.name">
|
||||
<tr :class="[(rowIndex % 2) ? 'odd' : 'even']"
|
||||
:aria-expanded="(entry.name in detailsByName) ? 'true' : 'false'">
|
||||
<td v-for="key in controller.keys"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue