summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
diff options
context:
space:
mode:
authorralph isenmann2020-08-11 16:16:53 +0200
committerralph isenmann2020-09-15 13:46:54 +0200
commit369f1f5b81d5ae87631a79628c764081c359fcd4 (patch)
treef752c7a8efb4ef349460d2e9784aa232b321aac7 /dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
parent[client] Allow user to update a docker entry by upload a new dockerfile (diff)
downloadtutor-module-369f1f5b81d5ae87631a79628c764081c359fcd4.tar.gz
tutor-module-369f1f5b81d5ae87631a79628c764081c359fcd4.tar.xz
tutor-module-369f1f5b81d5ae87631a79628c764081c359fcd4.zip
[client] handle dockerfile als metadata
dockerfile is now an entry in the datatable and not an image or an disk file ()
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
index 82e45472..c8ca7746 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java
@@ -11,9 +11,9 @@ import org.openslx.thrifthelper.TConst;
import org.openslx.util.vm.DiskImage;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
public class ImageWrapper {
@@ -45,11 +45,18 @@ public class ImageWrapper {
File destImage = new File(destDir.getAbsolutePath(),"dockerfile");
try {
+ // TODO: (RALPH) dockerfile == virtualizerconfig(table imageversion) ... maybe not a goot solution!
+ writeDockerfile(destDir, fTransInf.getMachineDescription());
+
+ // delete image file because thats also the dockerfile
+ Files.delete(tmpDiskFile.toPath());
+
// use move(..) because of platform independence
- Files.move(tmpDiskFile.toPath(),
+ /*Files.move(tmpDiskFile.toPath(),
destImage.toPath(),
StandardCopyOption.REPLACE_EXISTING
- );
+ );*/
+
} catch (IOException e) {
Gui.asyncMessageBox("Konnte dockerfile nicht an Ziel kopieren",
MessageType.WARNING, LOGGER, e);
@@ -98,4 +105,16 @@ public class ImageWrapper {
MessageType.WARNING, LOGGER, e);
}
}
+
+ private static void writeDockerfile(File destDir, byte[] dockerfile_b) {
+ String filename = "dockerfile";
+ File dockerfile = new File(destDir,filename);
+ try {
+ FileOutputStream fos = new FileOutputStream(dockerfile);
+ fos.write(dockerfile_b);
+ fos.close();
+ } catch (IOException e) {
+ LOGGER.error("could not write dockerfile", e);
+ }
+ }
}