Compare commits

..

5 commits

Author SHA1 Message Date
2572aa9e21 Merge branch 'release/v4.0.x' into release/v4.x
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
2025-08-11 18:56:25 +02:00
e4af5f132e Merge tag 'tags/VM-Operator-4.0.3' into release/v4.0.x
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
2025-08-11 18:53:20 +02:00
50c11073ad Update manager.
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
2025-05-11 11:49:17 +02:00
9385167385 Merge branch 'main' into release/v4.0.x 2025-04-29 15:48:44 +02:00
eca119a372 Pin version. 2025-03-31 13:11:43 +02:00
79 changed files with 325 additions and 113 deletions

78
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,78 @@
stages:
- build
- test
- publish
- deploy
.any-job:
rules:
- if: $CI_SERVER_HOST == "gitlab.mnl.de"
.gradle-job:
extends: .any-job
image: registry.mnl.de/org/jgrapes/jdk21-builder:v2
cache:
- key: dependencies-${CI_COMMIT_BRANCH}
policy: pull-push
paths:
- .gradle
- node_modules
- key: "$CI_COMMIT_SHA"
policy: pull-push
paths:
- build
- "*/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 pull
- git reset --hard $CI_COMMIT_SHA
build-jars:
stage: build
extends: .gradle-job
script:
- ./gradlew -Pdocker.registry=$CI_REGISTRY_IMAGE build apidocs
publish-images:
stage: publish
extends: .gradle-job
dependencies:
- build-jars
script:
- ./gradlew -Pdocker.registry=$CI_REGISTRY_IMAGE publishImage
.pages-job:
extends: .any-job
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/ruby:3.2
variables:
JEKYLL_ENV: production
LC_ALL: C.UTF-8
before_script:
- git fetch origin gh-pages
- git checkout gh-pages
- gem install bundler
- bundle install
test-pages:
stage: test
extends: .pages-job
rules:
- if: $CI_COMMIT_BRANCH == "gh-pages"
script:
- bundle exec jekyll build -d test
artifacts:
paths:
- test
#publish-pages:
# stage: publish
# extends: .pages-job
# rules:
# - if: $CI_COMMIT_BRANCH == "gh-pages"
# script:
# - bundle exec jekyll build -d public
# artifacts:
# paths:
# - public
# environment: production

View file

@ -1,38 +0,0 @@
when:
- event: push
evaluate: 'CI_SYSTEM_HOST == "woodpecker.mnl.de"'
clone:
- name: git
image: woodpeckerci/plugin-git
settings:
partial: false
tags: true
depth: 0
steps:
- name: prepare
image: alpine
commands:
# Because we run the next step as user 1000 to make podman work:
- mkdir /woodpecker/workflow
- chown 1000:1000 /woodpecker/workflow
- chown -R 1000:1000 $CI_WORKSPACE
- name: build-jars
image: registry.mnl.de/mnl/jdk21-builder:v4
environment:
HOME: /woodpecker/workflow
REGISTRY: registry.mnl.de
REGISTRY_USER: mnl
REGISTRY_TOKEN:
from_secret: REGISTRY_TOKEN
commands:
- echo $REGISTRY_TOKEN | podman login -u $REGISTRY_USER --password-stdin $REGISTRY
- ./gradlew -Pdocker.registry=$REGISTRY/$REGISTRY_USER build apidocs publishImage
backend_options:
kubernetes:
securityContext:
privileged: true
runAsUser: 1000
runAsGroup: 1000

View file

@ -20,8 +20,7 @@ spec:
containers: containers:
- name: vm-operator - name: vm-operator
image: >- image: >-
ghcr.io/mnlipp/org.jdrupes.vmoperator.manager:latest ghcr.io/mnlipp/org.jdrupes.vmoperator.manager:4.0.2
imagePullPolicy: Always
env: env:
- name: JAVA_OPTS - name: JAVA_OPTS
# The VM operator needs about 25 MB of memory, plus 1 MB for # The VM operator needs about 25 MB of memory, plus 1 MB for

View file

@ -1,3 +0,0 @@
#!/bin/sh
sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf

View file

