Move constants to separate class.
This commit is contained in:
parent
f493a2c582
commit
d637cb2c72
3 changed files with 56 additions and 11 deletions
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* VM-Operator
|
||||
* Copyright (C) 2023 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;
|
||||
|
||||
/**
|
||||
* Some constants.
|
||||
*/
|
||||
@SuppressWarnings("PMD.DataClass")
|
||||
public class Constants extends org.jdrupes.vmoperator.common.Constants {
|
||||
|
||||
/**
|
||||
* Process names.
|
||||
*/
|
||||
public static class ProcessName {
|
||||
|
||||
/** The Constant QEMU. */
|
||||
public static final String QEMU = "qemu";
|
||||
|
||||
/** The Constant SWTPM. */
|
||||
public static final String SWTPM = "swtpm";
|
||||
|
||||
/** The Constant CLOUD_INIT_IMG. */
|
||||
public static final String CLOUD_INIT_IMG = "cloudInitImg";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ import java.time.Instant;
|
|||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.logging.Level;
|
||||
import org.jdrupes.vmoperator.runner.qemu.Constants.ProcessName;
|
||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpCapabilities;
|
||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpCommand;
|
||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpPowerdown;
|
||||
|
|
@ -259,7 +260,7 @@ public class QemuMonitor extends QemuConnector {
|
|||
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||
public void onProcessExited(ProcessExited event) {
|
||||
if (!event.startedBy().associated(CommandDefinition.class)
|
||||
.map(cd -> Runner.QEMU.equals(cd.name())).orElse(false)) {
|
||||
.map(cd -> ProcessName.QEMU.equals(cd.name())).orElse(false)) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* VM-Operator
|
||||
* Copyright (C) 2023,2024 Michael N. Lipp
|
||||
* Copyright (C) 2023,2025 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
|
||||
|
|
@ -57,6 +57,7 @@ import org.apache.commons.cli.Option;
|
|||
import org.apache.commons.cli.Options;
|
||||
import static org.jdrupes.vmoperator.common.Constants.APP_NAME;
|
||||
import org.jdrupes.vmoperator.common.Constants.DisplaySecret;
|
||||
import org.jdrupes.vmoperator.runner.qemu.Constants.ProcessName;
|
||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpCont;
|
||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpReset;
|
||||
import org.jdrupes.vmoperator.runner.qemu.events.ConfigureQemu;
|
||||
|
|
@ -195,9 +196,6 @@ import org.jgrapes.util.events.WatchFile;
|
|||
"PMD.CouplingBetweenObjects", "PMD.TooManyFields" })
|
||||
public class Runner extends Component {
|
||||
|
||||
public static final String QEMU = "qemu";
|
||||
public static final String SWTPM = "swtpm";
|
||||
public static final String CLOUD_INIT_IMG = "cloudInitImg";
|
||||
private static final String TEMPLATE_DIR
|
||||
= "/opt/" + APP_NAME.replace("-", "") + "/templates";
|
||||
private static final String DEFAULT_TEMPLATE
|
||||
|
|
@ -350,15 +348,19 @@ public class Runner extends Component {
|
|||
initialConfig = newConfig;
|
||||
|
||||
// Configure
|
||||
swtpmDefinition = Optional.ofNullable(tplData.get(SWTPM))
|
||||
.map(d -> new CommandDefinition(SWTPM, d)).orElse(null);
|
||||
swtpmDefinition
|
||||
= Optional.ofNullable(tplData.get(ProcessName.SWTPM))
|
||||
.map(d -> new CommandDefinition(ProcessName.SWTPM, d))
|
||||
.orElse(null);
|
||||
logger.finest(() -> swtpmDefinition.toString());
|
||||
qemuDefinition = Optional.ofNullable(tplData.get(QEMU))
|
||||
.map(d -> new CommandDefinition(QEMU, d)).orElse(null);
|
||||
qemuDefinition = Optional.ofNullable(tplData.get(ProcessName.QEMU))
|
||||
.map(d -> new CommandDefinition(ProcessName.QEMU, d))
|
||||
.orElse(null);
|
||||
logger.finest(() -> qemuDefinition.toString());
|
||||
cloudInitImgDefinition
|
||||
= Optional.ofNullable(tplData.get(CLOUD_INIT_IMG))
|
||||
.map(d -> new CommandDefinition(CLOUD_INIT_IMG, d))
|
||||
= Optional.ofNullable(tplData.get(ProcessName.CLOUD_INIT_IMG))
|
||||
.map(d -> new CommandDefinition(ProcessName.CLOUD_INIT_IMG,
|
||||
d))
|
||||
.orElse(null);
|
||||
logger.finest(() -> cloudInitImgDefinition.toString());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue