summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
index 0e5a1d15..ca57a265 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
@@ -1,15 +1,24 @@
package org.openslx.dozmod.util;
import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
import org.openslx.bwlp.thrift.iface.LectureSummary;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.helper.MessageType;
+import org.openslx.dozmod.thrift.Session;
+import org.openslx.dozmod.thrift.cache.ImageCache;
import org.openslx.dozmod.thrift.cache.LectureCache;
import org.openslx.thrifthelper.TConst;
+import org.openslx.thrifthelper.ThriftManager;
+import org.openslx.util.ThriftUtil;
+import org.openslx.virtualization.configuration.container.ContainerDefinition;
+import org.openslx.virtualization.configuration.container.ContainerMeta;
import java.awt.*;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -36,8 +45,42 @@ public class ContainerUtils {
return false;
}
+ public static List<ImageSummaryRead> getDataContainerImages() {
+ String satelliteToken = Session.getSatelliteToken();
+ List<ImageSummaryRead> images = ImageCache.get(true);
+ List<ImageSummaryRead> dataContainerImages = new ArrayList<>();
+ for (ImageSummaryRead image: images) {
+ if (image.getVirtId().equals(TConst.VIRT_DOCKER))
+ {
+ try {
+ byte[] rawVirtConfig;
+ ByteBuffer byteBuffer = ThriftManager.getSatClient()
+ .getImageVersionVirtConfig(satelliteToken, image.getLatestVersionId());
+ rawVirtConfig = ThriftUtil.unwrapByteBuffer(byteBuffer);
+ ContainerDefinition containerDefinition = ContainerDefinition.fromByteArray(rawVirtConfig);
+ if (containerDefinition.getContainerMeta().getImageType() == ContainerMeta.ContainerImageType.DATA)
+ dataContainerImages.add(image);
+
+ } catch (TException e) {
+// LOGGER.error("Failed to retrieve virtualizer config for image version " + "'"
+// + image.getLatestVersionId() + ", see trace: ", e);
+ }
+ }
+ }
+ return dataContainerImages;
+ }
+
public static void showWarning(Component c, Logger logger) {
Gui.showMessageBox(c, I18n.WINDOW.getString("LectureDetails.Message.error.containerLinkedWithLecture"),
MessageType.WARNING, logger, null);
}
+
+ public static String getImageNameByBaseId(String imageBaseId) {
+ List<ImageSummaryRead> images = ImageCache.get(true);
+ for (ImageSummaryRead image: images) {
+ if (image.imageBaseId.equals(imageBaseId))
+ return image.getImageName();
+ }
+ return imageBaseId;
+ }
}