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.java20
1 files changed, 20 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 62e5dd0d..571b9c44 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ContainerUtils.java
@@ -3,6 +3,7 @@ package org.openslx.dozmod.util;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
import org.kamranzafar.jtar.TarEntry;
import org.kamranzafar.jtar.TarHeader;
import org.kamranzafar.jtar.TarInputStream;
@@ -11,11 +12,16 @@ 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.model.ContainerDefinition;
import org.openslx.dozmod.thrift.cache.LectureCache;
import org.openslx.thrifthelper.TConst;
+import org.openslx.thrifthelper.ThriftManager;
+import org.openslx.util.ThriftUtil;
+
import java.awt.*;
import java.io.*;
+import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
@@ -50,6 +56,20 @@ public class ContainerUtils {
MessageType.WARNING, logger, null);
}
+ public static ContainerDefinition getContainerDefinition(String satelliteToken, String latestVersionId) {
+ byte[] rawVirtConfig = null;
+ try {
+ ByteBuffer byteBuffer = ThriftManager.getSatClient()
+ .getImageVersionVirtConfig(satelliteToken, latestVersionId);
+ rawVirtConfig = ThriftUtil.unwrapByteBuffer(byteBuffer);
+ } catch (TException e) {
+ LOGGER.error("Failed to retrieve virtualizer config for image version " + "'"
+ + latestVersionId + ", see trace: ", e);
+ return null;
+ }
+ return ContainerDefinition.fromByteArray(rawVirtConfig);
+ }
+
/**
* Check if a provided tar file contains information about a single docker image.
* To check the validity of the file, the existence of two JSON files is checked