@ -72,8 +72,8 @@ doLogin() {
return return
fi fi
# Check if this user is already logged in on tty2 # Check if this user is already logged in on tty1
curUser=$(loginctl -j | jq -r '.[] | select(.tty=="tty2") | .user') curUser=$(loginctl -j | jq -r '.[] | select(.tty=="tty1") | .user')
if [ "$curUser" = "$user" ]; then if [ "$curUser" = "$user" ]; then
echo >&${con} "201 User already logged in" echo >&${con} "201 User already logged in"
return return
@ -96,14 +96,17 @@ doLogin() {
return return
fi fi
fi fi
# Configure user as auto login user # Start the desktop for the user
sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf systemd-run 2>$temperr \
sed -i '/\[daemon\]/a AutomaticLoginEnable=true\nAutomaticLogin='$user \ --unit vmop-user-desktop --uid=$uid --gid=$uid \
/etc/gdm/custom.conf --working-directory="/home/$user" -p TTYPath=/dev/tty1 \
-p PAMName=login -p StandardInput=tty -p StandardOutput=journal \
# Activate user -p Conflicts="gdm.service getty@tty1.service" \
systemctl restart gdm -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
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo >&${con} "201 User logged in successfully" echo >&${con} "201 User logged in successfully"
else else
@ -114,8 +117,14 @@ doLogin() {
# Attempt to log out a user currently using tty1. This is an intermediate # Attempt to log out a user currently using tty1. This is an intermediate
# operation that can be invoked from other operations # operation that can be invoked from other operations
attemptLogout() { attemptLogout() {
sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf systemctl status vmop-user-desktop > /dev/null 2>&1
systemctl stop gdm 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
echo >&${con} "102 Desktop stopped" echo >&${con} "102 Desktop stopped"
} }
@ -124,7 +133,15 @@ attemptLogout() {
# Also try to restart gdm, if it is not running. # Also try to restart gdm, if it is not running.
doLogout() { doLogout() {
attemptLogout attemptLogout
systemctl restart gdm 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
echo >&${con} "202 User logged out" echo >&${con} "202 User logged out"
} }
@ -136,7 +153,7 @@ while read line <&${con}; do
done done
onExit() { onExit() {
doLogout attemptLogout
if [ -n "$temperr" ]; then if [ -n "$temperr" ]; then
rm -f $temperr rm -f $temperr
fi fi

View file

@ -32,11 +32,13 @@ import java.util.regex.Pattern;
public class Convertions { public class Convertions {
@SuppressWarnings({ "PMD.UseConcurrentHashMap", @SuppressWarnings({ "PMD.UseConcurrentHashMap",
"PMD.FieldNamingConventions" }) "PMD.FieldNamingConventions", "PMD.VariableNamingConventions" })
private static final Map<String, BigInteger> unitMap = new HashMap<>(); private static final Map<String, BigInteger> unitMap = new HashMap<>();
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final List<Map.Entry<String, BigInteger>> unitMappings; private static final List<Map.Entry<String, BigInteger>> unitMappings;
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final Pattern memorySize private static final Pattern memorySize
= Pattern.compile("^\\s*(\\d+(\\.\\d+)?)\\s*([A-Za-z]*)\\s*"); = Pattern.compile("^\\s*(\\d+(\\.\\d+)?)\\s*([A-Za-z]*)\\s*");
@ -67,6 +69,7 @@ public class Convertions {
* @param amount the amount * @param amount the amount
* @return the big integer * @return the big integer
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public static BigInteger parseMemory(Object amount) { public static BigInteger parseMemory(Object amount) {
if (amount == null) { if (amount == null) {
return (BigInteger) amount; return (BigInteger) amount;

View file

@ -47,7 +47,8 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
/** /**
* Helpers for K8s API. * Helpers for K8s API.
*/ */
@SuppressWarnings({ "PMD.ShortClassName", "PMD.UseUtilityClass" }) @SuppressWarnings({ "PMD.ShortClassName", "PMD.UseUtilityClass",
"PMD.DataflowAnomalyAnalysis" })
public class K8s { public class K8s {
/** /**
@ -112,6 +113,7 @@ public class K8s {
public static JsonObject yamlToJson(ApiClient client, Reader yaml) { public static JsonObject yamlToJson(ApiClient client, Reader yaml) {
// Avoid Yaml.load due to // Avoid Yaml.load due to
// https://github.com/kubernetes-client/java/issues/2741 // https://github.com/kubernetes-client/java/issues/2741
@SuppressWarnings("PMD.UseConcurrentHashMap")
Map<String, Object> yamlData Map<String, Object> yamlData
= new Yaml(new SafeConstructor(new LoaderOptions())).load(yaml); = new Yaml(new SafeConstructor(new LoaderOptions())).load(yaml);

View file

@ -48,7 +48,8 @@ import okhttp3.Response;
* A client with some additional properties. * A client with some additional properties.
*/ */
@SuppressWarnings({ "PMD.ExcessivePublicCount", "PMD.TooManyMethods", @SuppressWarnings({ "PMD.ExcessivePublicCount", "PMD.TooManyMethods",
"checkstyle:LineLength", "PMD.CouplingBetweenObjects", "PMD.GodClass" }) "PMD.LinguisticNaming", "checkstyle:LineLength",
"PMD.CouplingBetweenObjects", "PMD.GodClass" })
public class K8sClient extends ApiClient { public class K8sClient extends ApiClient {
private ApiClient apiClient; private ApiClient apiClient;
@ -230,6 +231,7 @@ public class K8sClient extends ApiClient {
* @return the api client * @return the api client
* @see ApiClient#setKeyManagers(javax.net.ssl.KeyManager[]) * @see ApiClient#setKeyManagers(javax.net.ssl.KeyManager[])
*/ */
@SuppressWarnings("PMD.UseVarargs")
@Override @Override
public ApiClient setKeyManagers(KeyManager[] managers) { public ApiClient setKeyManagers(KeyManager[] managers) {
return apiClient().setKeyManagers(managers); return apiClient().setKeyManagers(managers);
@ -636,6 +638,7 @@ public class K8sClient extends ApiClient {
* @return the string * @return the string
* @see ApiClient#selectHeaderAccept(java.lang.String[]) * @see ApiClient#selectHeaderAccept(java.lang.String[])
*/ */
@SuppressWarnings("PMD.UseVarargs")
@Override @Override
public String selectHeaderAccept(String[] accepts) { public String selectHeaderAccept(String[] accepts) {
return apiClient().selectHeaderAccept(accepts); return apiClient().selectHeaderAccept(accepts);
@ -648,6 +651,7 @@ public class K8sClient extends ApiClient {
* @return the string * @return the string
* @see ApiClient#selectHeaderContentType(java.lang.String[]) * @see ApiClient#selectHeaderContentType(java.lang.String[])
*/ */
@SuppressWarnings("PMD.UseVarargs")
@Override @Override
public String selectHeaderContentType(String[] contentTypes) { public String selectHeaderContentType(String[] contentTypes) {
return apiClient().selectHeaderContentType(contentTypes); return apiClient().selectHeaderContentType(contentTypes);
@ -814,7 +818,7 @@ public class K8sClient extends ApiClient {
* @throws ApiException the api exception * @throws ApiException the api exception
* @see ApiClient#buildCall(java.lang.String, java.lang.String, java.util.List, java.util.List, java.lang.Object, java.util.Map, java.util.Map, java.util.Map, java.lang.String[], io.kubernetes.client.openapi.ApiCallback) * @see ApiClient#buildCall(java.lang.String, java.lang.String, java.util.List, java.util.List, java.lang.Object, java.util.Map, java.util.Map, java.util.Map, java.lang.String[], io.kubernetes.client.openapi.ApiCallback)
*/ */
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" })
@Override @Override
public Call buildCall(String path, String method, List<Pair> queryParams, public Call buildCall(String path, String method, List<Pair> queryParams,
List<Pair> collectionQueryParams, Object body, List<Pair> collectionQueryParams, Object body,
@ -843,7 +847,7 @@ public class K8sClient extends ApiClient {
* @throws ApiException the api exception * @throws ApiException the api exception
* @see ApiClient#buildRequest(java.lang.String, java.lang.String, java.util.List, java.util.List, java.lang.Object, java.util.Map, java.util.Map, java.util.Map, java.lang.String[], io.kubernetes.client.openapi.ApiCallback) * @see ApiClient#buildRequest(java.lang.String, java.lang.String, java.util.List, java.util.List, java.lang.Object, java.util.Map, java.util.Map, java.util.Map, java.lang.String[], io.kubernetes.client.openapi.ApiCallback)
*/ */
@SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" })
@Override @Override
public Request buildRequest(String path, String method, public Request buildRequest(String path, String method,
List<Pair> queryParams, List<Pair> collectionQueryParams, List<Pair> queryParams, List<Pair> collectionQueryParams,

View file

@ -45,7 +45,8 @@ import java.util.function.Function;
* @param <O> the generic type * @param <O> the generic type
* @param <L> the generic type * @param <L> the generic type
*/ */
@SuppressWarnings({ "PMD.CouplingBetweenObjects" }) @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis",
"PMD.CouplingBetweenObjects" })
public class K8sClusterGenericStub<O extends KubernetesObject, public class K8sClusterGenericStub<O extends KubernetesObject,
L extends KubernetesListObject> { L extends KubernetesListObject> {
protected final K8sClient client; protected final K8sClient client;
@ -254,6 +255,7 @@ public class K8sClusterGenericStub<O extends KubernetesObject,
* @param name the name * @param name the name
* @return the result * @return the result
*/ */
@SuppressWarnings("PMD.UseObjectForClearerAPI")
R get(Class<O> objectClass, Class<L> objectListClass, K8sClient client, R get(Class<O> objectClass, Class<L> objectListClass, K8sClient client,
APIResource context, String name); APIResource context, String name);
} }
@ -282,6 +284,7 @@ public class K8sClusterGenericStub<O extends KubernetesObject,
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop" })
public static <O extends KubernetesObject, L extends KubernetesListObject, public static <O extends KubernetesObject, L extends KubernetesListObject,
R extends K8sClusterGenericStub<O, L>> R extends K8sClusterGenericStub<O, L>>
R get(Class<O> objectClass, Class<L> objectListClass, R get(Class<O> objectClass, Class<L> objectListClass,
@ -312,6 +315,8 @@ public class K8sClusterGenericStub<O extends KubernetesObject,
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.UseObjectForClearerAPI" })
public static <O extends KubernetesObject, L extends KubernetesListObject, public static <O extends KubernetesObject, L extends KubernetesListObject,
R extends K8sClusterGenericStub<O, L>> R extends K8sClusterGenericStub<O, L>>
R get(Class<O> objectClass, Class<L> objectListClass, R get(Class<O> objectClass, Class<L> objectListClass,
@ -336,6 +341,8 @@ public class K8sClusterGenericStub<O extends KubernetesObject,
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" })
public static <O extends KubernetesObject, L extends KubernetesListObject, public static <O extends KubernetesObject, L extends KubernetesListObject,
R extends K8sClusterGenericStub<O, L>> R extends K8sClusterGenericStub<O, L>>
R create(Class<O> objectClass, Class<L> objectListClass, R create(Class<O> objectClass, Class<L> objectListClass,

View file

@ -29,6 +29,7 @@ import io.kubernetes.client.openapi.models.V1ObjectMeta;
* notably the metadata, is made available through the methods * notably the metadata, is made available through the methods
* defined by {@link KubernetesObject}. * defined by {@link KubernetesObject}.
*/ */
@SuppressWarnings("PMD.DataClass")
public class K8sDynamicModel implements KubernetesObject { public class K8sDynamicModel implements KubernetesObject {
private final V1ObjectMeta metadata; private final V1ObjectMeta metadata;

View file

@ -62,7 +62,7 @@ public class K8sDynamicModelsBase<T extends K8sDynamicModel>
} catch (InstantiationException | IllegalAccessException } catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException exc) { | NoSuchMethodException | SecurityException exc) {
throw new IllegalArgumentException(exc); throw new IllegalArgumentException(exc); // NOPMD
} }
} }
} }

View file

@ -31,6 +31,7 @@ import java.util.Collection;
* state and can therefore be used for any kind of object, especially * state and can therefore be used for any kind of object, especially
* custom objects. * custom objects.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sDynamicStub public class K8sDynamicStub
extends K8sDynamicStubBase<K8sDynamicModel, K8sDynamicModels> { extends K8sDynamicStubBase<K8sDynamicModel, K8sDynamicModels> {
@ -63,6 +64,8 @@ public class K8sDynamicStub
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" })
public static K8sDynamicStub get(K8sClient client, public static K8sDynamicStub get(K8sClient client,
GroupVersionKind gvk, String namespace, String name) GroupVersionKind gvk, String namespace, String name)
throws ApiException { throws ApiException {
@ -80,6 +83,8 @@ public class K8sDynamicStub
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" })
public static K8sDynamicStub get(K8sClient client, public static K8sDynamicStub get(K8sClient client,
APIResource context, String namespace, String name) { APIResource context, String namespace, String name) {
return new K8sDynamicStub(client, context, namespace, name); return new K8sDynamicStub(client, context, namespace, name);

View file

@ -26,6 +26,7 @@ import io.kubernetes.client.Discovery.APIResource;
* state and can therefore be used for any kind of object, especially * state and can therefore be used for any kind of object, especially
* custom objects. * custom objects.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public abstract class K8sDynamicStubBase<O extends K8sDynamicModel, public abstract class K8sDynamicStubBase<O extends K8sDynamicModel,
L extends K8sDynamicModelsBase<O>> extends K8sGenericStub<O, L> { L extends K8sDynamicModelsBase<O>> extends K8sGenericStub<O, L> {
@ -39,6 +40,7 @@ public abstract class K8sDynamicStubBase<O extends K8sDynamicModel,
* @param namespace the namespace * @param namespace the namespace
* @param name the name * @param name the name
*/ */
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
public K8sDynamicStubBase(Class<O> objectClass, public K8sDynamicStubBase(Class<O> objectClass,
Class<L> objectListClass, DynamicTypeAdapterFactory<O, L> taf, Class<L> objectListClass, DynamicTypeAdapterFactory<O, L> taf,
K8sClient client, APIResource context, String namespace, K8sClient client, APIResource context, String namespace,

View file

@ -48,7 +48,7 @@ import java.util.function.Function;
* @param <O> the generic type * @param <O> the generic type
* @param <L> the generic type * @param <L> the generic type
*/ */
@SuppressWarnings({ "PMD.TooManyMethods" }) @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.TooManyMethods" })
public class K8sGenericStub<O extends KubernetesObject, public class K8sGenericStub<O extends KubernetesObject,
L extends KubernetesListObject> { L extends KubernetesListObject> {
protected final K8sClient client; protected final K8sClient client;
@ -200,6 +200,7 @@ public class K8sGenericStub<O extends KubernetesObject,
* @return the updated model or empty if the object was not found * @return the updated model or empty if the object was not found
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings("PMD.AssignmentInOperand")
public Optional<O> updateStatus(O object, Function<O, Object> updater) public Optional<O> updateStatus(O object, Function<O, Object> updater)
throws ApiException { throws ApiException {
return K8s.optional(api.updateStatus(object, updater)); return K8s.optional(api.updateStatus(object, updater));
@ -217,7 +218,7 @@ public class K8sGenericStub<O extends KubernetesObject,
* @return the updated model or empty if the object was not found * @return the updated model or empty if the object was not found
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AssignmentInOperand" }) @SuppressWarnings({ "PMD.AssignmentInOperand", "PMD.UnusedAssignment" })
public Optional<O> updateStatus(Function<O, Object> updater, O current, public Optional<O> updateStatus(Function<O, Object> updater, O current,
int retries) throws ApiException { int retries) throws ApiException {
while (true) { while (true) {
@ -247,6 +248,7 @@ public class K8sGenericStub<O extends KubernetesObject,
* @return the updated model or empty if the object was not found * @return the updated model or empty if the object was not found
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AssignmentInOperand", "PMD.UnusedAssignment" })
public Optional<O> updateStatus(Function<O, Object> updater, int retries) public Optional<O> updateStatus(Function<O, Object> updater, int retries)
throws ApiException { throws ApiException {
return updateStatus(updater, null, retries); return updateStatus(updater, null, retries);
@ -369,6 +371,7 @@ public class K8sGenericStub<O extends KubernetesObject,
* @param name the name * @param name the name
* @return the result * @return the result
*/ */
@SuppressWarnings("PMD.UseObjectForClearerAPI")
R get(K8sClient client, String namespace, String name); R get(K8sClient client, String namespace, String name);
} }
@ -394,6 +397,8 @@ public class K8sGenericStub<O extends KubernetesObject,
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" })
public static <O extends KubernetesObject, L extends KubernetesListObject, public static <O extends KubernetesObject, L extends KubernetesListObject,
R extends K8sGenericStub<O, L>> R extends K8sGenericStub<O, L>>
R create(Class<O> objectClass, Class<L> objectListClass, R create(Class<O> objectClass, Class<L> objectListClass,

View file

@ -50,6 +50,7 @@ public class K8sObserver<O extends KubernetesObject,
ADDED, MODIFIED, DELETED ADDED, MODIFIED, DELETED
} }
@SuppressWarnings("PMD.FieldNamingConventions")
protected final Logger logger = Logger.getLogger(getClass().getName()); protected final Logger logger = Logger.getLogger(getClass().getName());
protected final K8sClient client; protected final K8sClient client;
@ -72,7 +73,8 @@ public class K8sObserver<O extends KubernetesObject,
* @param namespace the namespace * @param namespace the namespace
* @param options the options * @param options the options
*/ */
@SuppressWarnings({ "PMD.AvoidCatchingThrowable", @SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.UseObjectForClearerAPI", "PMD.AvoidCatchingThrowable",
"PMD.CognitiveComplexity", "PMD.AvoidCatchingGenericException" }) "PMD.CognitiveComplexity", "PMD.AvoidCatchingGenericException" })
public K8sObserver(Class<O> objectClass, Class<L> objectListClass, public K8sObserver(Class<O> objectClass, Class<L> objectListClass,
K8sClient client, APIResource context, String namespace, K8sClient client, APIResource context, String namespace,
@ -98,6 +100,7 @@ public class K8sObserver<O extends KubernetesObject,
while (!Thread.currentThread().isInterrupted()) { while (!Thread.currentThread().isInterrupted()) {
Instant startedAt = Instant.now(); Instant startedAt = Instant.now();
try { try {
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
var changed var changed
= api.watch(namespace, options).iterator(); = api.watch(namespace, options).iterator();
while (changed.hasNext()) { while (changed.hasNext()) {
@ -230,6 +233,7 @@ public class K8sObserver<O extends KubernetesObject,
} }
@Override @Override
@SuppressWarnings("PMD.UseLocaleWithCaseConversions")
public String toString() { public String toString() {
return "Observer for " + K8s.toString(context) + " " + namespace; return "Observer for " + K8s.toString(context) + " " + namespace;
} }

View file

@ -26,6 +26,7 @@ import java.util.List;
/** /**
* A stub for config maps (v1). * A stub for config maps (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1ConfigMapStub public class K8sV1ConfigMapStub
extends K8sGenericStub<V1ConfigMap, V1ConfigMapList> { extends K8sGenericStub<V1ConfigMap, V1ConfigMapList> {

View file

@ -29,6 +29,7 @@ import java.util.Optional;
/** /**
* A stub for pods (v1). * A stub for pods (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1DeploymentStub public class K8sV1DeploymentStub
extends K8sGenericStub<V1Deployment, V1DeploymentList> { extends K8sGenericStub<V1Deployment, V1DeploymentList> {

View file

@ -29,6 +29,7 @@ import java.util.List;
/** /**
* A stub for nodes (v1). * A stub for nodes (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1NodeStub extends K8sClusterGenericStub<V1Node, V1NodeList> { public class K8sV1NodeStub extends K8sClusterGenericStub<V1Node, V1NodeList> {
public static final APIResource CONTEXT = new APIResource("", List.of("v1"), public static final APIResource CONTEXT = new APIResource("", List.of("v1"),
@ -73,7 +74,8 @@ public class K8sV1NodeStub extends K8sClusterGenericStub<V1Node, V1NodeList> {
/** /**
* Provide {@link GenericSupplier}. * Provide {@link GenericSupplier}.
*/ */
@SuppressWarnings({ "PMD.UnusedFormalParameter" }) @SuppressWarnings({ "PMD.UnusedFormalParameter",
"PMD.UnusedPrivateMethod" })
private static K8sV1NodeStub getGeneric(Class<V1Node> objectClass, private static K8sV1NodeStub getGeneric(Class<V1Node> objectClass,
Class<V1NodeList> objectListClass, K8sClient client, Class<V1NodeList> objectListClass, K8sClient client,
APIResource context, String name) { APIResource context, String name) {

View file

@ -29,6 +29,7 @@ import java.util.List;
/** /**
* A stub for pods (v1). * A stub for pods (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1PodStub extends K8sGenericStub<V1Pod, V1PodList> { public class K8sV1PodStub extends K8sGenericStub<V1Pod, V1PodList> {
/** The pods' context. */ /** The pods' context. */

View file

@ -29,6 +29,7 @@ import java.util.List;
/** /**
* A stub for pods (v1). * A stub for pods (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1PvcStub extends public class K8sV1PvcStub extends
K8sGenericStub<V1PersistentVolumeClaim, V1PersistentVolumeClaimList> { K8sGenericStub<V1PersistentVolumeClaim, V1PersistentVolumeClaimList> {

View file

@ -29,6 +29,7 @@ import java.util.List;
/** /**
* A stub for secrets (v1). * A stub for secrets (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1SecretStub extends K8sGenericStub<V1Secret, V1SecretList> { public class K8sV1SecretStub extends K8sGenericStub<V1Secret, V1SecretList> {
public static final APIResource CONTEXT = new APIResource("", List.of("v1"), public static final APIResource CONTEXT = new APIResource("", List.of("v1"),

View file

@ -29,6 +29,7 @@ import java.util.List;
/** /**
* A stub for secrets (v1). * A stub for secrets (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1ServiceStub extends K8sGenericStub<V1Service, V1ServiceList> { public class K8sV1ServiceStub extends K8sGenericStub<V1Service, V1ServiceList> {
public static final APIResource CONTEXT = new APIResource("", List.of("v1"), public static final APIResource CONTEXT = new APIResource("", List.of("v1"),

View file

@ -26,6 +26,7 @@ import java.util.List;
/** /**
* A stub for stateful sets (v1). * A stub for stateful sets (v1).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class K8sV1StatefulSetStub public class K8sV1StatefulSetStub
extends K8sGenericStub<V1StatefulSet, V1StatefulSetList> { extends K8sGenericStub<V1StatefulSet, V1StatefulSetList> {

View file

@ -46,10 +46,11 @@ import org.jdrupes.vmoperator.util.DataPath;
/** /**
* Represents a VM definition. * Represents a VM definition.
*/ */
@SuppressWarnings({ "PMD.DataClass", "PMD.TooManyMethods" }) @SuppressWarnings({ "PMD.DataClass", "PMD.TooManyMethods",
"PMD.CouplingBetweenObjects" })
public class VmDefinition extends K8sDynamicModel { public class VmDefinition extends K8sDynamicModel {
@SuppressWarnings({ "unused" }) @SuppressWarnings({ "PMD.FieldNamingConventions", "unused" })
private static final Logger logger private static final Logger logger
= Logger.getLogger(VmDefinition.class.getName()); = Logger.getLogger(VmDefinition.class.getName());
@SuppressWarnings("PMD.FieldNamingConventions") @SuppressWarnings("PMD.FieldNamingConventions")

View file

@ -31,6 +31,7 @@ import java.util.Collection;
* state and can therefore be used for any kind of object, especially * state and can therefore be used for any kind of object, especially
* custom objects. * custom objects.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class VmDefinitionStub public class VmDefinitionStub
extends K8sDynamicStubBase<VmDefinition, VmDefinitions> { extends K8sDynamicStubBase<VmDefinition, VmDefinitions> {
@ -63,6 +64,8 @@ public class VmDefinitionStub
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" })
public static VmDefinitionStub get(K8sClient client, public static VmDefinitionStub get(K8sClient client,
GroupVersionKind gvk, String namespace, String name) GroupVersionKind gvk, String namespace, String name)
throws ApiException { throws ApiException {
@ -80,6 +83,8 @@ public class VmDefinitionStub
* @return the stub if the object exists * @return the stub if the object exists
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop",
"PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" })
public static VmDefinitionStub get(K8sClient client, public static VmDefinitionStub get(K8sClient client,
APIResource context, String namespace, String name) { APIResource context, String namespace, String name) {
return new VmDefinitionStub(client, context, namespace, name); return new VmDefinitionStub(client, context, namespace, name);

View file

@ -34,6 +34,7 @@ import java.util.logging.Logger;
*/ */
public class VmExtraData { public class VmExtraData {
@SuppressWarnings("PMD.FieldNamingConventions")
private static final Logger logger private static final Logger logger
= Logger.getLogger(VmExtraData.class.getName()); = Logger.getLogger(VmExtraData.class.getName());

View file

@ -35,6 +35,7 @@ import org.jdrupes.vmoperator.util.DataPath;
/** /**
* Represents a VM pool. * Represents a VM pool.
*/ */
@SuppressWarnings({ "PMD.DataClass" })
public class VmPool { public class VmPool {
private final String name; private final String name;

View file

@ -24,6 +24,7 @@ import org.jgrapes.core.Event;
/** /**
* Assign a VM from a pool to a user. * Assign a VM from a pool to a user.
*/ */
@SuppressWarnings("PMD.DataClass")
public class AssignVm extends Event<VmData> { public class AssignVm extends Event<VmData> {
private final String fromPool; private final String fromPool;

View file

@ -43,6 +43,7 @@ public interface ChannelDictionary<K, C extends Channel, A> {
* @param channel the channel * @param channel the channel
* @param associated the associated * @param associated the associated
*/ */
@SuppressWarnings("PMD.ShortClassName")
public record Value<C extends Channel, A>(C channel, A associated) { public record Value<C extends Channel, A>(C channel, A associated) {
} }

View file

@ -149,6 +149,8 @@ public class ChannelManager<K, C extends Channel, A>
* @param supplier the supplier * @param supplier the supplier
* @return the channel * @return the channel
*/ */
@SuppressWarnings({ "PMD.AssignmentInOperand",
"PMD.DataflowAnomalyAnalysis" })
public C computeIfAbsent(K key, Function<K, C> supplier) { public C computeIfAbsent(K key, Function<K, C> supplier) {
return entries.computeIfAbsent(key, return entries.computeIfAbsent(key,
k -> new Value<>(supplier.apply(k), null)).channel(); k -> new Value<>(supplier.apply(k), null)).channel();

View file

@ -24,6 +24,7 @@ import org.jgrapes.core.Event;
/** /**
* Gets the current display secret and optionally updates it. * Gets the current display secret and optionally updates it.
*/ */
@SuppressWarnings("PMD.DataClass")
public class GetDisplaySecret extends Event<String> { public class GetDisplaySecret extends Event<String> {
private final VmDefinition vmDef; private final VmDefinition vmDef;

View file

@ -27,6 +27,7 @@ import org.jgrapes.core.Event;
/** /**
* Gets the known pools' definitions. * Gets the known pools' definitions.
*/ */
@SuppressWarnings("PMD.DataClass")
public class GetPools extends Event<List<VmPool>> { public class GetPools extends Event<List<VmPool>> {
private String name; private String name;

View file

@ -27,6 +27,7 @@ import org.jgrapes.core.Event;
/** /**
* Gets the known VMs' definitions and channels. * Gets the known VMs' definitions and channels.
*/ */
@SuppressWarnings("PMD.DataClass")
public class GetVms extends Event<List<GetVms.VmData>> { public class GetVms extends Event<List<GetVms.VmData>> {
private String name; private String name;

View file

@ -24,6 +24,7 @@ import org.jgrapes.core.Event;
/** /**
* Modifies a VM. * Modifies a VM.
*/ */
@SuppressWarnings("PMD.DataClass")
public class ModifyVm extends Event<Void> { public class ModifyVm extends Event<Void> {
private final String name; private final String name;

View file

@ -23,6 +23,7 @@ import org.jgrapes.core.Event;
/** /**
* Triggers a reset of the VM. * Triggers a reset of the VM.
*/ */
@SuppressWarnings("PMD.DataClass")
public class ResetVm extends Event<String> { public class ResetVm extends Event<String> {
private final String vmName; private final String vmName;

View file

@ -24,6 +24,7 @@ import org.jgrapes.core.Event;
/** /**
* Note the assignment to a user in the VM status. * Note the assignment to a user in the VM status.
*/ */
@SuppressWarnings("PMD.DataClass")
public class UpdateAssignment extends Event<Boolean> { public class UpdateAssignment extends Event<Boolean> {
private final VmPool fromPool; private final VmPool fromPool;

View file

@ -28,6 +28,7 @@ import org.jgrapes.core.Subchannel.DefaultSubchannel;
/** /**
* A subchannel used to send the events related to a specific VM. * A subchannel used to send the events related to a specific VM.
*/ */
@SuppressWarnings("PMD.DataClass")
public class VmChannel extends DefaultSubchannel { public class VmChannel extends DefaultSubchannel {
private final EventPipeline pipeline; private final EventPipeline pipeline;
@ -55,6 +56,7 @@ public class VmChannel extends DefaultSubchannel {
* @param definition the definition * @param definition the definition
* @return the watch channel * @return the watch channel
*/ */
@SuppressWarnings("PMD.LinguisticNaming")
public VmChannel setVmDefinition(VmDefinition definition) { public VmChannel setVmDefinition(VmDefinition definition) {
this.definition = definition; this.definition = definition;
return this; return this;
@ -85,6 +87,7 @@ public class VmChannel extends DefaultSubchannel {
* @param generation the generation to set * @param generation the generation to set
* @return true if value has changed * @return true if value has changed
*/ */
@SuppressWarnings("PMD.LinguisticNaming")
public boolean setGeneration(long generation) { public boolean setGeneration(long generation) {
if (this.generation == generation) { if (this.generation == generation) {
return false; return false;

View file

@ -26,6 +26,7 @@ import org.jgrapes.core.Event;
/** /**
* Indicates a change in a pool configuration. * Indicates a change in a pool configuration.
*/ */
@SuppressWarnings("PMD.DataClass")
public class VmPoolChanged extends Event<Void> { public class VmPoolChanged extends Event<Void> {
private final VmPool vmPool; private final VmPool vmPool;

View file

@ -51,6 +51,7 @@ import org.jgrapes.util.events.ConfigurationUpdate;
* @param <O> the object type for the context * @param <O> the object type for the context
* @param <L> the object list type for the context * @param <L> the object list type for the context
*/ */
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis" })
public abstract class AbstractMonitor<O extends KubernetesObject, public abstract class AbstractMonitor<O extends KubernetesObject,
L extends KubernetesListObject, C extends Channel> extends Component { L extends KubernetesListObject, C extends Channel> extends Component {
@ -180,6 +181,7 @@ public abstract class AbstractMonitor<O extends KubernetesObject,
* @param event the event * @param event the event
*/ */
@Handler(priority = 10) @Handler(priority = 10)
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void onStart(Start event) { public void onStart(Start event) {
try { try {
// Get namespace // Get namespace

View file

@ -56,6 +56,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
/** /**
* Delegee for reconciling the config map * Delegee for reconciling the config map
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
/* default */ class ConfigMapReconciler { /* default */ class ConfigMapReconciler {
protected final Logger logger = Logger.getLogger(getClass().getName()); protected final Logger logger = Logger.getLogger(getClass().getName());
@ -80,6 +81,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
* @throws TemplateException the template exception * @throws TemplateException the template exception
* @throws ApiException the API exception * @throws ApiException the API exception
*/ */
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void reconcile(Map<String, Object> model, VmChannel channel, public void reconcile(Map<String, Object> model, VmChannel channel,
boolean modelChanged) boolean modelChanged)
throws IOException, TemplateException, ApiException { throws IOException, TemplateException, ApiException {
@ -187,6 +189,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
private final TemplateMethodModelEx adjustCloudInitMetaModel private final TemplateMethodModelEx adjustCloudInitMetaModel
= new TemplateMethodModelEx() { = new TemplateMethodModelEx() {
@Override @Override
@SuppressWarnings("PMD.PreserveStackTrace")
public Object exec(@SuppressWarnings("rawtypes") List arguments) public Object exec(@SuppressWarnings("rawtypes") List arguments)
throws TemplateModelException { throws TemplateModelException {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.manager;
/** /**
* Some constants. * Some constants.
*/ */
@SuppressWarnings("PMD.DataClass")
public class Constants extends org.jdrupes.vmoperator.common.Constants { public class Constants extends org.jdrupes.vmoperator.common.Constants {
/** The Constant STATE_RUNNING. */ /** The Constant STATE_RUNNING. */

View file

@ -42,6 +42,7 @@ import org.jgrapes.core.Channel;
* of the pod running the VM in response to force an update of the files * of the pod running the VM in response to force an update of the files
* in the pod that reflect the information from the secret. * in the pod that reflect the information from the secret.
*/ */
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.TooManyStaticImports" })
public class DisplaySecretMonitor public class DisplaySecretMonitor
extends AbstractMonitor<V1Secret, V1SecretList, VmChannel> { extends AbstractMonitor<V1Secret, V1SecretList, VmChannel> {

View file

@ -45,6 +45,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
/** /**
* Delegee for reconciling the service * Delegee for reconciling the service
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
/* default */ class LoadBalancerReconciler { /* default */ class LoadBalancerReconciler {
private static final String LOAD_BALANCER_SERVICE = "loadBalancerService"; private static final String LOAD_BALANCER_SERVICE = "loadBalancerService";
@ -85,7 +86,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
} }
// Check if to be generated // Check if to be generated
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "unchecked" })
var lbsDef = Optional.of(model) var lbsDef = Optional.of(model)
.map(m -> (Map<String, Object>) m.get("reconciler")) .map(m -> (Map<String, Object>) m.get("reconciler"))
.map(c -> c.get(LOAD_BALANCER_SERVICE)).orElse(Boolean.FALSE); .map(c -> c.get(LOAD_BALANCER_SERVICE)).orElse(Boolean.FALSE);

View file

@ -81,7 +81,7 @@ import org.jgrapes.webconsole.vuejs.VueJsConsoleWeblet;
/** /**
* The application class. * The application class.
*/ */
@SuppressWarnings({ "PMD.ExcessiveImports" }) @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" })
public class Manager extends Component { public class Manager extends Component {
private static String version; private static String version;
@ -97,8 +97,8 @@ public class Manager extends Component {
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
* @throws URISyntaxException * @throws URISyntaxException
*/ */
@SuppressWarnings({ "PMD.NcssCount", @SuppressWarnings({ "PMD.TooFewBranchesForASwitchStatement",
"PMD.ConstructorCallsOverridableMethod" }) "PMD.NcssCount", "PMD.ConstructorCallsOverridableMethod" })
public Manager(CommandLine cmdLine) throws IOException, URISyntaxException { public Manager(CommandLine cmdLine) throws IOException, URISyntaxException {
super(new NamedChannel("manager")); super(new NamedChannel("manager"));
// Prepare component tree // Prepare component tree
@ -217,6 +217,7 @@ public class Manager extends Component {
* @param event the event * @param event the event
*/ */
@Handler @Handler
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public void onConfigurationUpdate(ConfigurationUpdate event) { public void onConfigurationUpdate(ConfigurationUpdate event) {
event.structured(componentPath()).ifPresent(c -> { event.structured(componentPath()).ifPresent(c -> {
if (c.containsKey("clusterName")) { if (c.containsKey("clusterName")) {
@ -290,6 +291,7 @@ public class Manager extends Component {
* @param args the arguments * @param args the arguments
* @throws Exception the exception * @throws Exception the exception
*/ */
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public static void main(String[] args) { public static void main(String[] args) {
try { try {
// Instance logger is not available yet. // Instance logger is not available yet.

View file

@ -43,6 +43,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
/** /**
* Delegee for reconciling the pod. * Delegee for reconciling the pod.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
/* default */ class PodReconciler { /* default */ class PodReconciler {
protected final Logger logger = Logger.getLogger(getClass().getName()); protected final Logger logger = Logger.getLogger(getClass().getName());

View file

@ -53,6 +53,7 @@ import org.jgrapes.core.events.Attached;
* {@link VmPoolChanged} events fired on a special pipeline to * {@link VmPoolChanged} events fired on a special pipeline to
* avoid concurrent change informations. * avoid concurrent change informations.
*/ */
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" })
public class PoolMonitor extends public class PoolMonitor extends
AbstractMonitor<K8sDynamicModel, K8sDynamicModels, Channel> { AbstractMonitor<K8sDynamicModel, K8sDynamicModels, Channel> {

View file

@ -49,6 +49,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
/** /**
* Delegee for reconciling the stateful set (effectively the pod). * Delegee for reconciling the stateful set (effectively the pod).
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
/* default */ class PvcReconciler { /* default */ class PvcReconciler {
protected final Logger logger = Logger.getLogger(getClass().getName()); protected final Logger logger = Logger.getLogger(getClass().getName());
@ -74,7 +75,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
* @throws TemplateException the template exception * @throws TemplateException the template exception
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "unchecked" })
public void reconcile(VmDefinition vmDef, Map<String, Object> model, public void reconcile(VmDefinition vmDef, Map<String, Object> model,
VmChannel channel, boolean specChanged) VmChannel channel, boolean specChanged)
throws IOException, TemplateException, ApiException { throws IOException, TemplateException, ApiException {

View file

@ -137,13 +137,15 @@ import org.jgrapes.util.events.ConfigurationUpdate;
* *
* @see org.jdrupes.vmoperator.manager.DisplaySecretReconciler * @see org.jdrupes.vmoperator.manager.DisplaySecretReconciler
*/ */
@SuppressWarnings({ "PMD.AvoidDuplicateLiterals" }) @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis",
"PMD.AvoidDuplicateLiterals" })
public class Reconciler extends Component { public class Reconciler extends Component {
/** The Constant mapper. */ /** The Constant mapper. */
@SuppressWarnings("PMD.FieldNamingConventions") @SuppressWarnings("PMD.FieldNamingConventions")
protected static final ObjectMapper mapper = new ObjectMapper(); protected static final ObjectMapper mapper = new ObjectMapper();
@SuppressWarnings("PMD.SingularField")
private final Configuration fmConfig; private final Configuration fmConfig;
private final ConfigMapReconciler cmReconciler; private final ConfigMapReconciler cmReconciler;
private final DisplaySecretReconciler dsReconciler; private final DisplaySecretReconciler dsReconciler;
@ -201,6 +203,7 @@ public class Reconciler extends Component {
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
@Handler @Handler
@SuppressWarnings("PMD.ConfusingTernary")
public void onVmResourceChanged(VmResourceChanged event, VmChannel channel) public void onVmResourceChanged(VmResourceChanged event, VmChannel channel)
throws ApiException, TemplateException, IOException { throws ApiException, TemplateException, IOException {
// Ownership relationships takes care of deletions // Ownership relationships takes care of deletions
@ -335,6 +338,7 @@ public class Reconciler extends Component {
private final TemplateMethodModelEx formatMemoryModel private final TemplateMethodModelEx formatMemoryModel
= new TemplateMethodModelEx() { = new TemplateMethodModelEx() {
@Override @Override
@SuppressWarnings("PMD.PreserveStackTrace")
public Object exec(@SuppressWarnings("rawtypes") List arguments) public Object exec(@SuppressWarnings("rawtypes") List arguments)
throws TemplateModelException { throws TemplateModelException {
var arg = arguments.get(0); var arg = arguments.get(0);
@ -364,7 +368,8 @@ public class Reconciler extends Component {
private final TemplateMethodModelEx imgageLocationModel private final TemplateMethodModelEx imgageLocationModel
= new TemplateMethodModelEx() { = new TemplateMethodModelEx() {
@Override @Override
@SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition" }) @SuppressWarnings({ "PMD.PreserveStackTrace",
"PMD.AvoidLiteralsInIfCondition" })
public Object exec(@SuppressWarnings("rawtypes") List arguments) public Object exec(@SuppressWarnings("rawtypes") List arguments)
throws TemplateModelException { throws TemplateModelException {
var image = ((SimpleScalar) arguments.get(0)).getAsString(); var image = ((SimpleScalar) arguments.get(0)).getAsString();
@ -389,6 +394,7 @@ public class Reconciler extends Component {
private final TemplateMethodModelEx toJsonModel private final TemplateMethodModelEx toJsonModel
= new TemplateMethodModelEx() { = new TemplateMethodModelEx() {
@Override @Override
@SuppressWarnings("PMD.PreserveStackTrace")
public Object exec(@SuppressWarnings("rawtypes") List arguments) public Object exec(@SuppressWarnings("rawtypes") List arguments)
throws TemplateModelException { throws TemplateModelException {
try { try {

View file

@ -71,6 +71,7 @@ import org.jgrapes.core.annotation.Handler;
* event pipeline should be used for all events related to changes of * event pipeline should be used for all events related to changes of
* a particular VM. * a particular VM.
*/ */
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" })
public class VmMonitor extends public class VmMonitor extends
AbstractMonitor<VmDefinition, VmDefinitions, VmChannel> { AbstractMonitor<VmDefinition, VmDefinitions, VmChannel> {
@ -106,6 +107,7 @@ public class VmMonitor extends
purge(); purge();
} }
@SuppressWarnings("PMD.CognitiveComplexity")
private void purge() throws ApiException { private void purge() throws ApiException {
// Get existing CRs (VMs) // Get existing CRs (VMs)
var known = K8sDynamicStub.list(client(), context(), namespace()) var known = K8sDynamicStub.list(client(), context(), namespace())
@ -190,6 +192,7 @@ public class VmMonitor extends
} }
} }
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
private void addExtraData(VmDefinition vmDef, VmDefinition prevState) { private void addExtraData(VmDefinition vmDef, VmDefinition prevState) {
var extra = new VmExtraData(vmDef); var extra = new VmExtraData(vmDef);
var prevExtra = Optional.ofNullable(prevState).map(VmDefinition::extra); var prevExtra = Optional.ofNullable(prevState).map(VmDefinition::extra);
@ -238,6 +241,7 @@ public class VmMonitor extends
.ofNullable(pod.getSpec().getNodeName()).orElse(""); .ofNullable(pod.getSpec().getNodeName()).orElse("");
logger.finer(() -> "Adding node name " + nodeName logger.finer(() -> "Adding node name " + nodeName
+ " to VM info for " + vmDef.name()); + " to VM info for " + vmDef.name());
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
var addrs = new ArrayList<String>(); var addrs = new ArrayList<String>();
Optional.ofNullable(pod.getStatus().getPodIPs()) Optional.ofNullable(pod.getStatus().getPodIPs())
.orElse(Collections.emptyList()).stream() .orElse(Collections.emptyList()).stream()

View file

@ -36,6 +36,7 @@ import org.jgrapes.core.annotation.Handler;
/** /**
* The Class CdMediaController. * The Class CdMediaController.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class CdMediaController extends Component { public class CdMediaController extends Component {
/** /**
@ -54,6 +55,7 @@ public class CdMediaController extends Component {
* *
* @param componentChannel the component channel * @param componentChannel the component channel
*/ */
@SuppressWarnings("PMD.AssignmentToNonFinalStatic")
public CdMediaController(Channel componentChannel) { public CdMediaController(Channel componentChannel) {
super(componentChannel); super(componentChannel);
} }
@ -64,7 +66,8 @@ public class CdMediaController extends Component {
* @param event the event * @param event the event
*/ */
@Handler @Handler
@SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops" }) @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
"PMD.AvoidInstantiatingObjectsInLoops" })
public void onConfigureQemu(ConfigureQemu event) { public void onConfigureQemu(ConfigureQemu event) {
if (event.runState() == RunState.TERMINATING) { if (event.runState() == RunState.TERMINATING) {
return; return;

View file

@ -39,9 +39,11 @@ import org.jdrupes.vmoperator.util.FsdUtils;
/** /**
* The configuration information from the configuration file. * The configuration information from the configuration file.
*/ */
@SuppressWarnings({ "PMD.ExcessivePublicCount", "PMD.TooManyFields" })
public class Configuration implements Dto { public class Configuration implements Dto {
private static final String CI_INSTANCE_ID = "instance-id"; private static final String CI_INSTANCE_ID = "instance-id";
@SuppressWarnings("PMD.FieldNamingConventions")
protected final Logger logger = Logger.getLogger(getClass().getName()); protected final Logger logger = Logger.getLogger(getClass().getName());
/** Configuration timestamp. */ /** Configuration timestamp. */
@ -93,12 +95,15 @@ public class Configuration implements Dto {
public static class CloudInit implements Dto { public static class CloudInit implements Dto {
/** The meta data. */ /** The meta data. */
@SuppressWarnings("PMD.UseConcurrentHashMap")
public Map<String, Object> metaData; public Map<String, Object> metaData;
/** The user data. */ /** The user data. */
@SuppressWarnings("PMD.UseConcurrentHashMap")
public Map<String, Object> userData; public Map<String, Object> userData;
/** The network config. */ /** The network config. */
@SuppressWarnings("PMD.UseConcurrentHashMap")
public Map<String, Object> networkConfig; public Map<String, Object> networkConfig;
} }
@ -294,6 +299,7 @@ public class Configuration implements Dto {
return true; return true;
} }
@SuppressWarnings("PMD.AvoidLiteralsInIfCondition")
private void checkDrives() { private void checkDrives() {
for (Drive drive : vm.drives) { for (Drive drive : vm.drives) {
if (drive.file != null || drive.device != null if (drive.file != null || drive.device != null
@ -313,6 +319,7 @@ public class Configuration implements Dto {
} }
} }
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
private boolean checkRuntimeDir() { private boolean checkRuntimeDir() {
// Runtime directory (sockets etc.) // Runtime directory (sockets etc.)
if (runtimeDir == null) { if (runtimeDir == null) {
@ -348,6 +355,7 @@ public class Configuration implements Dto {
return true; return true;
} }
@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
private boolean checkDataDir() { private boolean checkDataDir() {
// Data directory // Data directory
if (dataDir == null) { if (dataDir == null) {

View file

@ -41,6 +41,7 @@ import org.jgrapes.core.events.Start;
* A (sub)component that updates the console status in the CR status. * A (sub)component that updates the console status in the CR status.
* Created as child of {@link StatusUpdater}. * Created as child of {@link StatusUpdater}.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class ConsoleTracker extends VmDefUpdater { public class ConsoleTracker extends VmDefUpdater {
private VmDefinitionStub vmStub; private VmDefinitionStub vmStub;
@ -52,6 +53,7 @@ public class ConsoleTracker extends VmDefUpdater {
* *
* @param componentChannel the component channel * @param componentChannel the component channel
*/ */
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
public ConsoleTracker(Channel componentChannel) { public ConsoleTracker(Channel componentChannel) {
super(componentChannel); super(componentChannel);
apiClient = (K8sClient) io.kubernetes.client.openapi.Configuration apiClient = (K8sClient) io.kubernetes.client.openapi.Configuration
@ -89,7 +91,8 @@ public class ConsoleTracker extends VmDefUpdater {
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@Handler @Handler
@SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition" }) @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
"PMD.AvoidDuplicateLiterals" })
public void onSpiceInitialized(SpiceInitializedEvent event) public void onSpiceInitialized(SpiceInitializedEvent event)
throws ApiException { throws ApiException {
if (vmStub == null) { if (vmStub == null) {
@ -124,6 +127,7 @@ public class ConsoleTracker extends VmDefUpdater {
* @throws ApiException the api exception * @throws ApiException the api exception
*/ */
@Handler @Handler
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void onSpiceDisconnected(SpiceDisconnectedEvent event) public void onSpiceDisconnected(SpiceDisconnectedEvent event)
throws ApiException { throws ApiException {
if (vmStub == null) { if (vmStub == null) {

View file

@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.runner.qemu;
/** /**
* Some constants. * Some constants.
*/ */
@SuppressWarnings("PMD.DataClass")
public class Constants extends org.jdrupes.vmoperator.common.Constants { public class Constants extends org.jdrupes.vmoperator.common.Constants {
/** /**

View file

@ -41,6 +41,7 @@ import org.jgrapes.core.annotation.Handler;
/** /**
* The Class CpuController. * The Class CpuController.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class CpuController extends Component { public class CpuController extends Component {
private Integer currentCpus; private Integer currentCpus;

View file

@ -43,6 +43,7 @@ import org.jgrapes.util.events.WatchFile;
/** /**
* The Class DisplayController. * The Class DisplayController.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class DisplayController extends Component { public class DisplayController extends Component {
private String currentPassword; private String currentPassword;
@ -58,7 +59,8 @@ public class DisplayController extends Component {
* @param componentChannel the component channel * @param componentChannel the component channel
* @param configDir * @param configDir
*/ */
@SuppressWarnings({ "PMD.ConstructorCallsOverridableMethod" }) @SuppressWarnings({ "PMD.AssignmentToNonFinalStatic",
"PMD.ConstructorCallsOverridableMethod" })
public DisplayController(Channel componentChannel, Path configDir) { public DisplayController(Channel componentChannel, Path configDir) {
super(componentChannel); super(componentChannel);
this.configDir = configDir; this.configDir = configDir;
@ -112,6 +114,7 @@ public class DisplayController extends Component {
* @param event the event * @param event the event
*/ */
@Handler @Handler
@SuppressWarnings("PMD.EmptyCatchBlock")
public void onFileChanged(FileChanged event) { public void onFileChanged(FileChanged event) {
if (event.path().equals(configDir.resolve(DisplaySecret.PASSWORD))) { if (event.path().equals(configDir.resolve(DisplaySecret.PASSWORD))) {
logger.fine(() -> "Display password updated"); logger.fine(() -> "Display password updated");

View file

@ -54,6 +54,7 @@ import org.jgrapes.util.events.ConfigurationUpdate;
* If the log level for this class is set to fine, the messages * If the log level for this class is set to fine, the messages
* exchanged on the monitor socket are logged. * exchanged on the monitor socket are logged.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class QemuMonitor extends QemuConnector { public class QemuMonitor extends QemuConnector {
private int powerdownTimeout; private int powerdownTimeout;
@ -71,6 +72,8 @@ public class QemuMonitor extends QemuConnector {
* @param configDir the config dir * @param configDir the config dir
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
@SuppressWarnings({ "PMD.AssignmentToNonFinalStatic",
"PMD.ConstructorCallsOverridableMethod" })
public QemuMonitor(Channel componentChannel, Path configDir) public QemuMonitor(Channel componentChannel, Path configDir)
throws IOException { throws IOException {
super(componentChannel); super(componentChannel);

View file

@ -39,6 +39,7 @@ public class RamController extends Component {
* *
* @param componentChannel the component channel * @param componentChannel the component channel
*/ */
@SuppressWarnings("PMD.AssignmentToNonFinalStatic")
public RamController(Channel componentChannel) { public RamController(Channel componentChannel) {
super(componentChannel); super(componentChannel);
} }

View file

@ -201,7 +201,8 @@ import org.jgrapes.util.events.WatchFile;
* *
*/ */
@SuppressWarnings({ "PMD.ExcessiveImports", "PMD.AvoidPrintStackTrace", @SuppressWarnings({ "PMD.ExcessiveImports", "PMD.AvoidPrintStackTrace",
"PMD.TooManyMethods", "PMD.CouplingBetweenObjects" }) "PMD.DataflowAnomalyAnalysis", "PMD.TooManyMethods",
"PMD.CouplingBetweenObjects", "PMD.TooManyFields" })
public class Runner extends Component { public class Runner extends Component {
private static final String TEMPLATE_DIR private static final String TEMPLATE_DIR
@ -217,6 +218,7 @@ public class Runner extends Component {
.builder().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) .builder().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
.build()); .build());
private final JsonNode defaults; private final JsonNode defaults;
@SuppressWarnings("PMD.UseConcurrentHashMap")
private final File configFile; private final File configFile;
private final Path configDir; private final Path configDir;
private Configuration initialConfig; private Configuration initialConfig;
@ -248,7 +250,8 @@ public class Runner extends Component {
* @param cmdLine the cmd line * @param cmdLine the cmd line
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
@SuppressWarnings({ "PMD.ConstructorCallsOverridableMethod" }) @SuppressWarnings({ "PMD.SystemPrintln",
"PMD.ConstructorCallsOverridableMethod" })
public Runner(CommandLine cmdLine) throws IOException { public Runner(CommandLine cmdLine) throws IOException {
yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
false); false);
@ -384,6 +387,8 @@ public class Runner extends Component {
} }
} }
@SuppressWarnings({ "PMD.CognitiveComplexity",
"PMD.DataflowAnomalyAnalysis" })
private void setFirmwarePaths(Configuration config) throws IOException { private void setFirmwarePaths(Configuration config) throws IOException {
JsonNode firmware = defaults.path("firmware").path(config.vm.firmware); JsonNode firmware = defaults.path("firmware").path(config.vm.firmware);
// Get file for firmware ROM // Get file for firmware ROM
@ -615,6 +620,8 @@ public class Runner extends Component {
* @throws InterruptedException the interrupted exception * @throws InterruptedException the interrupted exception
*/ */
@Handler @Handler
@SuppressWarnings({ "PMD.SwitchStmtsShouldHaveDefault",
"PMD.TooFewBranchesForASwitchStatement" })
public void onProcessStarted(ProcessStarted event, ProcessChannel channel) public void onProcessStarted(ProcessStarted event, ProcessChannel channel)
throws InterruptedException { throws InterruptedException {
event.startEvent().associated(CommandDefinition.class) event.startEvent().associated(CommandDefinition.class)
@ -771,6 +778,7 @@ public class Runner extends Component {
"The VM has been shut down")); "The VM has been shut down"));
} }
@SuppressWarnings("PMD.ConfusingArgumentToVarargsMethod")
private void shutdown() { private void shutdown() {
if (!Set.of(RunState.TERMINATING, RunState.STOPPED).contains(state)) { if (!Set.of(RunState.TERMINATING, RunState.STOPPED).contains(state)) {
fire(new Stop()); fire(new Stop());

View file

@ -66,7 +66,8 @@ import org.jgrapes.core.events.Start;
/** /**
* Updates the CR status. * Updates the CR status.
*/ */
@SuppressWarnings({ "PMD.CouplingBetweenObjects" }) @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis",
"PMD.CouplingBetweenObjects" })
public class StatusUpdater extends VmDefUpdater { public class StatusUpdater extends VmDefUpdater {
@SuppressWarnings("PMD.FieldNamingConventions") @SuppressWarnings("PMD.FieldNamingConventions")
@ -89,6 +90,7 @@ public class StatusUpdater extends VmDefUpdater {
* *
* @param componentChannel the component channel * @param componentChannel the component channel
*/ */
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
public StatusUpdater(Channel componentChannel) { public StatusUpdater(Channel componentChannel) {
super(componentChannel); super(componentChannel);
attach(new ConsoleTracker(componentChannel)); attach(new ConsoleTracker(componentChannel));
@ -151,6 +153,7 @@ public class StatusUpdater extends VmDefUpdater {
* @throws ApiException * @throws ApiException
*/ */
@Handler @Handler
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void onConfigureQemu(ConfigureQemu event) public void onConfigureQemu(ConfigureQemu event)
throws ApiException { throws ApiException {
guestShutdownStops = event.configuration().guestShutdownStops; guestShutdownStops = event.configuration().guestShutdownStops;
@ -184,7 +187,8 @@ public class StatusUpdater extends VmDefUpdater {
* @throws ApiException * @throws ApiException
*/ */
@Handler @Handler
@SuppressWarnings({ "PMD.AssignmentInOperand" }) @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
"PMD.AssignmentInOperand", "PMD.AvoidDuplicateLiterals" })
public void onRunnerStateChanged(RunnerStateChange event) public void onRunnerStateChanged(RunnerStateChange event)
throws ApiException { throws ApiException {
VmDefinition vmDef; VmDefinition vmDef;
@ -421,6 +425,7 @@ public class StatusUpdater extends VmDefUpdater {
* @throws ApiException * @throws ApiException
*/ */
@Handler @Handler
@SuppressWarnings("PMD.AssignmentInOperand")
public void onVmopAgentLoggedIn(VmopAgentLoggedIn event) public void onVmopAgentLoggedIn(VmopAgentLoggedIn event)
throws ApiException { throws ApiException {
vmStub.updateStatus(from -> { vmStub.updateStatus(from -> {
@ -437,6 +442,7 @@ public class StatusUpdater extends VmDefUpdater {
* @throws ApiException * @throws ApiException
*/ */
@Handler @Handler
@SuppressWarnings("PMD.AssignmentInOperand")
public void onVmopAgentLoggedOut(VmopAgentLoggedOut event) public void onVmopAgentLoggedOut(VmopAgentLoggedOut event)
throws ApiException { throws ApiException {
vmStub.updateStatus(from -> { vmStub.updateStatus(from -> {

View file

@ -43,6 +43,7 @@ import org.jgrapes.util.events.InitialConfiguration;
/** /**
* Updates the CR status. * Updates the CR status.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class VmDefUpdater extends Component { public class VmDefUpdater extends Component {
protected String namespace; protected String namespace;

View file

@ -87,7 +87,8 @@ public class VmopAgentClient extends AgentConnector {
} }
@Override @Override
@SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition" }) @SuppressWarnings({ "PMD.UnnecessaryReturn",
"PMD.AvoidLiteralsInIfCondition" })
protected void processInput(String line) throws IOException { protected void processInput(String line) throws IOException {
logger.finer(() -> "vmop agent(in): " + line); logger.finer(() -> "vmop agent(in): " + line);

View file

@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode;
*/ */
public class QmpCapabilities extends QmpCommand { public class QmpCapabilities extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"qmp_capabilities\" }"); = parseJson("{ \"execute\": \"qmp_capabilities\" }");

View file

@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
*/ */
public class QmpChangeMedium extends QmpCommand { public class QmpChangeMedium extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"blockdev-change-medium\",\"arguments\": {" = parseJson("{ \"execute\": \"blockdev-change-medium\",\"arguments\": {"
+ "\"id\": \"\",\"filename\": \"\",\"format\": \"raw\"," + "\"id\": \"\",\"filename\": \"\",\"format\": \"raw\","

View file

@ -30,7 +30,8 @@ import java.util.logging.Logger;
*/ */
public abstract class QmpCommand { public abstract class QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
protected static final ObjectMapper mapper = new ObjectMapper(); protected static final ObjectMapper mapper = new ObjectMapper();
/** /**

View file

@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode;
*/ */
public class QmpCont extends QmpCommand { public class QmpCont extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"cont\" }"); = parseJson("{ \"execute\": \"cont\" }");

View file

@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
*/ */
public class QmpDelCpu extends QmpCommand { public class QmpDelCpu extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"device_del\", " = parseJson("{ \"execute\": \"device_del\", "
+ "\"arguments\": " + "{ \"id\": 0 } }"); + "\"arguments\": " + "{ \"id\": 0 } }");

View file

@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
*/ */
public class QmpOpenTray extends QmpCommand { public class QmpOpenTray extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"blockdev-open-tray\",\"arguments\": {" = parseJson("{ \"execute\": \"blockdev-open-tray\",\"arguments\": {"
+ "\"id\": \"\" } }"); + "\"id\": \"\" } }");

View file

@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode;
*/ */
public class QmpPowerdown extends QmpCommand { public class QmpPowerdown extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"system_powerdown\" }"); = parseJson("{ \"execute\": \"system_powerdown\" }");

View file

@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode;
*/ */
public class QmpQueryHotpluggableCpus extends QmpCommand { public class QmpQueryHotpluggableCpus extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate = parseJson( private static final JsonNode jsonTemplate = parseJson(
"{\"execute\":\"query-hotpluggable-cpus\",\"arguments\":{}}"); "{\"execute\":\"query-hotpluggable-cpus\",\"arguments\":{}}");

View file

@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
*/ */
public class QmpRemoveMedium extends QmpCommand { public class QmpRemoveMedium extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"blockdev-remove-medium\",\"arguments\": {" = parseJson("{ \"execute\": \"blockdev-remove-medium\",\"arguments\": {"
+ "\"id\": \"\" } }"); + "\"id\": \"\" } }");

View file

@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode;
*/ */
public class QmpReset extends QmpCommand { public class QmpReset extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"system_reset\" }"); = parseJson("{ \"execute\": \"system_reset\" }");

View file

@ -28,7 +28,8 @@ import java.math.BigInteger;
*/ */
public class QmpSetBalloon extends QmpCommand { public class QmpSetBalloon extends QmpCommand {
@SuppressWarnings({ "PMD.FieldNamingConventions" }) @SuppressWarnings({ "PMD.FieldNamingConventions",
"PMD.VariableNamingConventions" })
private static final JsonNode jsonTemplate private static final JsonNode jsonTemplate
= parseJson("{ \"execute\": \"balloon\", " = parseJson("{ \"execute\": \"balloon\", "
+ "\"arguments\": " + "{ \"value\": 0 } }"); + "\"arguments\": " + "{ \"value\": 0 } }");

View file

@ -49,6 +49,7 @@ public class MonitorEvent extends Event<Void> {
* @param response the response * @param response the response
* @return the optional * @return the optional
*/ */
@SuppressWarnings("PMD.TooFewBranchesForASwitchStatement")
public static Optional<MonitorEvent> from(JsonNode response) { public static Optional<MonitorEvent> from(JsonNode response) {
try { try {
var kind = Kind.valueOf(response.get("event").asText()); var kind = Kind.valueOf(response.get("event").asText());

View file

@ -26,6 +26,7 @@ import org.jgrapes.core.Event;
/** /**
* The Class RunnerStateChange. * The Class RunnerStateChange.
*/ */
@SuppressWarnings("PMD.DataClass")
public class RunnerStateChange extends Event<Void> { public class RunnerStateChange extends Event<Void> {
/** /**

View file

@ -32,6 +32,7 @@ import java.util.logging.Logger;
*/ */
public final class DataPath { public final class DataPath {
@SuppressWarnings("PMD.FieldNamingConventions")
private static final Logger logger private static final Logger logger
= Logger.getLogger(DataPath.class.getName()); = Logger.getLogger(DataPath.class.getName());
@ -55,6 +56,7 @@ public final class DataPath {
* @param selectors the selectors * @param selectors the selectors
* @return the result * @return the result
*/ */
@SuppressWarnings("PMD.UseLocaleWithCaseConversions")
public static <T> Optional<T> get(Object from, Object... selectors) { public static <T> Optional<T> get(Object from, Object... selectors) {
Object cur = from; Object cur = from;
for (var selector : selectors) { for (var selector : selectors) {
@ -130,6 +132,7 @@ public final class DataPath {
@SuppressWarnings({ "PMD.CognitiveComplexity", "unchecked" }) @SuppressWarnings({ "PMD.CognitiveComplexity", "unchecked" })
public static <T> T deepCopy(T object) { public static <T> T deepCopy(T object) {
if (object instanceof Map map) { if (object instanceof Map map) {
@SuppressWarnings("PMD.UseConcurrentHashMap")
Map<Object, Object> copy; Map<Object, Object> copy;
try { try {
copy = (Map<Object, Object>) object.getClass().getConstructor() copy = (Map<Object, Object>) object.getClass().getConstructor()

View file

@ -32,7 +32,8 @@ import java.util.function.Supplier;
/** /**
* Utility class for pointing to elements on a Gson (Json) tree. * Utility class for pointing to elements on a Gson (Json) tree.
*/ */
@SuppressWarnings({ "PMD.ClassWithOnlyPrivateConstructorsShouldBeFinal" }) @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis",
"PMD.ClassWithOnlyPrivateConstructorsShouldBeFinal", "PMD.GodClass" })
public class GsonPtr { public class GsonPtr {
private final JsonElement position; private final JsonElement position;
@ -101,7 +102,7 @@ public class GsonPtr {
* @param selectors the selectors * @param selectors the selectors
* @return the Gson pointer * @return the Gson pointer
*/ */
@SuppressWarnings({ "PMD.PreserveStackTrace" }) @SuppressWarnings({ "PMD.ShortMethodName", "PMD.PreserveStackTrace" })
public Optional<GsonPtr> get(Object... selectors) { public Optional<GsonPtr> get(Object... selectors) {
JsonElement element = position; JsonElement element = position;
for (Object sel : selectors) { for (Object sel : selectors) {
@ -145,6 +146,7 @@ public class GsonPtr {
* @param cls the cls * @param cls the cls
* @return the result * @return the result
*/ */
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop" })
public <T extends JsonElement> T getAs(Class<T> cls) { public <T extends JsonElement> T getAs(Class<T> cls) {
if (cls.isAssignableFrom(position.getClass())) { if (cls.isAssignableFrom(position.getClass())) {
return cls.cast(position); return cls.cast(position);

View file

@ -111,8 +111,9 @@ import org.jgrapes.webconsole.base.freemarker.FreeMarkerConlet;
* users and roles. * users and roles.
* *
*/ */
@SuppressWarnings({ "PMD.ExcessiveImports", "PMD.CouplingBetweenObjects", @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports",
"PMD.GodClass", "PMD.TooManyMethods", "PMD.CyclomaticComplexity" }) "PMD.CouplingBetweenObjects", "PMD.GodClass", "PMD.TooManyMethods",
"PMD.CyclomaticComplexity" })
public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> { public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
private static final String VM_NAME_PROPERTY = "vmName"; private static final String VM_NAME_PROPERTY = "vmName";
@ -166,7 +167,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
* *
* @param event the event * @param event the event
*/ */
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" })
@Handler @Handler
public void onConfigurationUpdate(ConfigurationUpdate event) { public void onConfigurationUpdate(ConfigurationUpdate event) {
event.structured(componentPath()) event.structured(componentPath())
@ -266,7 +267,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
public void onConsoleConfigured(ConsoleConfigured event, public void onConsoleConfigured(ConsoleConfigured event,
ConsoleConnection connection) throws InterruptedException, ConsoleConnection connection) throws InterruptedException,
IOException { IOException {
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked", "PMD.PrematureDeclaration" })
final var rendered final var rendered
= (Set<ResourceModel>) connection.session().get(RENDERED); = (Set<ResourceModel>) connection.session().get(RENDERED);
connection.session().remove(RENDERED); connection.session().remove(RENDERED);
@ -276,7 +277,8 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
addMissingConlets(event, connection, rendered); addMissingConlets(event, connection, rendered);
} }
@SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops" }) @SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops",
"PMD.AvoidDuplicateLiterals" })
private void addMissingConlets(ConsoleConfigured event, private void addMissingConlets(ConsoleConfigured event,
ConsoleConnection connection, final Set<ResourceModel> rendered) ConsoleConnection connection, final Set<ResourceModel> rendered)
throws InterruptedException { throws InterruptedException {
@ -404,6 +406,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
} }
@Override @Override
@SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops" })
protected Set<RenderMode> doRenderConlet(RenderConletRequestBase<?> event, protected Set<RenderMode> doRenderConlet(RenderConletRequestBase<?> event,
ConsoleConnection channel, String conletId, ResourceModel model) ConsoleConnection channel, String conletId, ResourceModel model)
throws Exception { throws Exception {
@ -652,8 +655,9 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
* @throws InterruptedException * @throws InterruptedException
*/ */
@Handler(namedChannels = "manager") @Handler(namedChannels = "manager")
@SuppressWarnings({ "PMD.CognitiveComplexity", @SuppressWarnings({ "PMD.ConfusingTernary", "PMD.CognitiveComplexity",
"PMD.AvoidInstantiatingObjectsInLoops" }) "PMD.AvoidInstantiatingObjectsInLoops", "PMD.AvoidDuplicateLiterals",
"PMD.ConfusingArgumentToVarargsMethod" })
public void onVmResourceChanged(VmResourceChanged event, VmChannel channel) public void onVmResourceChanged(VmResourceChanged event, VmChannel channel)
throws IOException, InterruptedException { throws IOException, InterruptedException {
var vmDef = event.vmDefinition(); var vmDef = event.vmDefinition();
@ -849,7 +853,8 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
model.getConletId(), "openConsole", cf))); model.getConletId(), "openConsole", cf)));
} }
@SuppressWarnings({ "PMD.UseLocaleWithCaseConversions" }) @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
"PMD.UseLocaleWithCaseConversions" })
private void selectResource(NotifyConletModel event, private void selectResource(NotifyConletModel event,
ConsoleConnection channel, ResourceModel model) ConsoleConnection channel, ResourceModel model)
throws JsonProcessingException, InterruptedException { throws JsonProcessingException, InterruptedException {
@ -876,6 +881,7 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
/** /**
* The Class AccessModel. * The Class AccessModel.
*/ */
@SuppressWarnings("PMD.DataClass")
public static class ResourceModel extends ConletBaseModel { public static class ResourceModel extends ConletBaseModel {
/** /**

View file

@ -28,6 +28,7 @@ import java.util.List;
/** /**
* The Class TimeSeries. * The Class TimeSeries.
*/ */
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class TimeSeries { public class TimeSeries {
@SuppressWarnings("PMD.LooseCoupling") @SuppressWarnings("PMD.LooseCoupling")

View file

@ -75,7 +75,8 @@ import org.jgrapes.webconsole.base.freemarker.FreeMarkerConlet;
/** /**
* The Class {@link VmMgmt}. * The Class {@link VmMgmt}.
*/ */
@SuppressWarnings({ "PMD.CouplingBetweenObjects", "PMD.ExcessiveImports" }) @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.CouplingBetweenObjects",
"PMD.ExcessiveImports" })
public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> { public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
private Class<?> preferredIpVersion = Inet4Address.class; private Class<?> preferredIpVersion = Inet4Address.class;
@ -111,7 +112,7 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
* *
* @param event the event * @param event the event
*/ */
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" })
@Handler @Handler
public void onConfigurationUpdate(ConfigurationUpdate event) { public void onConfigurationUpdate(ConfigurationUpdate event) {
event.structured("/Manager/GuiHttpServer" event.structured("/Manager/GuiHttpServer"
@ -176,6 +177,7 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
} }
@Override @Override
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
protected Set<RenderMode> doRenderConlet(RenderConletRequestBase<?> event, protected Set<RenderMode> doRenderConlet(RenderConletRequestBase<?> event,
ConsoleConnection channel, String conletId, VmsModel conletState) ConsoleConnection channel, String conletId, VmsModel conletState)
throws Exception { throws Exception {
@ -228,6 +230,7 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
simplifiedVmDefinition(vmDef, user, roles))); simplifiedVmDefinition(vmDef, user, roles)));
} }
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
private Map<String, Object> simplifiedVmDefinition(VmDefinition vmDef, private Map<String, Object> simplifiedVmDefinition(VmDefinition vmDef,
String user, List<String> roles) { String user, List<String> roles) {
// Convert RAM sizes to unitless numbers // Convert RAM sizes to unitless numbers
@ -267,8 +270,9 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
* @throws IOException * @throws IOException
*/ */
@Handler(namedChannels = "manager") @Handler(namedChannels = "manager")
@SuppressWarnings({ "PMD.CognitiveComplexity", @SuppressWarnings({ "PMD.ConfusingTernary", "PMD.CognitiveComplexity",
"PMD.AvoidInstantiatingObjectsInLoops" }) "PMD.AvoidInstantiatingObjectsInLoops", "PMD.AvoidDuplicateLiterals",
"PMD.ConfusingArgumentToVarargsMethod" })
public void onVmResourceChanged(VmResourceChanged event, VmChannel channel) public void onVmResourceChanged(VmResourceChanged event, VmChannel channel)
throws IOException { throws IOException {
var vmName = event.vmDefinition().name(); var vmName = event.vmDefinition().name();
@ -374,6 +378,8 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
} }
@SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
"PMD.LambdaCanBeMethodReference" })
private Summary evaluateSummary(boolean force) { private Summary evaluateSummary(boolean force) {
if (!force && cachedSummary != null) { if (!force && cachedSummary != null) {
return cachedSummary; return cachedSummary;
@ -396,7 +402,8 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
} }
@Override @Override
@SuppressWarnings({ "PMD.NcssCount" }) @SuppressWarnings({ "PMD.AvoidDecimalLiteralsInBigDecimalConstructor",
"PMD.NcssCount" })
protected void doUpdateConletState(NotifyConletModel event, protected void doUpdateConletState(NotifyConletModel event,
ConsoleConnection channel, VmsModel model) throws Exception { ConsoleConnection channel, VmsModel model) throws Exception {
event.stop(); event.stop();