Merge branch 'main' into testing
This commit is contained in:
commit
ab14cd6009
11 changed files with 88 additions and 26 deletions
|
|
@ -32,4 +32,5 @@
|
||||||
<noscript><p><img referrerpolicy="no-referrer-when-downgrade"
|
<noscript><p><img referrerpolicy="no-referrer-when-downgrade"
|
||||||
src="//piwik.mnl.de/matomo.php?idsite=17&rec=1&action_name=VM-Operator" style="border:0;" alt="" /></p></noscript>
|
src="//piwik.mnl.de/matomo.php?idsite=17&rec=1&action_name=VM-Operator" style="border:0;" alt="" /></p></noscript>
|
||||||
<!-- End Matomo Code -->
|
<!-- End Matomo Code -->
|
||||||
|
<script defer src="https://gotit.mnl.de/script.js" data-website-id="14b277ad-d330-4a54-82f1-a77d111240ac"></script>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -240,6 +240,7 @@ public class K8sClusterGenericStub<O extends KubernetesObject,
|
||||||
* @param <L> the object list type
|
* @param <L> the object list type
|
||||||
* @param <R> the result type
|
* @param <R> the result type
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface GenericSupplier<O extends KubernetesObject,
|
public interface GenericSupplier<O extends KubernetesObject,
|
||||||
L extends KubernetesListObject,
|
L extends KubernetesListObject,
|
||||||
R extends K8sClusterGenericStub<O, L>> {
|
R extends K8sClusterGenericStub<O, L>> {
|
||||||
|
|
|
||||||
|
|
@ -359,6 +359,7 @@ public class K8sGenericStub<O extends KubernetesObject,
|
||||||
* @param <L> the object list type
|
* @param <L> the object list type
|
||||||
* @param <R> the result type
|
* @param <R> the result type
|
||||||
*/
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
public interface GenericSupplier<O extends KubernetesObject,
|
public interface GenericSupplier<O extends KubernetesObject,
|
||||||
L extends KubernetesListObject, R extends K8sGenericStub<O, L>> {
|
L extends KubernetesListObject, R extends K8sGenericStub<O, L>> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,14 +118,14 @@ public class VmExtraData {
|
||||||
if (addr.isEmpty()) {
|
if (addr.isEmpty()) {
|
||||||
logger
|
logger
|
||||||
.severe(() -> "Failed to find display IP for " + vmDef.name());
|
.severe(() -> "Failed to find display IP for " + vmDef.name());
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
var port = vmDef.<Number> fromVm("display", "spice", "port")
|
var port = vmDef.<Number> fromVm("display", "spice", "port")
|
||||||
.map(Number::longValue);
|
.map(Number::longValue);
|
||||||
if (port.isEmpty()) {
|
if (port.isEmpty()) {
|
||||||
logger
|
logger
|
||||||
.severe(() -> "No port defined for display of " + vmDef.name());
|
.severe(() -> "No port defined for display of " + vmDef.name());
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
StringBuffer data = new StringBuffer(100)
|
StringBuffer data = new StringBuffer(100)
|
||||||
.append("[virt-viewer]\ntype=spice\nhost=")
|
.append("[virt-viewer]\ntype=spice\nhost=")
|
||||||
|
|
|
||||||
|
|
@ -69,14 +69,14 @@ public class GuestAgentClient extends AgentConnector {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void agentConnected() {
|
protected void agentConnected() {
|
||||||
logger.fine(() -> "guest agent connected");
|
logger.fine(() -> "Guest agent connected");
|
||||||
connected = true;
|
connected = true;
|
||||||
rep().fire(new GuestAgentCommand(new QmpGuestGetOsinfo()));
|
rep().fire(new GuestAgentCommand(new QmpGuestGetOsinfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void agentDisconnected() {
|
protected void agentDisconnected() {
|
||||||
logger.fine(() -> "guest agent disconnected");
|
logger.fine(() -> "Guest agent disconnected");
|
||||||
connected = false;
|
connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,15 +88,16 @@ public class GuestAgentClient extends AgentConnector {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void processInput(String line) throws IOException {
|
protected void processInput(String line) throws IOException {
|
||||||
logger.fine(() -> "guest agent(in): " + line);
|
logger.finer(() -> "guest agent(in): " + line);
|
||||||
try {
|
try {
|
||||||
var response = mapper.readValue(line, ObjectNode.class);
|
var response = mapper.readValue(line, ObjectNode.class);
|
||||||
if (response.has("return") || response.has("error")) {
|
if (response.has("return") || response.has("error")) {
|
||||||
QmpCommand executed = executing.poll();
|
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));
|
+ " is result from executing %s)", executed));
|
||||||
if (executed instanceof QmpGuestGetOsinfo) {
|
if (executed instanceof QmpGuestGetOsinfo) {
|
||||||
var osInfo = new OsinfoEvent(response.get("return"));
|
var osInfo = new OsinfoEvent(response.get("return"));
|
||||||
|
logger.fine(() -> "Guest agent triggers: " + osInfo);
|
||||||
rep().fire(osInfo);
|
rep().fire(osInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -120,10 +121,11 @@ public class GuestAgentClient extends AgentConnector {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var command = event.command();
|
var command = event.command();
|
||||||
logger.fine(() -> "guest agent(out): " + command.toString());
|
logger.fine(() -> "Guest handles: " + event);
|
||||||
String asText;
|
String asText;
|
||||||
try {
|
try {
|
||||||
asText = command.asText();
|
asText = command.asText();
|
||||||
|
logger.finer(() -> "guest agent(out): " + asText);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
logger.log(Level.SEVERE, e,
|
logger.log(Level.SEVERE, e,
|
||||||
() -> "Cannot serialize Json: " + e.getMessage());
|
() -> "Cannot serialize Json: " + e.getMessage());
|
||||||
|
|
@ -163,8 +165,8 @@ public class GuestAgentClient extends AgentConnector {
|
||||||
}
|
}
|
||||||
event.suspendHandling();
|
event.suspendHandling();
|
||||||
suspendedStop = event;
|
suspendedStop = event;
|
||||||
logger.fine(() -> "Sending powerdown command, waiting for"
|
logger.fine(() -> "Attempting shutdown through guest agent,"
|
||||||
+ " termination until " + waitUntil);
|
+ " waiting for termination until " + waitUntil);
|
||||||
powerdownTimer = Components.schedule(t -> {
|
powerdownTimer = Components.schedule(t -> {
|
||||||
logger.fine(() -> "Powerdown timeout reached.");
|
logger.fine(() -> "Powerdown timeout reached.");
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
|
|
||||||
|
|
@ -108,24 +108,30 @@ public class QemuMonitor extends QemuConnector {
|
||||||
@Override
|
@Override
|
||||||
protected void processInput(String line)
|
protected void processInput(String line)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
logger.fine(() -> "monitor(in): " + line);
|
logger.finer(() -> "monitor(in): " + line);
|
||||||
try {
|
try {
|
||||||
var response = mapper.readValue(line, ObjectNode.class);
|
var response = mapper.readValue(line, ObjectNode.class);
|
||||||
if (response.has("QMP")) {
|
if (response.has("QMP")) {
|
||||||
monitorReady = true;
|
monitorReady = true;
|
||||||
|
logger.fine(() -> "QMP connection ready");
|
||||||
rep().fire(new MonitorReady());
|
rep().fire(new MonitorReady());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (response.has("return") || response.has("error")) {
|
if (response.has("return") || response.has("error")) {
|
||||||
QmpCommand executed = executing.poll();
|
QmpCommand executed = executing.poll();
|
||||||
logger.fine(
|
logger.finer(
|
||||||
() -> String.format("(Previous \"monitor(in)\" is result "
|
() -> String.format("(Previous \"monitor(in)\" is result "
|
||||||
+ "from executing %s)", executed));
|
+ "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;
|
return;
|
||||||
}
|
}
|
||||||
if (response.has("event")) {
|
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) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
|
|
@ -141,7 +147,7 @@ public class QemuMonitor extends QemuConnector {
|
||||||
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
||||||
channel.associated(this, getClass()).ifPresent(qm -> {
|
channel.associated(this, getClass()).ifPresent(qm -> {
|
||||||
super.onClosed(event, channel);
|
super.onClosed(event, channel);
|
||||||
logger.finer(() -> "QMP socket closed.");
|
logger.fine(() -> "QMP connection closed.");
|
||||||
monitorReady = false;
|
monitorReady = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +164,7 @@ public class QemuMonitor extends QemuConnector {
|
||||||
public void onMonitorCommand(MonitorCommand event) throws IOException {
|
public void onMonitorCommand(MonitorCommand event) throws IOException {
|
||||||
// Check prerequisites
|
// Check prerequisites
|
||||||
if (!monitorReady && !(event.command() instanceof QmpCapabilities)) {
|
if (!monitorReady && !(event.command() instanceof QmpCapabilities)) {
|
||||||
logger.severe(() -> "Premature monitor command (not ready): "
|
logger.severe(() -> "Premature QMP command (not ready): "
|
||||||
+ event.command());
|
+ event.command());
|
||||||
rep().fire(new Stop());
|
rep().fire(new Stop());
|
||||||
return;
|
return;
|
||||||
|
|
@ -166,10 +172,11 @@ public class QemuMonitor extends QemuConnector {
|
||||||
|
|
||||||
// Send the command
|
// Send the command
|
||||||
var command = event.command();
|
var command = event.command();
|
||||||
logger.fine(() -> "monitor(out): " + command.toString());
|
logger.fine(() -> "QMP handles: " + event.toString());
|
||||||
String asText;
|
String asText;
|
||||||
try {
|
try {
|
||||||
asText = command.asText();
|
asText = command.asText();
|
||||||
|
logger.finer(() -> "monitor(out): " + asText);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
logger.log(Level.SEVERE, e,
|
logger.log(Level.SEVERE, e,
|
||||||
() -> "Cannot serialize Json: " + e.getMessage());
|
() -> "Cannot serialize Json: " + e.getMessage());
|
||||||
|
|
@ -192,8 +199,8 @@ public class QemuMonitor extends QemuConnector {
|
||||||
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||||
public void onStop(Stop event) {
|
public void onStop(Stop event) {
|
||||||
if (!monitorReady) {
|
if (!monitorReady) {
|
||||||
logger.fine(() -> "No QMP connection,"
|
logger.fine(() -> "Not sending QMP powerdown command"
|
||||||
+ " cannot send powerdown command");
|
+ " because QMP connection is closed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,14 @@ public class VmopAgentClient extends AgentConnector {
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
public void onVmopAgentLogIn(VmopAgentLogIn event) throws IOException {
|
public void onVmopAgentLogIn(VmopAgentLogIn event) throws IOException {
|
||||||
logger.fine(() -> "vmop agent(out): login " + event.user());
|
|
||||||
if (writer().isPresent()) {
|
if (writer().isPresent()) {
|
||||||
|
logger.fine(() -> "Vmop agent handles:" + event);
|
||||||
executing.add(event);
|
executing.add(event);
|
||||||
|
logger.finer(() -> "vmop agent(out): login " + event.user());
|
||||||
sendCommand("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
|
@Handler
|
||||||
public void onVmopAgentLogout(VmopAgentLogOut event) throws IOException {
|
public void onVmopAgentLogout(VmopAgentLogOut event) throws IOException {
|
||||||
logger.fine(() -> "vmop agent(out): logout");
|
|
||||||
if (writer().isPresent()) {
|
if (writer().isPresent()) {
|
||||||
|
logger.fine(() -> "Vmop agent handles:" + event);
|
||||||
executing.add(event);
|
executing.add(event);
|
||||||
|
logger.finer(() -> "vmop agent(out): logout");
|
||||||
sendCommand("logout");
|
sendCommand("logout");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,23 +90,27 @@ public class VmopAgentClient extends AgentConnector {
|
||||||
@SuppressWarnings({ "PMD.UnnecessaryReturn",
|
@SuppressWarnings({ "PMD.UnnecessaryReturn",
|
||||||
"PMD.AvoidLiteralsInIfCondition" })
|
"PMD.AvoidLiteralsInIfCondition" })
|
||||||
protected void processInput(String line) throws IOException {
|
protected void processInput(String line) throws IOException {
|
||||||
logger.fine(() -> "vmop agent(in): " + line);
|
logger.finer(() -> "vmop agent(in): " + line);
|
||||||
|
|
||||||
// Check validity
|
// Check validity
|
||||||
if (line.isEmpty() || !Character.isDigit(line.charAt(0))) {
|
if (line.isEmpty() || !Character.isDigit(line.charAt(0))) {
|
||||||
logger.warning(() -> "Illegal response: " + line);
|
logger.warning(() -> "Illegal vmop agent response: " + line);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check positive responses
|
// Check positive responses
|
||||||
if (line.startsWith("220 ")) {
|
if (line.startsWith("220 ")) {
|
||||||
rep().fire(new VmopAgentConnected());
|
var evt = new VmopAgentConnected();
|
||||||
|
logger.fine(() -> "Vmop agent triggers " + evt);
|
||||||
|
rep().fire(evt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (line.startsWith("201 ")) {
|
if (line.startsWith("201 ")) {
|
||||||
Event<?> cmd = executing.pop();
|
Event<?> cmd = executing.pop();
|
||||||
if (cmd instanceof VmopAgentLogIn login) {
|
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 {
|
} else {
|
||||||
logger.severe(() -> "Response " + line
|
logger.severe(() -> "Response " + line
|
||||||
+ " does not match executing command " + cmd);
|
+ " does not match executing command " + cmd);
|
||||||
|
|
@ -111,7 +120,9 @@ public class VmopAgentClient extends AgentConnector {
|
||||||
if (line.startsWith("202 ")) {
|
if (line.startsWith("202 ")) {
|
||||||
Event<?> cmd = executing.pop();
|
Event<?> cmd = executing.pop();
|
||||||
if (cmd instanceof VmopAgentLogOut logout) {
|
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 {
|
} else {
|
||||||
logger.severe(() -> "Response " + line
|
logger.severe(() -> "Response " + line
|
||||||
+ "does not match executing command " + cmd);
|
+ "does not match executing command " + cmd);
|
||||||
|
|
@ -125,7 +136,7 @@ public class VmopAgentClient extends AgentConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error
|
// Error
|
||||||
logger.warning(() -> "Error response: " + line);
|
logger.warning(() -> "Error response from vmop agent: " + line);
|
||||||
executing.pop();
|
executing.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ package org.jdrupes.vmoperator.runner.qemu.events;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jgrapes.core.Channel;
|
||||||
|
import org.jgrapes.core.Components;
|
||||||
import org.jgrapes.core.Event;
|
import org.jgrapes.core.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -112,4 +114,20 @@ public class MonitorEvent extends Event<Void> {
|
||||||
public JsonNode data() {
|
public JsonNode data() {
|
||||||
return 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;
|
package org.jdrupes.vmoperator.runner.qemu.events;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import org.jgrapes.core.Channel;
|
||||||
|
import org.jgrapes.core.Components;
|
||||||
import org.jgrapes.core.Event;
|
import org.jgrapes.core.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,4 +42,21 @@ public class OsinfoEvent extends Event<Void> {
|
||||||
public JsonNode osinfo() {
|
public JsonNode osinfo() {
|
||||||
return 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
webpages/_includes/umami.html
Normal file
1
webpages/_includes/umami.html
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<script defer src="https://gotit.mnl.de/script.js" data-website-id="14b277ad-d330-4a54-82f1-a77d111240ac"></script>
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<link rel="stylesheet" href="stylesheets/styles.css">
|
<link rel="stylesheet" href="stylesheets/styles.css">
|
||||||
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
|
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
|
||||||
<meta name="viewport" content="width=device-width">
|
<meta name="viewport" content="width=device-width">
|
||||||
|
{% include umami.html %}
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue