summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
authorSimon Rettberg2015-10-27 16:09:31 +0100
committerSimon Rettberg2015-10-27 16:09:31 +0100
commitd90332548cfa6f68bb195344cd1993a7b5a89605 (patch)
treed2ea351c474f2288b0cb7fbaf2729bed9792a344 /dozentenmodul/src/main/java
parent[client] ResourceLoader: Fix leak, add getStream() (diff)
downloadtutor-module-d90332548cfa6f68bb195344cd1993a7b5a89605.tar.gz
tutor-module-d90332548cfa6f68bb195344cd1993a7b5a89605.tar.xz
tutor-module-d90332548cfa6f68bb195344cd1993a7b5a89605.zip
[client] Add two floppy drives to vmx of downloaded VM
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/VmWrapper.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmWrapper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmWrapper.java
index 37bbbc3d..30fbf166 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmWrapper.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmWrapper.java
@@ -2,7 +2,9 @@ package org.openslx.dozmod.util;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.lang.management.ManagementFactory;
import java.nio.charset.StandardCharsets;
@@ -15,8 +17,11 @@ import javax.management.ObjectName;
import javax.management.ReflectionException;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.thrift.cache.MetaDataCache;
import org.openslx.util.vm.DiskImage;
import org.openslx.util.vm.VmwareMetaData;
@@ -66,8 +71,22 @@ public class VmWrapper {
mem = osMaxMemMb;
}
vmwareConfig.addRam(mem);
+ vmwareConfig.addFloppy(0, null, true);
+ vmwareConfig.addFloppy(1, null, true);
+ // Copy BIOS with both floppies enabled
+ try (FileOutputStream output = new FileOutputStream(new File(diskFile.getAbsoluteFile()
+ .getParentFile(), "nvram")); InputStream input = ResourceLoader.getStream("/data/nvram")) {
+ IOUtils.copy(input, output);
+ } catch (Exception e) {
+ Gui.asyncMessageBox("Konnte das BIOS für die VM nicht kopieren", MessageType.ERROR, LOGGER, e);
+ }
// Output vmx
- File vmxFile = new File(diskFile.getAbsolutePath() + ".vmx");
+ String base = diskFile.getAbsolutePath();
+ int dot = base.lastIndexOf('.');
+ if (dot > 0) {
+ base = base.substring(0, dot);
+ }
+ File vmxFile = new File(base + ".vmx");
vmxFile.delete();
FileUtils.writeByteArrayToFile(vmxFile, vmwareConfig.getFilteredDefinitionArray());
}