summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorralph isenmann2020-09-18 16:04:33 +0200
committerralph isenmann2020-09-18 16:04:33 +0200
commit170afceda6c722590b80ab95a81b2ed8277cdddc (patch)
tree96e9dca90fba8c07093d15e0557ef3ad6f39c3b2
parent[client] more refactoring (diff)
downloadtutor-module-170afceda6c722590b80ab95a81b2ed8277cdddc.tar.gz
tutor-module-170afceda6c722590b80ab95a81b2ed8277cdddc.tar.xz
tutor-module-170afceda6c722590b80ab95a81b2ed8277cdddc.zip
[client] more refactoring
- remove unused code - create a temporary file in config dir. File serves as a replacement for an image. - use existing baseID
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java54
1 files changed, 25 insertions, 29 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java
index 4ae9e7c4..bc7a22e2 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java
@@ -21,7 +21,8 @@ import java.io.*;
public class DockerfileUploadPage extends ContainerUploadPageLayout {
- private final static Logger LOGGER = Logger.getLogger(DockerfileUploadPage.class);
+ private final Logger LOGGER = Logger.getLogger(DockerfileUploadPage.class);
+ private final String ZERO_FILE = new String("ZERO-FILE");
/**
* Page for uploading an imagefile
@@ -127,13 +128,21 @@ public class DockerfileUploadPage extends ContainerUploadPageLayout {
LOGGER.info("Upload also an created Image");
state.diskFile = imageTarFile;
} else {
+ // create a temp file with dummy content,
+ // because vmchooser relies on an existing image after choosing a lecture.
+ // TODO change behavior in vmchooser to allow start lectures without images.
try {
- // create a temp file with dummy content.
- File tmpFile = File.createTempFile("tmp", "img");
- FileUtils.writeStringToFile(tmpFile, "ZERO\n", "UTF-8");
- state.diskFile = tmpFile;
+ String configDir = Config.getPath();
+ File zeroFile = new File(configDir, ZERO_FILE);
+ if (!zeroFile.exists()) {
+ zeroFile.createNewFile();
+ FileUtils.writeStringToFile(zeroFile, "ZERO\n", "UTF-8");
+ }
+ state.diskFile = zeroFile;
+ LOGGER.info("Use dummy image file");
} catch (IOException e) {
e.printStackTrace();
+ LOGGER.error("Could not create a dummy image file.",e);
}
}
@@ -177,39 +186,26 @@ public class DockerfileUploadPage extends ContainerUploadPageLayout {
setPageComplete(completed);
}
- /**
- * This Method takes the user provided dockerfile and a ContainerMeta object
- * and packages those in temporally .tar.gz-file.
- * This file is then attached to a DockerMetaDataDummy object as VMX.
- * This ensures that dockerfile and ContainerMeta are kept in the server and made available to clients when a lecture
- * starts with attached containers.
- */
- // TODO redundant already implemented in ContainerDefinition
- private void createContainerInfo() {
-
- }
-
@Override protected boolean wantNextOrFinish() {
// are we creating a new image? then either:
// get the image name either auto filled by VmwareMetaData or by user
// get the image name from the image we are uploading a new version of
state.name = existingImage != null ? existingImage.getImageName() : txtImageName.getText();
- createContainerInfo();
state.meta = new ContainerDefinition(state.descriptionFile, containerMeta).createVmMeta();
// -- create image to get uuid --
- // if (existingImage == null) {
- if (state.uuid == null) {
- state.uuid = ThriftActions.createImage(JOptionPane.getFrameForComponent(this), state.name);
- if (state.uuid == null)
- return false;
- txtImageName.setEnabled(false);
- btnBrowseForImage.setEnabled(false);
- txtImageFile.setEnabled(false);
+ if (existingImage == null) {
+ if (state.uuid == null) {
+ state.uuid = ThriftActions.createImage(JOptionPane.getFrameForComponent(this), state.name);
+ if (state.uuid == null)
+ return false;
+ txtImageName.setEnabled(false);
+ btnBrowseForImage.setEnabled(false);
+ txtImageFile.setEnabled(false);
+ }
+ } else {
+ state.uuid = existingImage.getImageBaseId();
}
- // } else {
- // state.uuid = existingImage.getImageBaseId();
- // }
// Create upload initiator that will manage requesting a token, hashing the
// file, connecting for upload...
if (state.upload == null) {