diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..7dff899 --- /dev/null +++ b/.gitlab-ci.yml @@ -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 diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml deleted file mode 100644 index 56a575c..0000000 --- a/.woodpecker/build.yaml +++ /dev/null @@ -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 diff --git a/dev-example/vmop-agent/gdm/PostLogin/Default b/dev-example/vmop-agent/gdm/PostLogin/Default deleted file mode 100755 index 8a70890..0000000 --- a/dev-example/vmop-agent/gdm/PostLogin/Default +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf diff --git a/dev-example/vmop-agent/vmop-agent b/dev-example/vmop-agent/vmop-agent index 9f4d9e7..f61a55e 100755 --- a/dev-example/vmop-agent/vmop-agent +++ b/dev-example/vmop-agent/vmop-agent @@ -72,8 +72,8 @@ doLogin() { return fi - # Check if this user is already logged in on tty2 - curUser=$(loginctl -j | jq -r '.[] | select(.tty=="tty2") | .user') + # Check if this user is already logged in on tty1 + curUser=$(loginctl -j | jq -r '.[] | select(.tty=="tty1") | .user') if [ "$curUser" = "$user" ]; then echo >&${con} "201 User already logged in" return @@ -96,14 +96,17 @@ doLogin() { return fi fi - - # Configure user as auto login user - sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf - sed -i '/\[daemon\]/a AutomaticLoginEnable=true\nAutomaticLogin='$user \ - /etc/gdm/custom.conf - - # Activate user - systemctl restart gdm + + # Start the desktop for the user + systemd-run 2>$temperr \ + --unit vmop-user-desktop --uid=$uid --gid=$uid \ + --working-directory="/home/$user" -p TTYPath=/dev/tty1 \ + -p PAMName=login -p StandardInput=tty -p StandardOutput=journal \ + -p Conflicts="gdm.service getty@tty1.service" \ + -E XDG_RUNTIME_DIR="/run/user/$uid" \ + -E XDG_CURRENT_DESKTOP=GNOME \ + -p ExecStartPre="/usr/bin/chvt 1" \ + dbus-run-session -- gnome-shell --display-server --wayland if [ $? -eq 0 ]; then echo >&${con} "201 User logged in successfully" else @@ -114,8 +117,14 @@ doLogin() { # Attempt to log out a user currently using tty1. This is an intermediate # operation that can be invoked from other operations attemptLogout() { - sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf - systemctl stop gdm + systemctl status vmop-user-desktop > /dev/null 2>&1 + if [ $? = 0 ]; then + systemctl stop vmop-user-desktop + fi + loginctl -j | jq -r '.[] | select(.tty=="tty1") | .session' \ + | while read sid; do + loginctl kill-session $sid + done echo >&${con} "102 Desktop stopped" } @@ -124,7 +133,15 @@ attemptLogout() { # Also try to restart gdm, if it is not running. doLogout() { 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" } @@ -136,7 +153,7 @@ while read line <&${con}; do done onExit() { - doLogout + attemptLogout if [ -n "$temperr" ]; then rm -f $temperr fi diff --git a/org.jdrupes.vmoperator.common/build.gradle b/org.jdrupes.vmoperator.common/build.gradle index e72cb14..c9f1413 100644 --- a/org.jdrupes.vmoperator.common/build.gradle +++ b/org.jdrupes.vmoperator.common/build.gradle @@ -11,7 +11,7 @@ plugins { dependencies { api project(':org.jdrupes.vmoperator.util') api 'org.jgrapes:org.jgrapes.core:[1.22.1,2)' - api 'io.kubernetes:client-java:[19.0.0,20.0.0)' + api 'io.kubernetes:client-java:[23.0.0,24.0.0)' api 'org.yaml:snakeyaml' api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:[2.16.1,3]' } diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/Convertions.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/Convertions.java index 68f52eb..47b7208 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/Convertions.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/Convertions.java @@ -32,11 +32,13 @@ import java.util.regex.Pattern; public class Convertions { @SuppressWarnings({ "PMD.UseConcurrentHashMap", - "PMD.FieldNamingConventions" }) + "PMD.FieldNamingConventions", "PMD.VariableNamingConventions" }) private static final Map unitMap = new HashMap<>(); - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final List> unitMappings; - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final Pattern memorySize = Pattern.compile("^\\s*(\\d+(\\.\\d+)?)\\s*([A-Za-z]*)\\s*"); @@ -67,6 +69,7 @@ public class Convertions { * @param amount the amount * @return the big integer */ + @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public static BigInteger parseMemory(Object amount) { if (amount == null) { return (BigInteger) amount; diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/DynamicTypeAdapterFactory.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/DynamicTypeAdapterFactory.java index d21eed4..9625b98 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/DynamicTypeAdapterFactory.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/DynamicTypeAdapterFactory.java @@ -26,7 +26,7 @@ import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.kubernetes.client.openapi.ApiClient; +import io.kubernetes.client.openapi.JSON; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; @@ -45,18 +45,15 @@ public class DynamicTypeAdapterFactory yamlData = new Yaml(new SafeConstructor(new LoaderOptions())).load(yaml); // There's no short-cut from Java (collections) to Gson - var gson = client.getJSON().getGson(); + var gson = JSON.getGson(); var jsonText = gson.toJson(yamlData); return gson.fromJson(jsonText, JsonObject.class); } @@ -243,7 +246,7 @@ public class K8s { if (event.getRegarding() == null) { event.regarding(objectReference(object)); } - new EventsV1Api(client).createNamespacedEvent( - object.getMetadata().getNamespace(), event, null, null, null, null); + new EventsV1Api(client) + .createNamespacedEvent(object.getMetadata().getNamespace(), event); } } diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClient.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClient.java index 272da2b..efe1fb6 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClient.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClient.java @@ -31,6 +31,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Type; +import java.net.URI; import java.text.DateFormat; import java.time.format.DateTimeFormatter; import java.util.Collection; @@ -48,7 +49,8 @@ import okhttp3.Response; * A client with some additional properties. */ @SuppressWarnings({ "PMD.ExcessivePublicCount", "PMD.TooManyMethods", - "checkstyle:LineLength", "PMD.CouplingBetweenObjects", "PMD.GodClass" }) + "PMD.LinguisticNaming", "checkstyle:LineLength", + "PMD.CouplingBetweenObjects", "PMD.GodClass" }) public class K8sClient extends ApiClient { private ApiClient apiClient; @@ -230,6 +232,7 @@ public class K8sClient extends ApiClient { * @return the api client * @see ApiClient#setKeyManagers(javax.net.ssl.KeyManager[]) */ + @SuppressWarnings("PMD.UseVarargs") @Override public ApiClient setKeyManagers(KeyManager[] managers) { return apiClient().setKeyManagers(managers); @@ -636,6 +639,7 @@ public class K8sClient extends ApiClient { * @return the string * @see ApiClient#selectHeaderAccept(java.lang.String[]) */ + @SuppressWarnings("PMD.UseVarargs") @Override public String selectHeaderAccept(String[] accepts) { return apiClient().selectHeaderAccept(accepts); @@ -648,6 +652,7 @@ public class K8sClient extends ApiClient { * @return the string * @see ApiClient#selectHeaderContentType(java.lang.String[]) */ + @SuppressWarnings("PMD.UseVarargs") @Override public String selectHeaderContentType(String[] contentTypes) { return apiClient().selectHeaderContentType(contentTypes); @@ -800,6 +805,7 @@ public class K8sClient extends ApiClient { /** * Builds the call. * + * @param baseUrl the base url * @param path the path * @param method the method * @param queryParams the query params @@ -814,14 +820,15 @@ public class K8sClient extends ApiClient { * @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) */ - @SuppressWarnings({ "rawtypes" }) + @SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" }) @Override - public Call buildCall(String path, String method, List queryParams, - List collectionQueryParams, Object body, - Map headerParams, Map cookieParams, - Map formParams, String[] authNames, + public Call buildCall(String baseUrl, String path, String method, + List queryParams, List collectionQueryParams, + Object body, Map headerParams, + Map cookieParams, Map formParams, + String[] authNames, ApiCallback callback) throws ApiException { - return apiClient().buildCall(path, method, queryParams, + return apiClient().buildCall(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); } @@ -829,6 +836,7 @@ public class K8sClient extends ApiClient { /** * Builds the request. * + * @param baseUrl the base url * @param path the path * @param method the method * @param queryParams the query params @@ -843,14 +851,14 @@ public class K8sClient extends ApiClient { * @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) */ - @SuppressWarnings({ "rawtypes" }) + @SuppressWarnings({ "rawtypes", "PMD.ExcessiveParameterList" }) @Override - public Request buildRequest(String path, String method, + public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { - return apiClient().buildRequest(path, method, queryParams, + return apiClient().buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); } @@ -858,6 +866,7 @@ public class K8sClient extends ApiClient { /** * Builds the url. * + * @param baseUrl the base url * @param path the path * @param queryParams the query params * @param collectionQueryParams the collection query params @@ -865,9 +874,10 @@ public class K8sClient extends ApiClient { * @see ApiClient#buildUrl(java.lang.String, java.util.List, java.util.List) */ @Override - public String buildUrl(String path, List queryParams, + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { - return apiClient().buildUrl(path, queryParams, collectionQueryParams); + return apiClient().buildUrl(baseUrl, path, queryParams, + collectionQueryParams); } /** @@ -903,14 +913,15 @@ public class K8sClient extends ApiClient { * @param queryParams the query params * @param headerParams the header params * @param cookieParams the cookie params + * @throws ApiException * @see ApiClient#updateParamsForAuth(java.lang.String[], java.util.List, java.util.Map, java.util.Map) */ @Override public void updateParamsForAuth(String[] authNames, List queryParams, - Map headerParams, - Map cookieParams) { + Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { apiClient().updateParamsForAuth(authNames, queryParams, headerParams, - cookieParams); + cookieParams, payload, method, uri); } /** diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClusterGenericStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClusterGenericStub.java index 59b4d12..6b5fd7e 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClusterGenericStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sClusterGenericStub.java @@ -45,7 +45,8 @@ import java.util.function.Function; * @param the generic type * @param the generic type */ -@SuppressWarnings({ "PMD.CouplingBetweenObjects" }) +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", + "PMD.CouplingBetweenObjects" }) public class K8sClusterGenericStub { protected final K8sClient client; @@ -254,6 +255,7 @@ public class K8sClusterGenericStub objectClass, Class objectListClass, K8sClient client, APIResource context, String name); } @@ -282,6 +284,7 @@ public class K8sClusterGenericStub> R get(Class objectClass, Class objectListClass, @@ -312,6 +315,8 @@ public class K8sClusterGenericStub> R get(Class objectClass, Class objectListClass, @@ -336,6 +341,8 @@ public class K8sClusterGenericStub> R create(Class objectClass, Class objectListClass, diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModel.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModel.java index 2392d3e..dd2bdd5 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModel.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModel.java @@ -29,6 +29,7 @@ import io.kubernetes.client.openapi.models.V1ObjectMeta; * notably the metadata, is made available through the methods * defined by {@link KubernetesObject}. */ +@SuppressWarnings("PMD.DataClass") public class K8sDynamicModel implements KubernetesObject { private final V1ObjectMeta metadata; diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModelsBase.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModelsBase.java index 4e21c0e..61c17be 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModelsBase.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicModelsBase.java @@ -22,7 +22,7 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.kubernetes.client.common.KubernetesListObject; -import io.kubernetes.client.openapi.Configuration; +import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.openapi.models.V1ListMeta; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -62,7 +62,7 @@ public class K8sDynamicModelsBase } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException exc) { - throw new IllegalArgumentException(exc); + throw new IllegalArgumentException(exc); // NOPMD } } } @@ -147,9 +147,7 @@ public class K8sDynamicModelsBase * @param objectMeta the new metadata */ public void setMetadata(V1ListMeta objectMeta) { - data.add("metadata", - Configuration.getDefaultApiClient().getJSON().getGson() - .toJsonTree(objectMeta)); + data.add("metadata", JSON.getGson().toJsonTree(objectMeta)); } @Override diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStub.java index c0303c2..42658d0 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStub.java @@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.common; import io.kubernetes.client.Discovery.APIResource; import io.kubernetes.client.apimachinery.GroupVersionKind; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.util.generic.options.ListOptions; import java.io.Reader; import java.util.Collection; @@ -31,6 +32,7 @@ import java.util.Collection; * state and can therefore be used for any kind of object, especially * custom objects. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sDynamicStub extends K8sDynamicStubBase { @@ -63,6 +65,8 @@ public class K8sDynamicStub * @return the stub if the object exists * @throws ApiException the api exception */ + @SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop", + "PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" }) public static K8sDynamicStub get(K8sClient client, GroupVersionKind gvk, String namespace, String name) throws ApiException { @@ -80,6 +84,8 @@ public class K8sDynamicStub * @return the stub if the object exists * @throws ApiException the api exception */ + @SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop", + "PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" }) public static K8sDynamicStub get(K8sClient client, APIResource context, String namespace, String name) { return new K8sDynamicStub(client, context, namespace, name); @@ -96,8 +102,8 @@ public class K8sDynamicStub */ public static K8sDynamicStub createFromYaml(K8sClient client, APIResource context, Reader yaml) throws ApiException { - var model = new K8sDynamicModel(client.getJSON().getGson(), - K8s.yamlToJson(client, yaml)); + var model + = new K8sDynamicModel(JSON.getGson(), K8s.yamlToJson(client, yaml)); return K8sGenericStub.create(K8sDynamicModel.class, K8sDynamicModels.class, client, context, model, (c, ns, n) -> new K8sDynamicStub(c, context, ns, n)); diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStubBase.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStubBase.java index ae3f012..1d39847 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStubBase.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sDynamicStubBase.java @@ -26,6 +26,7 @@ import io.kubernetes.client.Discovery.APIResource; * state and can therefore be used for any kind of object, especially * custom objects. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public abstract class K8sDynamicStubBase> extends K8sGenericStub { @@ -39,11 +40,12 @@ public abstract class K8sDynamicStubBase objectClass, Class objectListClass, DynamicTypeAdapterFactory taf, K8sClient client, APIResource context, String namespace, String name) { super(objectClass, objectListClass, client, context, namespace, name); - taf.register(client); + taf.register(); } } \ No newline at end of file diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java index 9ba376f..627dd83 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sGenericStub.java @@ -24,6 +24,7 @@ import io.kubernetes.client.common.KubernetesListObject; import io.kubernetes.client.common.KubernetesObject; import io.kubernetes.client.custom.V1Patch; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.util.Strings; import io.kubernetes.client.util.generic.GenericKubernetesApi; import io.kubernetes.client.util.generic.KubernetesApiResponse; @@ -48,7 +49,7 @@ import java.util.function.Function; * @param the generic type * @param the generic type */ -@SuppressWarnings({ "PMD.TooManyMethods" }) +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.TooManyMethods" }) public class K8sGenericStub { protected final K8sClient client; @@ -200,6 +201,7 @@ public class K8sGenericStub updateStatus(O object, Function updater) throws ApiException { return K8s.optional(api.updateStatus(object, updater)); @@ -217,7 +219,7 @@ public class K8sGenericStub updateStatus(Function updater, O current, int retries) throws ApiException { while (true) { @@ -247,6 +249,7 @@ public class K8sGenericStub updateStatus(Function updater, int retries) throws ApiException { return updateStatus(updater, null, retries); @@ -323,7 +326,7 @@ public class K8sGenericStub> R create(Class objectClass, Class objectListClass, diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sObserver.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sObserver.java index 9e22382..f3e10bb 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sObserver.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sObserver.java @@ -50,6 +50,7 @@ public class K8sObserver objectClass, Class objectListClass, K8sClient client, APIResource context, String namespace, @@ -98,6 +100,7 @@ public class K8sObserver { diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1DeploymentStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1DeploymentStub.java index 9075a84..16e5c82 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1DeploymentStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1DeploymentStub.java @@ -29,6 +29,7 @@ import java.util.Optional; /** * A stub for pods (v1). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sV1DeploymentStub extends K8sGenericStub { diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1NodeStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1NodeStub.java index ea1237d..050c593 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1NodeStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1NodeStub.java @@ -29,6 +29,7 @@ import java.util.List; /** * A stub for nodes (v1). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sV1NodeStub extends K8sClusterGenericStub { public static final APIResource CONTEXT = new APIResource("", List.of("v1"), @@ -73,7 +74,8 @@ public class K8sV1NodeStub extends K8sClusterGenericStub { /** * Provide {@link GenericSupplier}. */ - @SuppressWarnings({ "PMD.UnusedFormalParameter" }) + @SuppressWarnings({ "PMD.UnusedFormalParameter", + "PMD.UnusedPrivateMethod" }) private static K8sV1NodeStub getGeneric(Class objectClass, Class objectListClass, K8sClient client, APIResource context, String name) { diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PodStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PodStub.java index f21bb47..21ac931 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PodStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PodStub.java @@ -29,6 +29,7 @@ import java.util.List; /** * A stub for pods (v1). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sV1PodStub extends K8sGenericStub { /** The pods' context. */ diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PvcStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PvcStub.java index c46a60f..876e648 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PvcStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1PvcStub.java @@ -29,6 +29,7 @@ import java.util.List; /** * A stub for pods (v1). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sV1PvcStub extends K8sGenericStub { diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1SecretStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1SecretStub.java index 9c1c086..a847d36 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1SecretStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1SecretStub.java @@ -29,6 +29,7 @@ import java.util.List; /** * A stub for secrets (v1). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sV1SecretStub extends K8sGenericStub { public static final APIResource CONTEXT = new APIResource("", List.of("v1"), diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1ServiceStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1ServiceStub.java index 863f86f..2157a1d 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1ServiceStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1ServiceStub.java @@ -29,6 +29,7 @@ import java.util.List; /** * A stub for secrets (v1). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sV1ServiceStub extends K8sGenericStub { public static final APIResource CONTEXT = new APIResource("", List.of("v1"), diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1StatefulSetStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1StatefulSetStub.java index be30b00..b918725 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1StatefulSetStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/K8sV1StatefulSetStub.java @@ -26,6 +26,7 @@ import java.util.List; /** * A stub for stateful sets (v1). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class K8sV1StatefulSetStub extends K8sGenericStub { diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinition.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinition.java index a0b66bf..2d5e2fe 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinition.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinition.java @@ -46,14 +46,15 @@ import org.jdrupes.vmoperator.util.DataPath; /** * Represents a VM definition. */ -@SuppressWarnings({ "PMD.DataClass", "PMD.TooManyMethods" }) +@SuppressWarnings({ "PMD.DataClass", "PMD.TooManyMethods", + "PMD.CouplingBetweenObjects" }) public class VmDefinition extends K8sDynamicModel { - @SuppressWarnings({ "unused" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", "unused" }) private static final Logger logger = Logger.getLogger(VmDefinition.class.getName()); @SuppressWarnings("PMD.FieldNamingConventions") - private static final Gson gson = new JSON().getGson(); + private static final Gson gson = JSON.getGson(); @SuppressWarnings("PMD.FieldNamingConventions") private static final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinitionStub.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinitionStub.java index 377220a..57cd210 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinitionStub.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmDefinitionStub.java @@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.common; import io.kubernetes.client.Discovery.APIResource; import io.kubernetes.client.apimachinery.GroupVersionKind; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.util.generic.options.ListOptions; import java.io.Reader; import java.util.Collection; @@ -31,6 +32,7 @@ import java.util.Collection; * state and can therefore be used for any kind of object, especially * custom objects. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class VmDefinitionStub extends K8sDynamicStubBase { @@ -63,6 +65,8 @@ public class VmDefinitionStub * @return the stub if the object exists * @throws ApiException the api exception */ + @SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop", + "PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" }) public static VmDefinitionStub get(K8sClient client, GroupVersionKind gvk, String namespace, String name) throws ApiException { @@ -80,6 +84,8 @@ public class VmDefinitionStub * @return the stub if the object exists * @throws ApiException the api exception */ + @SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop", + "PMD.AvoidInstantiatingObjectsInLoops", "PMD.UseObjectForClearerAPI" }) public static VmDefinitionStub get(K8sClient client, APIResource context, String namespace, String name) { return new VmDefinitionStub(client, context, namespace, name); @@ -96,8 +102,8 @@ public class VmDefinitionStub */ public static VmDefinitionStub createFromYaml(K8sClient client, APIResource context, Reader yaml) throws ApiException { - var model = new VmDefinition(client.getJSON().getGson(), - K8s.yamlToJson(client, yaml)); + var model + = new VmDefinition(JSON.getGson(), K8s.yamlToJson(client, yaml)); return K8sGenericStub.create(VmDefinition.class, VmDefinitions.class, client, context, model, (c, ns, n) -> new VmDefinitionStub(c, context, ns, n)); diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmExtraData.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmExtraData.java index e1565c5..6a94c9c 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmExtraData.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmExtraData.java @@ -34,6 +34,7 @@ import java.util.logging.Logger; */ public class VmExtraData { + @SuppressWarnings("PMD.FieldNamingConventions") private static final Logger logger = Logger.getLogger(VmExtraData.class.getName()); diff --git a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmPool.java b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmPool.java index f7aaa67..2bf1c30 100644 --- a/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmPool.java +++ b/org.jdrupes.vmoperator.common/src/org/jdrupes/vmoperator/common/VmPool.java @@ -35,6 +35,7 @@ import org.jdrupes.vmoperator.util.DataPath; /** * Represents a VM pool. */ +@SuppressWarnings({ "PMD.DataClass" }) public class VmPool { private final String name; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/AssignVm.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/AssignVm.java index 7252c6a..21e6031 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/AssignVm.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/AssignVm.java @@ -24,6 +24,7 @@ import org.jgrapes.core.Event; /** * Assign a VM from a pool to a user. */ +@SuppressWarnings("PMD.DataClass") public class AssignVm extends Event { private final String fromPool; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelDictionary.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelDictionary.java index 2b23532..05a079e 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelDictionary.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelDictionary.java @@ -43,6 +43,7 @@ public interface ChannelDictionary { * @param channel the channel * @param associated the associated */ + @SuppressWarnings("PMD.ShortClassName") public record Value(C channel, A associated) { } diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelManager.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelManager.java index da36123..ce0e4f0 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelManager.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ChannelManager.java @@ -149,6 +149,8 @@ public class ChannelManager * @param supplier the supplier * @return the channel */ + @SuppressWarnings({ "PMD.AssignmentInOperand", + "PMD.DataflowAnomalyAnalysis" }) public C computeIfAbsent(K key, Function supplier) { return entries.computeIfAbsent(key, k -> new Value<>(supplier.apply(k), null)).channel(); diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetDisplaySecret.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetDisplaySecret.java index dc47b4a..2f7dbd6 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetDisplaySecret.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetDisplaySecret.java @@ -24,6 +24,7 @@ import org.jgrapes.core.Event; /** * Gets the current display secret and optionally updates it. */ +@SuppressWarnings("PMD.DataClass") public class GetDisplaySecret extends Event { private final VmDefinition vmDef; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetPools.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetPools.java index b563c9c..40fa6ad 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetPools.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetPools.java @@ -27,6 +27,7 @@ import org.jgrapes.core.Event; /** * Gets the known pools' definitions. */ +@SuppressWarnings("PMD.DataClass") public class GetPools extends Event> { private String name; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetVms.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetVms.java index 0e24013..8b00698 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetVms.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/GetVms.java @@ -27,6 +27,7 @@ import org.jgrapes.core.Event; /** * Gets the known VMs' definitions and channels. */ +@SuppressWarnings("PMD.DataClass") public class GetVms extends Event> { private String name; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ModifyVm.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ModifyVm.java index 9e19255..8f735da 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ModifyVm.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ModifyVm.java @@ -24,6 +24,7 @@ import org.jgrapes.core.Event; /** * Modifies a VM. */ +@SuppressWarnings("PMD.DataClass") public class ModifyVm extends Event { private final String name; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ResetVm.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ResetVm.java index 778820e..f3320c8 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ResetVm.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/ResetVm.java @@ -23,6 +23,7 @@ import org.jgrapes.core.Event; /** * Triggers a reset of the VM. */ +@SuppressWarnings("PMD.DataClass") public class ResetVm extends Event { private final String vmName; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/UpdateAssignment.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/UpdateAssignment.java index b4fcf56..af9dde0 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/UpdateAssignment.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/UpdateAssignment.java @@ -24,6 +24,7 @@ import org.jgrapes.core.Event; /** * Note the assignment to a user in the VM status. */ +@SuppressWarnings("PMD.DataClass") public class UpdateAssignment extends Event { private final VmPool fromPool; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmChannel.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmChannel.java index 73507ae..7b03ad3 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmChannel.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmChannel.java @@ -28,6 +28,7 @@ import org.jgrapes.core.Subchannel.DefaultSubchannel; /** * A subchannel used to send the events related to a specific VM. */ +@SuppressWarnings("PMD.DataClass") public class VmChannel extends DefaultSubchannel { private final EventPipeline pipeline; @@ -55,6 +56,7 @@ public class VmChannel extends DefaultSubchannel { * @param definition the definition * @return the watch channel */ + @SuppressWarnings("PMD.LinguisticNaming") public VmChannel setVmDefinition(VmDefinition definition) { this.definition = definition; return this; @@ -85,6 +87,7 @@ public class VmChannel extends DefaultSubchannel { * @param generation the generation to set * @return true if value has changed */ + @SuppressWarnings("PMD.LinguisticNaming") public boolean setGeneration(long generation) { if (this.generation == generation) { return false; diff --git a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmPoolChanged.java b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmPoolChanged.java index 0c3f3a1..0c506a1 100644 --- a/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmPoolChanged.java +++ b/org.jdrupes.vmoperator.manager.events/src/org/jdrupes/vmoperator/manager/events/VmPoolChanged.java @@ -26,6 +26,7 @@ import org.jgrapes.core.Event; /** * Indicates a change in a pool configuration. */ +@SuppressWarnings("PMD.DataClass") public class VmPoolChanged extends Event { private final VmPool vmPool; diff --git a/org.jdrupes.vmoperator.manager/build.gradle b/org.jdrupes.vmoperator.manager/build.gradle index 4ce4ed0..eda5ce0 100644 --- a/org.jdrupes.vmoperator.manager/build.gradle +++ b/org.jdrupes.vmoperator.manager/build.gradle @@ -17,7 +17,7 @@ dependencies { implementation 'org.jgrapes:org.jgrapes.io:[2.12.1,3)' implementation 'org.jgrapes:org.jgrapes.http:[3.5.0,4)' - implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.3.0,3)' + implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.2.0,3)' implementation 'org.jgrapes:org.jgrapes.webconsole.vuejs:[1.8.0,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.rbac:[1.4.0,2)' implementation 'org.jgrapes:org.jgrapes.webconlet.oidclogin:[1.7.0,2)' diff --git a/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerConfig.ftl.yaml b/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerConfig.ftl.yaml index 0200021..5dc8d9b 100644 --- a/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerConfig.ftl.yaml +++ b/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerConfig.ftl.yaml @@ -37,7 +37,7 @@ data: # The template to use. Resolved relative to /usr/share/vmrunner/templates. # template: "Standard-VM-latest.ftl.yaml" <#if spec.runnerTemplate?? && spec.runnerTemplate.source?? > - template: ${ spec.runnerTemplate.source } + template: ${ cm.spec().runnerTemplate.source } # The template is copied to the data diretory when the VM starts for diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/AbstractMonitor.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/AbstractMonitor.java index c10752e..eb545a3 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/AbstractMonitor.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/AbstractMonitor.java @@ -51,6 +51,7 @@ import org.jgrapes.util.events.ConfigurationUpdate; * @param the object type for the context * @param the object list type for the context */ +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis" }) public abstract class AbstractMonitor extends Component { @@ -180,6 +181,7 @@ public abstract class AbstractMonitor model, VmChannel channel, boolean modelChanged) throws IOException, TemplateException, ApiException { @@ -187,6 +189,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; private final TemplateMethodModelEx adjustCloudInitMetaModel = new TemplateMethodModelEx() { @Override + @SuppressWarnings("PMD.PreserveStackTrace") public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { @SuppressWarnings("unchecked") diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Constants.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Constants.java index 2ef4199..c5c8528 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Constants.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Constants.java @@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.manager; /** * Some constants. */ +@SuppressWarnings("PMD.DataClass") public class Constants extends org.jdrupes.vmoperator.common.Constants { /** The Constant STATE_RUNNING. */ diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Controller.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Controller.java index ce14488..c15acc5 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Controller.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Controller.java @@ -50,7 +50,6 @@ import org.jdrupes.vmoperator.manager.events.VmPoolChanged; import org.jdrupes.vmoperator.manager.events.VmResourceChanged; import org.jgrapes.core.Channel; import org.jgrapes.core.Component; -import org.jgrapes.core.EventPipeline; import org.jgrapes.core.annotation.Handler; import org.jgrapes.core.events.HandlingError; import org.jgrapes.core.events.Start; @@ -95,7 +94,7 @@ import org.jgrapes.util.events.ConfigurationUpdate; public class Controller extends Component { private String namespace; - private final ChannelManager chanMgr; + private final ChannelManager chanMgr; /** * Creates a new instance. diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java index b094b79..a254c0e 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretMonitor.java @@ -42,6 +42,7 @@ import org.jgrapes.core.Channel; * 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. */ +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.TooManyStaticImports" }) public class DisplaySecretMonitor extends AbstractMonitor { diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretReconciler.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretReconciler.java index 1e3eb0f..60d27d4 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretReconciler.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/DisplaySecretReconciler.java @@ -66,6 +66,7 @@ import org.jose4j.base64url.Base64; * * `passwordValidity`: the validity of the random password in seconds. * Used to calculate the password expiry time in the generated secret. */ +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.TooManyStaticImports" }) public class DisplaySecretReconciler extends Component { protected final Logger logger = Logger.getLogger(getClass().getName()); @@ -103,15 +104,12 @@ public class DisplaySecretReconciler extends Component { return oldConfig; }).ifPresent(c -> { try { - Optional.ofNullable(c.get("passwordValidity")) - .map(p -> p instanceof Integer ? (Integer) p - : Integer.valueOf((String) p)) - .ifPresent(p -> { - passwordValidity = p; - }); - } catch (NumberFormatException e) { - logger.warning( - () -> "Malformed configuration: " + e.getMessage()); + if (c.containsKey("passwordValidity")) { + passwordValidity = Integer + .parseInt((String) c.get("passwordValidity")); + } + } catch (ClassCastException e) { + logger.config("Malformed configuration: " + e.getMessage()); } }); } @@ -192,6 +190,7 @@ public class DisplaySecretReconciler extends Component { * @throws ApiException the api exception */ @Handler + @SuppressWarnings("PMD.StringInstantiation") public void onGetDisplaySecret(GetDisplaySecret event, VmChannel channel) throws ApiException { // Get VM definition and check if running @@ -320,6 +319,7 @@ public class DisplaySecretReconciler extends Component { /** * The Class PendingGet. */ + @SuppressWarnings("PMD.DataClass") private static class PendingRequest { public final GetDisplaySecret event; public final long expectedSerial; diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/LoadBalancerReconciler.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/LoadBalancerReconciler.java index a66b432..b04a35f 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/LoadBalancerReconciler.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/LoadBalancerReconciler.java @@ -22,6 +22,7 @@ import com.google.gson.Gson; import freemarker.template.Configuration; import freemarker.template.TemplateException; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.openapi.models.V1APIService; import io.kubernetes.client.openapi.models.V1ObjectMeta; import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesObject; @@ -45,6 +46,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; /** * Delegee for reconciling the service */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") /* default */ class LoadBalancerReconciler { private static final String LOAD_BALANCER_SERVICE = "loadBalancerService"; @@ -85,7 +87,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; } // Check if to be generated - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "unchecked" }) var lbsDef = Optional.of(model) .map(m -> (Map) m.get("reconciler")) .map(c -> c.get(LOAD_BALANCER_SERVICE)).orElse(Boolean.FALSE); @@ -121,7 +123,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; ? (Map>) lbsDef : null; var client = channel.client(); - mergeMetadata(client.getJSON().getGson(), svcDef, defaults, vmDef); + mergeMetadata(JSON.getGson(), svcDef, defaults, vmDef); // Apply var svcStub = K8sV1ServiceStub diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Manager.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Manager.java index f431c9d..41b59f9 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Manager.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Manager.java @@ -81,7 +81,7 @@ import org.jgrapes.webconsole.vuejs.VueJsConsoleWeblet; /** * The application class. */ -@SuppressWarnings({ "PMD.ExcessiveImports" }) +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" }) public class Manager extends Component { private static String version; @@ -97,8 +97,8 @@ public class Manager extends Component { * @throws IOException Signals that an I/O exception has occurred. * @throws URISyntaxException */ - @SuppressWarnings({ "PMD.NcssCount", - "PMD.ConstructorCallsOverridableMethod" }) + @SuppressWarnings({ "PMD.TooFewBranchesForASwitchStatement", + "PMD.NcssCount", "PMD.ConstructorCallsOverridableMethod" }) public Manager(CommandLine cmdLine) throws IOException, URISyntaxException { super(new NamedChannel("manager")); // Prepare component tree @@ -217,6 +217,7 @@ public class Manager extends Component { * @param event the event */ @Handler + @SuppressWarnings("PMD.DataflowAnomalyAnalysis") public void onConfigurationUpdate(ConfigurationUpdate event) { event.structured(componentPath()).ifPresent(c -> { if (c.containsKey("clusterName")) { @@ -290,6 +291,7 @@ public class Manager extends Component { * @param args the arguments * @throws Exception the exception */ + @SuppressWarnings("PMD.SignatureDeclareThrowsException") public static void main(String[] args) { try { // Instance logger is not available yet. diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PodReconciler.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PodReconciler.java index 4733e73..4b7f394 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PodReconciler.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PodReconciler.java @@ -43,6 +43,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; /** * Delegee for reconciling the pod. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") /* default */ class PodReconciler { protected final Logger logger = Logger.getLogger(getClass().getName()); diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PoolMonitor.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PoolMonitor.java index e554d5a..6c9a823 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PoolMonitor.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PoolMonitor.java @@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.manager; import com.google.gson.JsonObject; import io.kubernetes.client.apimachinery.GroupVersionKind; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.util.Watch; import java.io.IOException; import java.util.Collections; @@ -53,6 +54,7 @@ import org.jgrapes.core.events.Attached; * {@link VmPoolChanged} events fired on a special pipeline to * avoid concurrent change informations. */ +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" }) public class PoolMonitor extends AbstractMonitor { @@ -129,7 +131,7 @@ public class PoolMonitor extends // Get pool and merge changes var vmPool = pools.computeIfAbsent(poolName, k -> new VmPool(poolName)); - vmPool.defineFrom(client().getJSON().getGson().fromJson( + vmPool.defineFrom(JSON.getGson().fromJson( GsonPtr.to(poolModel.data()).to("spec").get(), VmPool.class)); poolPipeline.fire(new VmPoolChanged(vmPool)); } diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PvcReconciler.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PvcReconciler.java index 515bfc9..b0f97fd 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PvcReconciler.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/PvcReconciler.java @@ -25,6 +25,7 @@ import freemarker.template.TemplateException; import freemarker.template.TemplateNotFoundException; import io.kubernetes.client.custom.V1Patch; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.JSON; import io.kubernetes.client.util.generic.dynamic.Dynamics; import io.kubernetes.client.util.generic.options.ListOptions; import io.kubernetes.client.util.generic.options.PatchOptions; @@ -49,6 +50,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; /** * Delegee for reconciling the stateful set (effectively the pod). */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") /* default */ class PvcReconciler { protected final Logger logger = Logger.getLogger(getClass().getName()); @@ -74,7 +76,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; * @throws TemplateException the template exception * @throws ApiException the api exception */ - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "unchecked" }) public void reconcile(VmDefinition vmDef, Map model, VmChannel channel, boolean specChanged) throws IOException, TemplateException, ApiException { @@ -159,8 +161,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; opts.setForce(true); opts.setFieldManager("kubernetes-java-kubectl-apply"); if (pvcStub.patch(V1Patch.PATCH_FORMAT_APPLY_YAML, - new V1Patch(channel.client().getJSON().serialize(pvcDef)), opts) - .isEmpty()) { + new V1Patch(JSON.serialize(pvcDef)), opts).isEmpty()) { logger.warning( () -> "Could not patch pvc for " + pvcStub.name()); } @@ -202,8 +203,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; opts.setForce(true); opts.setFieldManager("kubernetes-java-kubectl-apply"); if (pvcStub.patch(V1Patch.PATCH_FORMAT_APPLY_YAML, - new V1Patch(channel.client().getJSON().serialize(pvcDef)), opts) - .isEmpty()) { + new V1Patch(JSON.serialize(pvcDef)), opts).isEmpty()) { logger.warning( () -> "Could not patch pvc for " + pvcStub.name()); } @@ -217,8 +217,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; PatchOptions opts = new PatchOptions(); opts.setFieldManager("kubernetes-java-kubectl-apply"); if (pvcStub.patch(V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH, - new V1Patch(channel.client().getJSON().serialize(pvcDef)), opts) - .isEmpty()) { + new V1Patch(JSON.serialize(pvcDef)), opts).isEmpty()) { logger.warning( () -> "Could not patch pvc for " + pvcStub.name()); } diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java index e580c48..700b081 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java @@ -137,13 +137,15 @@ import org.jgrapes.util.events.ConfigurationUpdate; * * @see org.jdrupes.vmoperator.manager.DisplaySecretReconciler */ -@SuppressWarnings({ "PMD.AvoidDuplicateLiterals" }) +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", + "PMD.AvoidDuplicateLiterals" }) public class Reconciler extends Component { /** The Constant mapper. */ @SuppressWarnings("PMD.FieldNamingConventions") protected static final ObjectMapper mapper = new ObjectMapper(); + @SuppressWarnings("PMD.SingularField") private final Configuration fmConfig; private final ConfigMapReconciler cmReconciler; private final DisplaySecretReconciler dsReconciler; @@ -201,6 +203,7 @@ public class Reconciler extends Component { * @throws IOException Signals that an I/O exception has occurred. */ @Handler + @SuppressWarnings("PMD.ConfusingTernary") public void onVmResourceChanged(VmResourceChanged event, VmChannel channel) throws ApiException, TemplateException, IOException { // Ownership relationships takes care of deletions @@ -335,6 +338,7 @@ public class Reconciler extends Component { private final TemplateMethodModelEx formatMemoryModel = new TemplateMethodModelEx() { @Override + @SuppressWarnings("PMD.PreserveStackTrace") public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { var arg = arguments.get(0); @@ -364,7 +368,8 @@ public class Reconciler extends Component { private final TemplateMethodModelEx imgageLocationModel = new TemplateMethodModelEx() { @Override - @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition" }) + @SuppressWarnings({ "PMD.PreserveStackTrace", + "PMD.AvoidLiteralsInIfCondition" }) public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { var image = ((SimpleScalar) arguments.get(0)).getAsString(); @@ -389,6 +394,7 @@ public class Reconciler extends Component { private final TemplateMethodModelEx toJsonModel = new TemplateMethodModelEx() { @Override + @SuppressWarnings("PMD.PreserveStackTrace") public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { try { diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/VmMonitor.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/VmMonitor.java index 22f083c..09bade8 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/VmMonitor.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/VmMonitor.java @@ -22,6 +22,7 @@ import com.google.gson.JsonObject; import io.kubernetes.client.apimachinery.GroupVersionKind; import io.kubernetes.client.custom.V1Patch; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.models.V1ObjectMeta; import io.kubernetes.client.util.Watch; import io.kubernetes.client.util.generic.options.ListOptions; import java.io.IOException; @@ -31,6 +32,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Optional; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import org.jdrupes.vmoperator.common.Constants.Crd; import org.jdrupes.vmoperator.common.Constants.Status; @@ -55,27 +57,16 @@ import org.jdrupes.vmoperator.manager.events.VmResourceChanged; import org.jdrupes.vmoperator.util.GsonPtr; import org.jgrapes.core.Channel; import org.jgrapes.core.Event; -import org.jgrapes.core.EventPipeline; import org.jgrapes.core.annotation.Handler; /** - * Watches for changes of VM definitions. When a VM definition (CR) - * becomes known, is is registered with a {@link ChannelManager} and thus - * gets an associated {@link VmChannel} and an associated - * {@link EventPipeline}. - * - * The {@link EventPipeline} is used for submitting an action that processes - * the change data from kubernetes, eventually transforming it to a - * {@link VmResourceChanged} event that is handled by another - * {@link EventPipeline} associated with the {@link VmChannel}. This - * event pipeline should be used for all events related to changes of - * a particular VM. + * Watches for changes of VM definitions. */ +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports" }) public class VmMonitor extends AbstractMonitor { - private final ChannelManager channelManager; + private final ChannelManager channelManager; /** * Instantiates a new VM definition watcher. @@ -84,7 +75,7 @@ public class VmMonitor extends * @param channelManager the channel manager */ public VmMonitor(Channel componentChannel, - ChannelManager channelManager) { + ChannelManager channelManager) { super(componentChannel, VmDefinition.class, VmDefinitions.class); this.channelManager = channelManager; @@ -106,6 +97,7 @@ public class VmMonitor extends purge(); } + @SuppressWarnings("PMD.CognitiveComplexity") private void purge() throws ApiException { // Get existing CRs (VMs) var known = K8sDynamicStub.list(client(), context(), namespace()) @@ -130,18 +122,14 @@ public class VmMonitor extends @Override protected void handleChange(K8sClient client, Watch.Response response) { - var name = response.object.getMetadata().getName(); + V1ObjectMeta metadata = response.object.getMetadata(); + AtomicBoolean toBeAdded = new AtomicBoolean(false); + VmChannel channel = channelManager.channel(metadata.getName()) + .orElseGet(() -> { + toBeAdded.set(true); + return channelManager.createChannel(metadata.getName()); + }); - // Process the response data on a VM specific pipeline to - // increase concurrency when e.g. starting many VMs. - var preparing = channelManager.associated(name) - .orElseGet(() -> newEventPipeline()); - preparing.submit("VmChange[" + name + "]", - () -> processChange(client, response, preparing)); - } - - private void processChange(K8sClient client, - Watch.Response response, EventPipeline preparing) { // Get full definition and associate with channel as backup var vmDef = response.object; if (vmDef.data() == null) { @@ -149,9 +137,6 @@ public class VmMonitor extends // https://github.com/kubernetes-client/java/issues/3215 vmDef = getModel(client, vmDef); } - var name = response.object.getMetadata().getName(); - var channel = channelManager.channel(name) - .orElseGet(() -> channelManager.createChannel(name)); if (vmDef.data() != null) { // New data, augment and save addExtraData(vmDef, channel.vmDefinition()); @@ -165,7 +150,9 @@ public class VmMonitor extends + response.object.getMetadata()); return; } - channelManager.put(name, channel, preparing); + if (toBeAdded.get()) { + channelManager.put(vmDef.name(), channel); + } // Create and fire changed event. Remove channel from channel // manager on completion. @@ -190,6 +177,7 @@ public class VmMonitor extends } } + @SuppressWarnings("PMD.AvoidDuplicateLiterals") private void addExtraData(VmDefinition vmDef, VmDefinition prevState) { var extra = new VmExtraData(vmDef); var prevExtra = Optional.ofNullable(prevState).map(VmDefinition::extra); @@ -211,16 +199,9 @@ public class VmMonitor extends @Handler public void onPodChanged(PodChanged event, VmChannel channel) { var vmDef = channel.vmDefinition(); - - // Make sure that this is properly sync'd with VM CR changes. - channelManager.associated(vmDef.name()) - .orElseGet(() -> activeEventPipeline()) - .submit("NodeInfo[" + vmDef.name() + "]", - () -> { - updateNodeInfo(event, vmDef); - channel.fire(new VmResourceChanged(ResponseType.MODIFIED, - vmDef, false, true)); - }); + updateNodeInfo(event, vmDef); + channel + .fire(new VmResourceChanged(ResponseType.MODIFIED, vmDef, false, true)); } private void updateNodeInfo(PodChanged event, VmDefinition vmDef) { @@ -238,6 +219,7 @@ public class VmMonitor extends .ofNullable(pod.getSpec().getNodeName()).orElse(""); logger.finer(() -> "Adding node name " + nodeName + " to VM info for " + vmDef.name()); + @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") var addrs = new ArrayList(); Optional.ofNullable(pod.getStatus().getPodIPs()) .orElse(Collections.emptyList()).stream() diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CdMediaController.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CdMediaController.java index c4ac871..0a8971c 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CdMediaController.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CdMediaController.java @@ -36,6 +36,7 @@ import org.jgrapes.core.annotation.Handler; /** * The Class CdMediaController. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class CdMediaController extends Component { /** @@ -54,6 +55,7 @@ public class CdMediaController extends Component { * * @param componentChannel the component channel */ + @SuppressWarnings("PMD.AssignmentToNonFinalStatic") public CdMediaController(Channel componentChannel) { super(componentChannel); } @@ -64,7 +66,8 @@ public class CdMediaController extends Component { * @param event the event */ @Handler - @SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops" }) + @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition", + "PMD.AvoidInstantiatingObjectsInLoops" }) public void onConfigureQemu(ConfigureQemu event) { if (event.runState() == RunState.TERMINATING) { return; diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java index 87e8c76..50635b5 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java @@ -39,9 +39,11 @@ import org.jdrupes.vmoperator.util.FsdUtils; /** * The configuration information from the configuration file. */ +@SuppressWarnings({ "PMD.ExcessivePublicCount", "PMD.TooManyFields" }) public class Configuration implements Dto { private static final String CI_INSTANCE_ID = "instance-id"; + @SuppressWarnings("PMD.FieldNamingConventions") protected final Logger logger = Logger.getLogger(getClass().getName()); /** Configuration timestamp. */ @@ -93,12 +95,15 @@ public class Configuration implements Dto { public static class CloudInit implements Dto { /** The meta data. */ + @SuppressWarnings("PMD.UseConcurrentHashMap") public Map metaData; /** The user data. */ + @SuppressWarnings("PMD.UseConcurrentHashMap") public Map userData; /** The network config. */ + @SuppressWarnings("PMD.UseConcurrentHashMap") public Map networkConfig; } @@ -294,6 +299,7 @@ public class Configuration implements Dto { return true; } + @SuppressWarnings("PMD.AvoidLiteralsInIfCondition") private void checkDrives() { for (Drive drive : vm.drives) { if (drive.file != null || drive.device != null @@ -313,6 +319,7 @@ public class Configuration implements Dto { } } + @SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts") private boolean checkRuntimeDir() { // Runtime directory (sockets etc.) if (runtimeDir == null) { @@ -348,6 +355,7 @@ public class Configuration implements Dto { return true; } + @SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts") private boolean checkDataDir() { // Data directory if (dataDir == null) { diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/ConsoleTracker.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/ConsoleTracker.java index b50b481..ddfc702 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/ConsoleTracker.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/ConsoleTracker.java @@ -41,6 +41,7 @@ import org.jgrapes.core.events.Start; * A (sub)component that updates the console status in the CR status. * Created as child of {@link StatusUpdater}. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class ConsoleTracker extends VmDefUpdater { private VmDefinitionStub vmStub; @@ -52,6 +53,7 @@ public class ConsoleTracker extends VmDefUpdater { * * @param componentChannel the component channel */ + @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") public ConsoleTracker(Channel componentChannel) { super(componentChannel); apiClient = (K8sClient) io.kubernetes.client.openapi.Configuration @@ -89,7 +91,8 @@ public class ConsoleTracker extends VmDefUpdater { * @throws ApiException the api exception */ @Handler - @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition" }) + @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition", + "PMD.AvoidDuplicateLiterals" }) public void onSpiceInitialized(SpiceInitializedEvent event) throws ApiException { if (vmStub == null) { @@ -124,6 +127,7 @@ public class ConsoleTracker extends VmDefUpdater { * @throws ApiException the api exception */ @Handler + @SuppressWarnings("PMD.AvoidDuplicateLiterals") public void onSpiceDisconnected(SpiceDisconnectedEvent event) throws ApiException { if (vmStub == null) { diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Constants.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Constants.java index eac05fa..ca88f0b 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Constants.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Constants.java @@ -21,6 +21,7 @@ package org.jdrupes.vmoperator.runner.qemu; /** * Some constants. */ +@SuppressWarnings("PMD.DataClass") public class Constants extends org.jdrupes.vmoperator.common.Constants { /** diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CpuController.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CpuController.java index 440da91..b0abfd4 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CpuController.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/CpuController.java @@ -41,6 +41,7 @@ import org.jgrapes.core.annotation.Handler; /** * The Class CpuController. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class CpuController extends Component { private Integer currentCpus; diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/DisplayController.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/DisplayController.java index c3bec93..f5deda8 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/DisplayController.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/DisplayController.java @@ -43,6 +43,7 @@ import org.jgrapes.util.events.WatchFile; /** * The Class DisplayController. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class DisplayController extends Component { private String currentPassword; @@ -58,7 +59,8 @@ public class DisplayController extends Component { * @param componentChannel the component channel * @param configDir */ - @SuppressWarnings({ "PMD.ConstructorCallsOverridableMethod" }) + @SuppressWarnings({ "PMD.AssignmentToNonFinalStatic", + "PMD.ConstructorCallsOverridableMethod" }) public DisplayController(Channel componentChannel, Path configDir) { super(componentChannel); this.configDir = configDir; @@ -112,6 +114,7 @@ public class DisplayController extends Component { * @param event the event */ @Handler + @SuppressWarnings("PMD.EmptyCatchBlock") public void onFileChanged(FileChanged event) { if (event.path().equals(configDir.resolve(DisplaySecret.PASSWORD))) { logger.fine(() -> "Display password updated"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/GuestAgentClient.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/GuestAgentClient.java index 45d2487..b0001e4 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/GuestAgentClient.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/GuestAgentClient.java @@ -69,14 +69,14 @@ public class GuestAgentClient extends AgentConnector { */ @Override protected void agentConnected() { - logger.fine(() -> "Guest agent connected"); + logger.fine(() -> "guest agent connected"); connected = true; rep().fire(new GuestAgentCommand(new QmpGuestGetOsinfo())); } @Override protected void agentDisconnected() { - logger.fine(() -> "Guest agent disconnected"); + logger.fine(() -> "guest agent disconnected"); connected = false; } @@ -88,16 +88,15 @@ public class GuestAgentClient extends AgentConnector { */ @Override protected void processInput(String line) throws IOException { - logger.finer(() -> "guest agent(in): " + line); + logger.fine(() -> "guest agent(in): " + line); try { var response = mapper.readValue(line, ObjectNode.class); if (response.has("return") || response.has("error")) { QmpCommand executed = executing.poll(); - logger.finer(() -> String.format("(Previous \"guest agent(in)\"" + logger.fine(() -> String.format("(Previous \"guest agent(in)\"" + " is result from executing %s)", executed)); if (executed instanceof QmpGuestGetOsinfo) { var osInfo = new OsinfoEvent(response.get("return")); - logger.fine(() -> "Guest agent triggers: " + osInfo); rep().fire(osInfo); } } @@ -121,11 +120,10 @@ public class GuestAgentClient extends AgentConnector { return; } var command = event.command(); - logger.fine(() -> "Guest handles: " + event); + logger.fine(() -> "guest agent(out): " + command.toString()); String asText; try { asText = command.asText(); - logger.finer(() -> "guest agent(out): " + asText); } catch (JsonProcessingException e) { logger.log(Level.SEVERE, e, () -> "Cannot serialize Json: " + e.getMessage()); @@ -165,8 +163,8 @@ public class GuestAgentClient extends AgentConnector { } event.suspendHandling(); suspendedStop = event; - logger.fine(() -> "Attempting shutdown through guest agent," - + " waiting for termination until " + waitUntil); + logger.fine(() -> "Sending powerdown command, waiting for" + + " termination until " + waitUntil); powerdownTimer = Components.schedule(t -> { logger.fine(() -> "Powerdown timeout reached."); synchronized (this) { diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/QemuMonitor.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/QemuMonitor.java index feeb76a..6be7603 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/QemuMonitor.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/QemuMonitor.java @@ -54,6 +54,7 @@ import org.jgrapes.util.events.ConfigurationUpdate; * If the log level for this class is set to fine, the messages * exchanged on the monitor socket are logged. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class QemuMonitor extends QemuConnector { private int powerdownTimeout; @@ -71,6 +72,8 @@ public class QemuMonitor extends QemuConnector { * @param configDir the config dir * @throws IOException Signals that an I/O exception has occurred. */ + @SuppressWarnings({ "PMD.AssignmentToNonFinalStatic", + "PMD.ConstructorCallsOverridableMethod" }) public QemuMonitor(Channel componentChannel, Path configDir) throws IOException { super(componentChannel); @@ -105,30 +108,24 @@ public class QemuMonitor extends QemuConnector { @Override protected void processInput(String line) throws IOException { - logger.finer(() -> "monitor(in): " + line); + logger.fine(() -> "monitor(in): " + line); try { var response = mapper.readValue(line, ObjectNode.class); if (response.has("QMP")) { monitorReady = true; - logger.fine(() -> "QMP connection ready"); rep().fire(new MonitorReady()); return; } if (response.has("return") || response.has("error")) { QmpCommand executed = executing.poll(); - logger.finer( + logger.fine( () -> String.format("(Previous \"monitor(in)\" is result " + "from executing %s)", executed)); - var monRes = MonitorResult.from(executed, response); - logger.fine(() -> "QMP triggers: " + monRes); - rep().fire(monRes); + rep().fire(MonitorResult.from(executed, response)); return; } if (response.has("event")) { - MonitorEvent.from(response).ifPresent(me -> { - logger.fine(() -> "QMP triggers: " + me); - rep().fire(me); - }); + MonitorEvent.from(response).ifPresent(rep()::fire); } } catch (JsonProcessingException e) { throw new IOException(e); @@ -144,7 +141,7 @@ public class QemuMonitor extends QemuConnector { public void onClosed(Closed event, SocketIOChannel channel) { channel.associated(this, getClass()).ifPresent(qm -> { super.onClosed(event, channel); - logger.fine(() -> "QMP connection closed."); + logger.finer(() -> "QMP socket closed."); monitorReady = false; }); } @@ -161,7 +158,7 @@ public class QemuMonitor extends QemuConnector { public void onMonitorCommand(MonitorCommand event) throws IOException { // Check prerequisites if (!monitorReady && !(event.command() instanceof QmpCapabilities)) { - logger.severe(() -> "Premature QMP command (not ready): " + logger.severe(() -> "Premature monitor command (not ready): " + event.command()); rep().fire(new Stop()); return; @@ -169,11 +166,10 @@ public class QemuMonitor extends QemuConnector { // Send the command var command = event.command(); - logger.fine(() -> "QMP handles: " + event.toString()); + logger.fine(() -> "monitor(out): " + command.toString()); String asText; try { asText = command.asText(); - logger.finer(() -> "monitor(out): " + asText); } catch (JsonProcessingException e) { logger.log(Level.SEVERE, e, () -> "Cannot serialize Json: " + e.getMessage()); @@ -196,8 +192,8 @@ public class QemuMonitor extends QemuConnector { @SuppressWarnings("PMD.AvoidSynchronizedStatement") public void onStop(Stop event) { if (!monitorReady) { - logger.fine(() -> "Not sending QMP powerdown command" - + " because QMP connection is closed"); + logger.fine(() -> "No QMP connection," + + " cannot send powerdown command"); return; } diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/RamController.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/RamController.java index 81a10f9..9cdc2b5 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/RamController.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/RamController.java @@ -39,6 +39,7 @@ public class RamController extends Component { * * @param componentChannel the component channel */ + @SuppressWarnings("PMD.AssignmentToNonFinalStatic") public RamController(Channel componentChannel) { super(componentChannel); } diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java index 4819dcd..5c0da21 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Runner.java @@ -201,7 +201,8 @@ import org.jgrapes.util.events.WatchFile; * */ @SuppressWarnings({ "PMD.ExcessiveImports", "PMD.AvoidPrintStackTrace", - "PMD.TooManyMethods", "PMD.CouplingBetweenObjects" }) + "PMD.DataflowAnomalyAnalysis", "PMD.TooManyMethods", + "PMD.CouplingBetweenObjects", "PMD.TooManyFields" }) public class Runner extends Component { private static final String TEMPLATE_DIR @@ -217,6 +218,7 @@ public class Runner extends Component { .builder().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) .build()); private final JsonNode defaults; + @SuppressWarnings("PMD.UseConcurrentHashMap") private final File configFile; private final Path configDir; private Configuration initialConfig; @@ -248,7 +250,8 @@ public class Runner extends Component { * @param cmdLine the cmd line * @throws IOException Signals that an I/O exception has occurred. */ - @SuppressWarnings({ "PMD.ConstructorCallsOverridableMethod" }) + @SuppressWarnings({ "PMD.SystemPrintln", + "PMD.ConstructorCallsOverridableMethod" }) public Runner(CommandLine cmdLine) throws IOException { yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -384,6 +387,8 @@ public class Runner extends Component { } } + @SuppressWarnings({ "PMD.CognitiveComplexity", + "PMD.DataflowAnomalyAnalysis" }) private void setFirmwarePaths(Configuration config) throws IOException { JsonNode firmware = defaults.path("firmware").path(config.vm.firmware); // Get file for firmware ROM @@ -615,6 +620,8 @@ public class Runner extends Component { * @throws InterruptedException the interrupted exception */ @Handler + @SuppressWarnings({ "PMD.SwitchStmtsShouldHaveDefault", + "PMD.TooFewBranchesForASwitchStatement" }) public void onProcessStarted(ProcessStarted event, ProcessChannel channel) throws InterruptedException { event.startEvent().associated(CommandDefinition.class) @@ -771,6 +778,7 @@ public class Runner extends Component { "The VM has been shut down")); } + @SuppressWarnings("PMD.ConfusingArgumentToVarargsMethod") private void shutdown() { if (!Set.of(RunState.TERMINATING, RunState.STOPPED).contains(state)) { fire(new Stop()); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StatusUpdater.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StatusUpdater.java index 127c070..f6c7c48 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StatusUpdater.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/StatusUpdater.java @@ -66,11 +66,12 @@ import org.jgrapes.core.events.Start; /** * Updates the CR status. */ -@SuppressWarnings({ "PMD.CouplingBetweenObjects" }) +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", + "PMD.CouplingBetweenObjects" }) public class StatusUpdater extends VmDefUpdater { @SuppressWarnings("PMD.FieldNamingConventions") - private static final Gson gson = new JSON().getGson(); + private static final Gson gson = JSON.getGson(); @SuppressWarnings("PMD.FieldNamingConventions") private static final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()); @@ -89,6 +90,7 @@ public class StatusUpdater extends VmDefUpdater { * * @param componentChannel the component channel */ + @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") public StatusUpdater(Channel componentChannel) { super(componentChannel); attach(new ConsoleTracker(componentChannel)); @@ -151,6 +153,7 @@ public class StatusUpdater extends VmDefUpdater { * @throws ApiException */ @Handler + @SuppressWarnings("PMD.AvoidDuplicateLiterals") public void onConfigureQemu(ConfigureQemu event) throws ApiException { guestShutdownStops = event.configuration().guestShutdownStops; @@ -184,7 +187,8 @@ public class StatusUpdater extends VmDefUpdater { * @throws ApiException */ @Handler - @SuppressWarnings({ "PMD.AssignmentInOperand" }) + @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition", + "PMD.AssignmentInOperand", "PMD.AvoidDuplicateLiterals" }) public void onRunnerStateChanged(RunnerStateChange event) throws ApiException { VmDefinition vmDef; @@ -421,6 +425,7 @@ public class StatusUpdater extends VmDefUpdater { * @throws ApiException */ @Handler + @SuppressWarnings("PMD.AssignmentInOperand") public void onVmopAgentLoggedIn(VmopAgentLoggedIn event) throws ApiException { vmStub.updateStatus(from -> { @@ -437,6 +442,7 @@ public class StatusUpdater extends VmDefUpdater { * @throws ApiException */ @Handler + @SuppressWarnings("PMD.AssignmentInOperand") public void onVmopAgentLoggedOut(VmopAgentLoggedOut event) throws ApiException { vmStub.updateStatus(from -> { diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmDefUpdater.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmDefUpdater.java index 406a0bc..a24b766 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmDefUpdater.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmDefUpdater.java @@ -19,6 +19,7 @@ package org.jdrupes.vmoperator.runner.qemu; import com.google.gson.JsonObject; +import io.kubernetes.client.openapi.JSON; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -43,6 +44,7 @@ import org.jgrapes.util.events.InitialConfiguration; /** * Updates the CR status. */ +@SuppressWarnings("PMD.DataflowAnomalyAnalysis") public class VmDefUpdater extends Component { protected String namespace; @@ -160,8 +162,7 @@ public class VmDefUpdater extends Component { : cond) .collect(Collectors.toCollection(() -> new ArrayList<>())); newConds.addAll(toReplace); - status.add("conditions", - apiClient.getJSON().getGson().toJsonTree(newConds)); + status.add("conditions", JSON.getGson().toJsonTree(newConds)); return status; } } diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmopAgentClient.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmopAgentClient.java index a940d73..f50d397 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmopAgentClient.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/VmopAgentClient.java @@ -59,14 +59,10 @@ public class VmopAgentClient extends AgentConnector { */ @Handler public void onVmopAgentLogIn(VmopAgentLogIn event) throws IOException { + logger.fine(() -> "vmop agent(out): login " + event.user()); if (writer().isPresent()) { - logger.fine(() -> "Vmop agent handles:" + event); executing.add(event); - logger.finer(() -> "vmop agent(out): login " + event.user()); sendCommand("login " + event.user()); - } else { - logger - .warning(() -> "No vmop agent connection for sending " + event); } } @@ -78,38 +74,34 @@ public class VmopAgentClient extends AgentConnector { */ @Handler public void onVmopAgentLogout(VmopAgentLogOut event) throws IOException { + logger.fine(() -> "vmop agent(out): logout"); if (writer().isPresent()) { - logger.fine(() -> "Vmop agent handles:" + event); executing.add(event); - logger.finer(() -> "vmop agent(out): logout"); sendCommand("logout"); } } @Override - @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition" }) + @SuppressWarnings({ "PMD.UnnecessaryReturn", + "PMD.AvoidLiteralsInIfCondition" }) protected void processInput(String line) throws IOException { - logger.finer(() -> "vmop agent(in): " + line); + logger.fine(() -> "vmop agent(in): " + line); // Check validity if (line.isEmpty() || !Character.isDigit(line.charAt(0))) { - logger.warning(() -> "Illegal vmop agent response: " + line); + logger.warning(() -> "Illegal response: " + line); return; } // Check positive responses if (line.startsWith("220 ")) { - var evt = new VmopAgentConnected(); - logger.fine(() -> "Vmop agent triggers " + evt); - rep().fire(evt); + rep().fire(new VmopAgentConnected()); return; } if (line.startsWith("201 ")) { Event cmd = executing.pop(); if (cmd instanceof VmopAgentLogIn login) { - var evt = new VmopAgentLoggedIn(login); - logger.fine(() -> "Vmop agent triggers " + evt); - rep().fire(evt); + rep().fire(new VmopAgentLoggedIn(login)); } else { logger.severe(() -> "Response " + line + " does not match executing command " + cmd); @@ -119,9 +111,7 @@ public class VmopAgentClient extends AgentConnector { if (line.startsWith("202 ")) { Event cmd = executing.pop(); if (cmd instanceof VmopAgentLogOut logout) { - var evt = new VmopAgentLoggedOut(logout); - logger.fine(() -> "Vmop agent triggers " + evt); - rep().fire(evt); + rep().fire(new VmopAgentLoggedOut(logout)); } else { logger.severe(() -> "Response " + line + "does not match executing command " + cmd); @@ -135,7 +125,7 @@ public class VmopAgentClient extends AgentConnector { } // Error - logger.warning(() -> "Error response from vmop agent: " + line); + logger.warning(() -> "Error response: " + line); executing.pop(); } diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCapabilities.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCapabilities.java index 918b7d5..ffd6ca6 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCapabilities.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCapabilities.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class QmpCapabilities extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"qmp_capabilities\" }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpChangeMedium.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpChangeMedium.java index b60b619..158a318 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpChangeMedium.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpChangeMedium.java @@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; */ public class QmpChangeMedium extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"blockdev-change-medium\",\"arguments\": {" + "\"id\": \"\",\"filename\": \"\",\"format\": \"raw\"," diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCommand.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCommand.java index 0db58e2..f91d702 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCommand.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCommand.java @@ -30,7 +30,8 @@ import java.util.logging.Logger; */ public abstract class QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) protected static final ObjectMapper mapper = new ObjectMapper(); /** diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCont.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCont.java index 0e06e34..7b1abbd 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCont.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpCont.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class QmpCont extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"cont\" }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpDelCpu.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpDelCpu.java index a97e6c6..46fba32 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpDelCpu.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpDelCpu.java @@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; */ public class QmpDelCpu extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"device_del\", " + "\"arguments\": " + "{ \"id\": 0 } }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpOpenTray.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpOpenTray.java index 88a392c..2f9ad55 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpOpenTray.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpOpenTray.java @@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; */ public class QmpOpenTray extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"blockdev-open-tray\",\"arguments\": {" + "\"id\": \"\" } }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpPowerdown.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpPowerdown.java index dfb7d96..108a355 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpPowerdown.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpPowerdown.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class QmpPowerdown extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"system_powerdown\" }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpQueryHotpluggableCpus.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpQueryHotpluggableCpus.java index d4fb5cc..6f87d10 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpQueryHotpluggableCpus.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpQueryHotpluggableCpus.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class QmpQueryHotpluggableCpus extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson( "{\"execute\":\"query-hotpluggable-cpus\",\"arguments\":{}}"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpRemoveMedium.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpRemoveMedium.java index 71360cf..cc74555 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpRemoveMedium.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpRemoveMedium.java @@ -27,7 +27,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; */ public class QmpRemoveMedium extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"blockdev-remove-medium\",\"arguments\": {" + "\"id\": \"\" } }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpReset.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpReset.java index 5364811..0bcffc4 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpReset.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpReset.java @@ -25,7 +25,8 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class QmpReset extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"system_reset\" }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpSetBalloon.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpSetBalloon.java index f9d4c5d..c7f6bed 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpSetBalloon.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/commands/QmpSetBalloon.java @@ -28,7 +28,8 @@ import java.math.BigInteger; */ public class QmpSetBalloon extends QmpCommand { - @SuppressWarnings({ "PMD.FieldNamingConventions" }) + @SuppressWarnings({ "PMD.FieldNamingConventions", + "PMD.VariableNamingConventions" }) private static final JsonNode jsonTemplate = parseJson("{ \"execute\": \"balloon\", " + "\"arguments\": " + "{ \"value\": 0 } }"); diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/MonitorEvent.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/MonitorEvent.java index 93e7785..e35a172 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/MonitorEvent.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/MonitorEvent.java @@ -20,8 +20,6 @@ package org.jdrupes.vmoperator.runner.qemu.events; import com.fasterxml.jackson.databind.JsonNode; import java.util.Optional; -import org.jgrapes.core.Channel; -import org.jgrapes.core.Components; import org.jgrapes.core.Event; /** @@ -49,6 +47,7 @@ public class MonitorEvent extends Event { * @param response the response * @return the optional */ + @SuppressWarnings("PMD.TooFewBranchesForASwitchStatement") public static Optional from(JsonNode response) { try { var kind = Kind.valueOf(response.get("event").asText()); @@ -113,20 +112,4 @@ public class MonitorEvent extends Event { public JsonNode data() { return data; } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append(Components.objectName(this)).append(" [").append(data); - if (channels() != null) { - builder.append(", channels=").append(Channel.toString(channels())); - } - builder.append(']'); - return builder.toString(); - } } diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/OsinfoEvent.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/OsinfoEvent.java index 0e90019..294ac7b 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/OsinfoEvent.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/OsinfoEvent.java @@ -19,8 +19,6 @@ package org.jdrupes.vmoperator.runner.qemu.events; import com.fasterxml.jackson.databind.JsonNode; -import org.jgrapes.core.Channel; -import org.jgrapes.core.Components; import org.jgrapes.core.Event; /** @@ -42,21 +40,4 @@ public class OsinfoEvent extends Event { public JsonNode osinfo() { return osinfo; } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append(Components.objectName(this)).append(" [") - .append(osinfo); - if (channels() != null) { - builder.append(", channels=").append(Channel.toString(channels())); - } - builder.append(']'); - return builder.toString(); - } } diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/RunnerStateChange.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/RunnerStateChange.java index 261eebf..829cc88 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/RunnerStateChange.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/events/RunnerStateChange.java @@ -26,6 +26,7 @@ import org.jgrapes.core.Event; /** * The Class RunnerStateChange. */ +@SuppressWarnings("PMD.DataClass") public class RunnerStateChange extends Event { /** diff --git a/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/DataPath.java b/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/DataPath.java index e83cf27..445d383 100644 --- a/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/DataPath.java +++ b/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/DataPath.java @@ -32,6 +32,7 @@ import java.util.logging.Logger; */ public final class DataPath { + @SuppressWarnings("PMD.FieldNamingConventions") private static final Logger logger = Logger.getLogger(DataPath.class.getName()); @@ -55,6 +56,7 @@ public final class DataPath { * @param selectors the selectors * @return the result */ + @SuppressWarnings("PMD.UseLocaleWithCaseConversions") public static Optional get(Object from, Object... selectors) { Object cur = from; for (var selector : selectors) { @@ -130,6 +132,7 @@ public final class DataPath { @SuppressWarnings({ "PMD.CognitiveComplexity", "unchecked" }) public static T deepCopy(T object) { if (object instanceof Map map) { + @SuppressWarnings("PMD.UseConcurrentHashMap") Map copy; try { copy = (Map) object.getClass().getConstructor() diff --git a/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/GsonPtr.java b/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/GsonPtr.java index c6fb101..f78374c 100644 --- a/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/GsonPtr.java +++ b/org.jdrupes.vmoperator.util/src/org/jdrupes/vmoperator/util/GsonPtr.java @@ -32,7 +32,8 @@ import java.util.function.Supplier; /** * Utility class for pointing to elements on a Gson (Json) tree. */ -@SuppressWarnings({ "PMD.ClassWithOnlyPrivateConstructorsShouldBeFinal" }) +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", + "PMD.ClassWithOnlyPrivateConstructorsShouldBeFinal", "PMD.GodClass" }) public class GsonPtr { private final JsonElement position; @@ -101,7 +102,7 @@ public class GsonPtr { * @param selectors the selectors * @return the Gson pointer */ - @SuppressWarnings({ "PMD.PreserveStackTrace" }) + @SuppressWarnings({ "PMD.ShortMethodName", "PMD.PreserveStackTrace" }) public Optional get(Object... selectors) { JsonElement element = position; for (Object sel : selectors) { @@ -145,6 +146,7 @@ public class GsonPtr { * @param cls the cls * @return the result */ + @SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop" }) public T getAs(Class cls) { if (cls.isAssignableFrom(position.getClass())) { return cls.cast(position); diff --git a/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java b/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java index f30b771..b48aa7e 100644 --- a/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java +++ b/org.jdrupes.vmoperator.vmaccess/src/org/jdrupes/vmoperator/vmaccess/VmAccess.java @@ -111,8 +111,9 @@ import org.jgrapes.webconsole.base.freemarker.FreeMarkerConlet; * users and roles. * */ -@SuppressWarnings({ "PMD.ExcessiveImports", "PMD.CouplingBetweenObjects", - "PMD.GodClass", "PMD.TooManyMethods", "PMD.CyclomaticComplexity" }) +@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports", + "PMD.CouplingBetweenObjects", "PMD.GodClass", "PMD.TooManyMethods", + "PMD.CyclomaticComplexity" }) public class VmAccess extends FreeMarkerConlet { private static final String VM_NAME_PROPERTY = "vmName"; @@ -166,7 +167,7 @@ public class VmAccess extends FreeMarkerConlet { * * @param event the event */ - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" }) @Handler public void onConfigurationUpdate(ConfigurationUpdate event) { event.structured(componentPath()) @@ -266,7 +267,7 @@ public class VmAccess extends FreeMarkerConlet { public void onConsoleConfigured(ConsoleConfigured event, ConsoleConnection connection) throws InterruptedException, IOException { - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({ "unchecked", "PMD.PrematureDeclaration" }) final var rendered = (Set) connection.session().get(RENDERED); connection.session().remove(RENDERED); @@ -276,7 +277,8 @@ public class VmAccess extends FreeMarkerConlet { addMissingConlets(event, connection, rendered); } - @SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops" }) + @SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops", + "PMD.AvoidDuplicateLiterals" }) private void addMissingConlets(ConsoleConfigured event, ConsoleConnection connection, final Set rendered) throws InterruptedException { @@ -404,6 +406,7 @@ public class VmAccess extends FreeMarkerConlet { } @Override + @SuppressWarnings({ "PMD.AvoidInstantiatingObjectsInLoops" }) protected Set doRenderConlet(RenderConletRequestBase event, ConsoleConnection channel, String conletId, ResourceModel model) throws Exception { @@ -652,8 +655,9 @@ public class VmAccess extends FreeMarkerConlet { * @throws InterruptedException */ @Handler(namedChannels = "manager") - @SuppressWarnings({ "PMD.CognitiveComplexity", - "PMD.AvoidInstantiatingObjectsInLoops" }) + @SuppressWarnings({ "PMD.ConfusingTernary", "PMD.CognitiveComplexity", + "PMD.AvoidInstantiatingObjectsInLoops", "PMD.AvoidDuplicateLiterals", + "PMD.ConfusingArgumentToVarargsMethod" }) public void onVmResourceChanged(VmResourceChanged event, VmChannel channel) throws IOException, InterruptedException { var vmDef = event.vmDefinition(); @@ -849,7 +853,8 @@ public class VmAccess extends FreeMarkerConlet { model.getConletId(), "openConsole", cf))); } - @SuppressWarnings({ "PMD.UseLocaleWithCaseConversions" }) + @SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition", + "PMD.UseLocaleWithCaseConversions" }) private void selectResource(NotifyConletModel event, ConsoleConnection channel, ResourceModel model) throws JsonProcessingException, InterruptedException { @@ -876,6 +881,7 @@ public class VmAccess extends FreeMarkerConlet { /** * The Class AccessModel. */ + @SuppressWarnings("PMD.DataClass") public static class ResourceModel extends ConletBaseModel { /** diff --git a/org.jdrupes.vmoperator.vmmgmt/resources/org/jdrupes/vmoperator/vmmgmt/VmMgmt-view.ftl.html b/org.jdrupes.vmoperator.vmmgmt/resources/org/jdrupes/vmoperator/vmmgmt/VmMgmt-view.ftl.html index 3197440..5a28cb8 100644 --- a/org.jdrupes.vmoperator.vmmgmt/resources/org/jdrupes/vmoperator/vmmgmt/VmMgmt-view.ftl.html +++ b/org.jdrupes.vmoperator.vmmgmt/resources/org/jdrupes/vmoperator/vmmgmt/VmMgmt-view.ftl.html @@ -30,7 +30,7 @@ -