diff options
Diffstat (limited to 'dozentenmodul/src')
23 files changed, 225 insertions, 233 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java index a062c1d6..7e13be8d 100755 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java @@ -24,6 +24,8 @@ import javax.swing.UIManager; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.apache.log4j.spi.LoggingEvent; @@ -56,7 +58,7 @@ public class App { private static String masterServerHost = null; - private static void setupLogger() { + private static String setupFileLogger() { // path to the log file final String logFilePath = Config.getPath() + File.separator + Branding.getConfigDirectory() + ".log"; @@ -79,13 +81,12 @@ public class App { // add file appender to global logger FileAppender fa = null; try { - fa = new FileAppender(new PatternLayout("%d [%F:%M] %m%n"), logFilePath); + fa = new FileAppender(new PatternLayout("[%t] %-5p %F - %m%n"), logFilePath); fa.setEncoding("UTF-8"); - // All classes should log to file, configure global file appender. + fa.setThreshold(Level.DEBUG); } catch (IOException e) { LOGGER.error("Failed to set logfile path to '" + logFilePath + "': ", e); - BasicConfigurator.configure(); - return; + return null; } final FileAppender ffa = fa; @@ -123,7 +124,14 @@ public class App { } }; + // register file logger (appender) BasicConfigurator.configure(ap); + + return logFilePath; + } + + public static void logHeader(String logFilePath) + { LOGGER.info("Starting logging to: " + logFilePath); LOGGER.info(Branding.getApplicationName() + " Version: " + ClientVersion.getLocalRevision()); LOGGER.info(" " + FormatHelper.longDate(ClientVersion.getLocalRevTimestamp())); @@ -135,8 +143,14 @@ public class App { LOGGER.info("java.vm.version: " + System.getProperty("java.vm.version")); LOGGER.info("java.runtime.version: " + System.getProperty("java.runtime.version")); } - - public static void main(final String[] args) throws InvocationTargetException, InterruptedException { + + public static void main(final String[] args) throws InvocationTargetException, InterruptedException + { + // setup basic logging appender to log output on console if no external appender (log4j.properties) is configured + if (LogManager.getRootLogger().getAllAppenders() == null) { + BasicConfigurator.configure(); + } + if (args.length >= 2) { if (args[0].equals("--json")) { writeJsonUpdateFile(args[1]); @@ -161,7 +175,8 @@ public class App { return; } - setupLogger(); + final String logFilePath = setupFileLogger(); + logHeader(logFilePath); // Setting the locale if (!setPreferredLanguage()) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/changemonitor/DialogChangeMonitor.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/changemonitor/DialogChangeMonitor.java index 4651bdad..6e2df962 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/changemonitor/DialogChangeMonitor.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/changemonitor/DialogChangeMonitor.java @@ -154,7 +154,7 @@ public class DialogChangeMonitor { * @param cw The ControlWrapper where the changed state changed. */ void contentChanged(AbstractControlWrapper<?> cw) { - LOGGER.info(cw.getClass().getSimpleName() + " is changed: " + cw.isCurrentlyChanged); + LOGGER.debug(cw.getClass().getSimpleName() + " is changed: " + cw.isCurrentlyChanged); final boolean oldEver = this.wasEverModified; final boolean oldCurrent = this.isCurrentlyModified; this.wasEverModified = false; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java index bad9cea0..a847082f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java @@ -141,12 +141,12 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout @Override public void validityChanged(String errorMessage) { lblError.setText(errorMessage); btnSaveChanges.setEnabled(changeMonitor.isValid() && changeMonitor.wasEverModified()); - LOGGER.info("Valid: " + changeMonitor.isValid()); + LOGGER.debug("Valid: " + changeMonitor.isValid()); } @Override public void modificationChanged() { btnSaveChanges.setEnabled(changeMonitor.isValid() && changeMonitor.wasEverModified()); - LOGGER.info("Changed: " + changeMonitor.isCurrentlyModified()); + LOGGER.debug("Changed: " + changeMonitor.isCurrentlyModified()); } }); // Hook when user presses X (top right) diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtConfigEditorWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtConfigEditorWindow.java index 3a29e3b3..60ea343a 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtConfigEditorWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtConfigEditorWindow.java @@ -24,9 +24,9 @@ import org.openslx.dozmod.thrift.ImageDetailsActions; import org.openslx.dozmod.thrift.ImageDetailsActions.VirtConfCallback; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.util.XmlHelper; -import org.openslx.vm.VboxMetaData; -import org.openslx.vm.VmMetaData; -import org.openslx.vm.VmwareConfig; +import org.openslx.virtualization.configuration.VirtualizationConfigurationVirtualBox; +import org.openslx.virtualization.configuration.VirtualizationConfigurationVmwareFileFormat; +import org.openslx.virtualization.configuration.VirtualizationConfiguration; public class VirtConfigEditorWindow extends VirtConfigEditorWindowLayout implements UiFeedback { @@ -88,26 +88,26 @@ public class VirtConfigEditorWindow extends VirtConfigEditorWindowLayout impleme // we make use of the fact that we saved the BB here! final String userInput = pnlEditor.getText(); byte[] uiBytes = userInput.getBytes(StandardCharsets.ISO_8859_1); - Charset cs = VmwareConfig.getCharset(uiBytes, uiBytes.length); + Charset cs = VirtualizationConfigurationVmwareFileFormat.getCharset(uiBytes, uiBytes.length); // cs is now either the detected encoding, or latin1 as a default uiBytes = userInput.getBytes(cs); // now we should have the correct bytes... - VmMetaData<?, ?, ?, ?, ?> metaCandidate = null; + VirtualizationConfiguration<?, ?, ?, ?> virtualizationConfig = null; try { - metaCandidate = VmMetaData.getInstance(MetaDataCache.getOperatingSystems(), uiBytes, + virtualizationConfig = VirtualizationConfiguration.getInstance(MetaDataCache.getOperatingSystems(), uiBytes, uiBytes.length); } catch (IOException e) { LOGGER.error("Could not get VmMetaData instance from given machine description: ", e); } - if (metaCandidate == null) { + if (virtualizationConfig == null) { dispose(); return; } - byte[] uiBytesFiltered = metaCandidate.getDefinitionArray(); + byte[] uiBytesFiltered = virtualizationConfig.getConfigurationAsByteArray(); final String userInputFiltered; // TODO: This is ugly, why is there instanceof stuff here, add a method to VmMetaData!? - if (metaCandidate instanceof VboxMetaData) { + if (virtualizationConfig instanceof VirtualizationConfigurationVirtualBox) { userInputFiltered = XmlHelper.getFormattedXml(new ByteArrayInputStream(uiBytesFiltered)); } else { userInputFiltered = new String(uiBytesFiltered, cs); @@ -131,13 +131,13 @@ public class VirtConfigEditorWindow extends VirtConfigEditorWindowLayout impleme return; } ByteBuffer toSave; - if (metaCandidate instanceof VboxMetaData) { + if (virtualizationConfig instanceof VirtualizationConfigurationVirtualBox) { String unformattedInput = XmlHelper.getUnformattedXml(new ByteArrayInputStream(uiBytesFiltered)); toSave = ByteBuffer.wrap(unformattedInput.getBytes(cs)); } else { toSave = ByteBuffer.wrap(uiBytesFiltered); } - // we have a valid vmx or the user accepted to push the filtered input + // we have a valid virtualization configuration or the user accepted to push the filtered input actionHandler.setVirtualizerConfig(imageVersionId, toSave, new VirtConfCallback() { @Override public void virtConfCallback(boolean success) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtDropDownConfigEditorWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtDropDownConfigEditorWindow.java index b44cc764..680b9b7c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtDropDownConfigEditorWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/VirtDropDownConfigEditorWindow.java @@ -20,13 +20,13 @@ import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.sat.thrift.version.Feature; import org.openslx.util.ThriftUtil; import org.openslx.util.XmlHelper; -import org.openslx.vm.VboxMetaData; -import org.openslx.vm.VmMetaData; -import org.openslx.vm.VmMetaData.DDAcceleration; -import org.openslx.vm.VmMetaData.EthernetDevType; -import org.openslx.vm.VmMetaData.HWVersion; -import org.openslx.vm.VmMetaData.SoundCardType; -import org.openslx.vm.VmMetaData.UsbSpeed; +import org.openslx.virtualization.configuration.VirtualizationConfigurationVirtualBox; +import org.openslx.virtualization.Version; +import org.openslx.virtualization.configuration.VirtualizationConfiguration; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.DDAcceleration; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.EthernetDevType; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.SoundCardType; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.UsbSpeed; public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWindowLayout implements UiFeedback { @@ -45,7 +45,7 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind private final String imageVersionId; private final String originalMachineDescription; private final VirtDropDownConfigEditorWindow me = this; - private final VmMetaData<?, ?, ?, ?, ?> meta; + private VirtualizationConfiguration<?, ?, ?, ?> virtualizationConfig = null; private final ImageDetailsActions actionHandler; protected VirtDropDownConfigEditorWindow(Window modalParent, final ImageDetailsActions actionHandler, @@ -56,38 +56,35 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind this.imageVersionId = imageVersionId; // and now for the meta data - VmMetaData<?, ?, ?, ?, ?> metaCandidate = null; byte[] machineData = ThriftUtil.unwrapByteBuffer(machineDescription); try { - metaCandidate = VmMetaData.getInstance(MetaDataCache.getOperatingSystems(), machineData, - machineData.length); + virtualizationConfig = VirtualizationConfiguration.getInstance(MetaDataCache.getOperatingSystems(), + machineData, machineData.length); } catch (IOException e) { LOGGER.error("Could not get VmMetaData instance from given machine description: ", e); } - - meta = metaCandidate; - if (metaCandidate == null) { + if (virtualizationConfig == null) { this.originalMachineDescription = null; dispose(); return; } - initializeSoundBox(meta.getSupportedSoundCards()); - initializeDDABox(meta.getSupportedDDAccs()); - initializeHWVersBox(meta.getSupportedHWVersions()); - initializeEDTBox(meta.getSupportedEthernetDevices()); - initializeUsbBox(meta.getSupportedUsbSpeeds()); + initializeSoundBox(virtualizationConfig.getSupportedSoundCards()); + initializeDDABox(virtualizationConfig.getSupportedDDAccs()); + initializeHWVersBox(virtualizationConfig.getVirtualizer().getSupportedVersions()); + initializeEDTBox(virtualizationConfig.getSupportedEthernetDevices()); + initializeUsbBox(virtualizationConfig.getSupportedUsbSpeeds()); //set the initial state of the buttons - initializeComboBoxes(meta); + initializeComboBoxes(virtualizationConfig); // listener for the sound card drop box cboSound.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SoundCardType selected = (SoundCardType) cboSound.getSelectedItem(); - meta.setSoundCard(selected); + virtualizationConfig.setSoundCard(selected); btnSave.setEnabled(hasChanged()); } }); @@ -97,7 +94,7 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind @Override public void actionPerformed(ActionEvent e) { DDAcceleration selected = (DDAcceleration) cbo3DAcceleration.getSelectedItem(); - meta.setDDAcceleration(selected); + virtualizationConfig.setDDAcceleration(selected); btnSave.setEnabled(hasChanged()); } }); @@ -106,8 +103,8 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind cboHWVersion.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - HWVersion selected = (HWVersion) cboHWVersion.getSelectedItem(); - meta.setHWVersion(selected); + Version selected = (Version) cboHWVersion.getSelectedItem(); + virtualizationConfig.setVirtualizerVersion(selected); btnSave.setEnabled(hasChanged()); } }); @@ -117,7 +114,7 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind @Override public void actionPerformed(ActionEvent e) { EthernetDevType selected = (EthernetDevType) cboE0VirtDev.getSelectedItem(); - meta.setEthernetDevType(0, selected); + virtualizationConfig.setEthernetDevType(0, selected); btnSave.setEnabled(hasChanged()); } }); @@ -127,7 +124,7 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind @Override public void actionPerformed(ActionEvent e) { UsbSpeed selected = (UsbSpeed) cboMaxUsbSpeed.getSelectedItem(); - meta.setMaxUsbSpeed(selected); + virtualizationConfig.setMaxUsbSpeed(selected); btnSave.setEnabled(hasChanged()); } }); @@ -156,12 +153,12 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind // here we need special logic for formatting vbox file in a human-readable way... // we will just format it before sending it to the editor window and reformat it right after... String currentMachineDesc; - if (meta instanceof VboxMetaData) + if (virtualizationConfig instanceof VirtualizationConfigurationVirtualBox) currentMachineDesc = XmlHelper - .getFormattedXml(new ByteArrayInputStream(meta.getDefinitionArray())); + .getFormattedXml(new ByteArrayInputStream(virtualizationConfig.getConfigurationAsByteArray())); else currentMachineDesc = ThriftUtil - .byteBufferToString(ByteBuffer.wrap(meta.getDefinitionArray())); + .byteBufferToString(ByteBuffer.wrap(virtualizationConfig.getConfigurationAsByteArray())); boolean didSave = VirtConfigEditorWindow.open(me, actionHandler, imageVersionId, currentMachineDesc, originalMachineDescription); // user did save the changes via the expert mode window - close this one too @@ -175,17 +172,23 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind btnSave.setEnabled(false); } - /* setting the boxes to their initial value...value is read from the given metaData - * @param: given VmwareMetaData + /* + * setting the boxes to their initial value...value is read from the given virtualization configuration */ - private void initializeComboBoxes(VmMetaData<?, ?, ?, ?, ?> m) { + private void initializeComboBoxes(VirtualizationConfiguration<?, ?, ?, ?> m) { try { SoundCardType SCT = m.getSoundCard(); cboSound.setSelectedItem(SCT); DDAcceleration DDA = m.getDDAcceleration(); cbo3DAcceleration.setSelectedItem(DDA); - HWVersion HWV = m.getHWVersion(); - cboHWVersion.setSelectedItem(HWV); + + // initialize version value in combobox + Version HWV = m.getVirtualizerVersion(); + if (HWV != null) { + // set version value specified in the virtualization configuration as default if specified + cboHWVersion.setSelectedItem(HWV); + } + EthernetDevType E0VD = m.getEthernetDevType(0); cboE0VirtDev.setSelectedItem(E0VD); UsbSpeed usbSpeed = m.getMaxUsbSpeed(); @@ -199,7 +202,7 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind private void saveClicked() { // we have a valid vmx or the user accepted to push the filtered input - actionHandler.setVirtualizerConfig(imageVersionId, ByteBuffer.wrap(meta.getDefinitionArray()), + actionHandler.setVirtualizerConfig(imageVersionId, ByteBuffer.wrap(virtualizationConfig.getConfigurationAsByteArray()), new VirtConfCallback() { @Override public void virtConfCallback(boolean success) { @@ -219,7 +222,7 @@ public class VirtDropDownConfigEditorWindow extends VirtDropDownConfigEditorWind private boolean hasChanged() { return !originalMachineDescription - .equals(ThriftUtil.byteBufferToString(ByteBuffer.wrap(meta.getDefinitionArray()))); + .equals(ThriftUtil.byteBufferToString(ByteBuffer.wrap(virtualizationConfig.getConfigurationAsByteArray()))); } private void safeClose() { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtDropDownConfigEditorWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtDropDownConfigEditorWindowLayout.java index a566f158..24e41e78 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtDropDownConfigEditorWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtDropDownConfigEditorWindowLayout.java @@ -25,11 +25,11 @@ import org.openslx.dozmod.gui.helper.GridManager; import org.openslx.dozmod.gui.helper.I18n; import org.openslx.dozmod.thrift.Session; import org.openslx.sat.thrift.version.Feature; -import org.openslx.vm.VmMetaData.DDAcceleration; -import org.openslx.vm.VmMetaData.EthernetDevType; -import org.openslx.vm.VmMetaData.HWVersion; -import org.openslx.vm.VmMetaData.SoundCardType; -import org.openslx.vm.VmMetaData.UsbSpeed; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.DDAcceleration; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.EthernetDevType; +import org.openslx.virtualization.Version; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.SoundCardType; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.UsbSpeed; public class VirtDropDownConfigEditorWindowLayout extends JDialog { @@ -45,7 +45,7 @@ public class VirtDropDownConfigEditorWindowLayout extends JDialog { protected final JButton btnMore; protected final JComboBox<SoundCardType> cboSound; protected final JComboBox<DDAcceleration> cbo3DAcceleration; - protected final JComboBox<HWVersion> cboHWVersion; + protected final JComboBox<Version> cboHWVersion; protected final JComboBox<EthernetDevType> cboE0VirtDev; protected final JComboBox<UsbSpeed> cboMaxUsbSpeed; @@ -86,12 +86,12 @@ public class VirtDropDownConfigEditorWindowLayout extends JDialog { }, DDAcceleration.class); // HardwareVersioBox - cboHWVersion = new ComboBox<HWVersion>(new ComboBoxRenderer<HWVersion>() { + cboHWVersion = new ComboBox<Version>(new ComboBoxRenderer<Version>() { @Override - public String renderItem(HWVersion item) { - return item.displayName; + public String renderItem(org.openslx.virtualization.Version item) { + return item.getName(); } - }, HWVersion.class); + }, Version.class); // HardwareVersioBox cboE0VirtDev = new ComboBox<EthernetDevType>(new ComboBoxRenderer<EthernetDevType>() { @@ -177,9 +177,18 @@ public class VirtDropDownConfigEditorWindowLayout extends JDialog { } // Hardware version - public void initializeHWVersBox(List<HWVersion> list) { - for (HWVersion i : list) { - cboHWVersion.addItem(i); + public void initializeHWVersBox(List<Version> list) { + if (list == null || list.isEmpty()) { + // disable selection of items if list does not contain any items + cboHWVersion.setEnabled(false); + } else { + // append items to combobox if list contains items + for (Version i : list) { + cboHWVersion.addItem(i); + } + + // enable selection of items + cboHWVersion.setEnabled(true); } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java index cb40b0f5..a51b2163 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java @@ -206,7 +206,7 @@ public class ImageCreationWizard extends Wizard LOGGER.error("OS has no id: " + state.selectedOs.toString()); return false; } - if (state.meta == null) { + if (state.virtualizationConfig == null) { LOGGER.error("No vm meta data set in state!"); return false; } @@ -228,7 +228,7 @@ public class ImageCreationWizard extends Wizard private ImageBaseWrite imageBaseWriteFromState() { // build imageBaseWrite return new ImageBaseWrite(state.name, state.description, state.selectedOs.getOsId(), - state.meta.getVirtualizer().getVirtId(), state.isTemplate, state.defaultPermissions, + state.virtualizationConfig.getVirtualizer().getId(), state.isTemplate, state.defaultPermissions, state.shareMode); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java index 48b88627..63089274 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java @@ -23,9 +23,6 @@ public abstract class ImageMetaDataPageLayout extends WizardPage { protected final QLabel lblOperatingSystem; protected final JComboBox<OperatingSystem> cboOperatingSystem; protected final JTextArea txtDescription; - protected final JTextArea startCommand; - protected final QLabel sCommandCaption; - protected final JScrollPane startCommandPane; protected final JCheckBox chkLicenseRestricted; protected final JCheckBox chkIsTemplate; @@ -54,18 +51,6 @@ public abstract class ImageMetaDataPageLayout extends WizardPage { grid.add(cboOperatingSystem); grid.nextRow(); - sCommandCaption = new QLabel(I18n.PAGE_LAYOUT.getString("ImageMetaData.Label.startCommand.text")); - startCommand = new JTextArea(1, 50); - startCommand.setMinimumSize(Gui.getScaledDimension(0, 35)); - startCommand.setLineWrap(true); - startCommand.setWrapStyleWord(true); - startCommandPane = new JScrollPane(startCommand, JScrollPane.VERTICAL_SCROLLBAR_NEVER, - JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - startCommandPane.setMinimumSize(startCommand.getMinimumSize()); - grid.add(sCommandCaption); - grid.add(startCommandPane).fill(true, false).expand(true, false); - grid.nextRow(); - // description QLabel descriptionCaption = new QLabel( I18n.PAGE_LAYOUT.getString("ImageMetaData.Label.description.text")); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java index b16a9785..c2db8554 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java @@ -20,7 +20,7 @@ import org.openslx.dozmod.thrift.ThriftError; import org.openslx.dozmod.thrift.UploadInitiator; import org.openslx.dozmod.thrift.WrappedException; import org.openslx.dozmod.thrift.cache.MetaDataCache; -import org.openslx.vm.DockerMetaDataDummy; +import org.openslx.virtualization.configuration.VirtualizationConfigurationDocker; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -32,6 +32,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.File; import java.io.IOException; +import java.nio.ByteBuffer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -253,7 +254,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { return true; } - private DockerMetaDataDummy createVmMeta() { + private VirtualizationConfigurationDocker createVirtualizationConfig() { ContainerMeta containerMeta = containerDefinition.getContainerMeta(); containerMeta.setBuildContextMethod(getBuildContextMethod().ordinal()); @@ -275,7 +276,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { state.descriptionFile = getDummyFile(); break; } - return containerDefinition.createVmMeta(); + return containerDefinition.createVirtualizationConfig(); } /** @@ -295,7 +296,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { // 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(); - state.meta = createVmMeta(); + state.virtualizationConfig = createVirtualizationConfig(); // -- create image to get uuid -- if (existingImage == null) { @@ -315,7 +316,7 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { if (state.upload == null) { try { state.upload = new UploadInitiator(state.uuid, state.diskFile, - state.meta.getFilteredDefinition()); + ByteBuffer.wrap(state.virtualizationConfig.getConfigurationAsByteArray())); } catch (WrappedException e) { ThriftError.showMessage(this, LOGGER, e.exception, e.displayMessage); return false; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java index b767cbd4..e6fcc783 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java @@ -13,8 +13,7 @@ import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.thrifthelper.Comparators; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; -import org.openslx.vm.DockerMetaDataDummy; -import org.openslx.vm.QemuMetaData; +import org.openslx.virtualization.configuration.VirtualizationConfigurationDocker; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -78,8 +77,7 @@ public class ImageMetaDataPage extends ImageMetaDataPageLayout { } else if (state.selectedOs == null) { cboOperatingSystem.setSelectedItem(null); } - sCommandCaption.setVisible(false); - startCommandPane.setVisible(false); + chkIsTemplate.setSelected(state.isTemplate); chkLicenseRestricted.setSelected(state.isRestricted); reactToUserInput(); @@ -115,12 +113,7 @@ public class ImageMetaDataPage extends ImageMetaDataPageLayout { return; } - if (state.meta instanceof QemuMetaData) { - sCommandCaption.setVisible(true); - startCommandPane.setVisible(true); - } - - if (state.meta instanceof DockerMetaDataDummy) { + if (state.virtualizationConfig instanceof VirtualizationConfigurationDocker) { // TODO we need Information about a OS in Container? Currently use "Other (32 Bit)" as default lblOperatingSystem.setVisible(false); cboOperatingSystem.setVisible(false); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java index 645587c6..9ade4587 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java @@ -8,6 +8,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; import java.io.IOException; +import java.nio.ByteBuffer; import java.util.List; import javax.swing.JFileChooser; @@ -35,9 +36,14 @@ import org.openslx.dozmod.thrift.WrappedException; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.sat.thrift.version.Feature; import org.openslx.thrifthelper.TConst; -import org.openslx.vm.VmMetaData; -import org.openslx.vm.VmwareMetaData; -import org.openslx.vm.VmMetaData.HardDisk; +import org.openslx.virtualization.configuration.VirtualizationConfigurationVmware; +import org.openslx.virtualization.configuration.data.ConfigurationDataDozModClientToDozModServer; +import org.openslx.virtualization.configuration.logic.ConfigurationLogicDozModClientToDozModServer; +import org.openslx.virtualization.configuration.transformation.TransformationException; +import org.openslx.virtualization.configuration.VirtualizationConfiguration; +import org.openslx.virtualization.configuration.VirtualizationConfiguration.HardDisk; +import org.openslx.virtualization.configuration.VirtualizationConfigurationQemu; +import org.openslx.virtualization.configuration.VirtualizationConfigurationVirtualBox; import org.openslx.vm.disk.DiskImage; import org.openslx.vm.disk.DiskImage.ImageFormat; import org.openslx.vm.disk.DiskImageException; @@ -59,12 +65,12 @@ public class ImageUploadPage extends ImageUploadPageLayout { private ImageDetailsRead existingImage = null; private final FileNameExtensionFilter allSupportedFilter; - private final FileNameExtensionFilter vmxFilter = new FileNameExtensionFilter("VMware Virtual Machine", - "vmx"); + private final FileNameExtensionFilter vmxFilter = new FileNameExtensionFilter( + "VMware Virtual Machine", VirtualizationConfigurationVmware.FILE_NAME_EXTENSION); private final FileNameExtensionFilter vboxFilter = new FileNameExtensionFilter( - "VirtualBox Virtual Machine", "vbox"); + "VirtualBox Virtual Machine", VirtualizationConfigurationVirtualBox.FILE_NAME_EXTENSION); private final FileNameExtensionFilter qemuFilter = new FileNameExtensionFilter( - "QEMU Virtual Machine", "xml"); + "QEMU Virtual Machine", VirtualizationConfigurationQemu.FILE_NAME_EXTENSION); private final FileNameExtensionFilter ovfFilter = new FileNameExtensionFilter( "OVF Virtual Machine Format", "ovf"); @@ -104,9 +110,15 @@ public class ImageUploadPage extends ImageUploadPageLayout { // initialize allSupportedFilter depending on whether multiple hypervisors // are supported or not if (Session.hasFeature(Feature.MULTIPLE_HYPERVISORS)) { - allSupportedFilter = new FileNameExtensionFilter("All Supported", "vmx", "ovf", "vbox", "xml", "ova"); + allSupportedFilter = new FileNameExtensionFilter("All Supported", + VirtualizationConfigurationVmware.FILE_NAME_EXTENSION, + VirtualizationConfigurationVirtualBox.FILE_NAME_EXTENSION, + VirtualizationConfigurationQemu.FILE_NAME_EXTENSION, + "ovf", "ova"); } else { - allSupportedFilter = new FileNameExtensionFilter("All Supported", "vmx", "ovf", "ova"); + allSupportedFilter = new FileNameExtensionFilter("All Supported", + VirtualizationConfigurationVmware.FILE_NAME_EXTENSION, + "ovf", "ova"); } btnBrowseForImage.requestFocus(); } @@ -203,9 +215,10 @@ public class ImageUploadPage extends ImageUploadPageLayout { askForConversion(file); return; } + try { // gets the metadata object of the selected VM depending on its type - state.meta = VmMetaData.getInstance(MetaDataCache.getOperatingSystems(), file); + state.virtualizationConfig = VirtualizationConfiguration.getInstance(MetaDataCache.getOperatingSystems(), file); } catch (IOException e) { Gui.showMessageBox(this, I18n.PAGE.getString("ImageUpload.Message.error.couldNotGetMetadata", file.getPath()), @@ -214,22 +227,26 @@ public class ImageUploadPage extends ImageUploadPageLayout { return; } - if (state.meta == null || state.meta.getDisplayName() == null) { + try { + // transforms (filters) the virtualization configuration + final ConfigurationLogicDozModClientToDozModServer uploadLogic = new ConfigurationLogicDozModClientToDozModServer(); + uploadLogic.apply( state.virtualizationConfig, new ConfigurationDataDozModClientToDozModServer() ); + } catch (TransformationException e) { setErrorMessage(I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.invalidConfigFile")); setPageComplete(false); return; } - final String fileformat = state.meta.getVirtualizer().virtName; + final String virtualizerName = state.virtualizationConfig.getVirtualizer().getName(); // bail if multiple hypervisors are not supported - if (!(state.meta instanceof VmwareMetaData) && !Session.hasFeature(Feature.MULTIPLE_HYPERVISORS)) { + if (!(state.virtualizationConfig instanceof VirtualizationConfigurationVmware) && !Session.hasFeature(Feature.MULTIPLE_HYPERVISORS)) { setErrorMessage(I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.hypervisorNotSupported", - fileformat)); + virtualizerName)); setPageComplete(false); return; } // check if the user somehow changed the type of the VM - if (existingImage != null && !existingImage.virtId.equals(state.meta.getVirtualizer().virtId)) { + if (existingImage != null && !existingImage.virtId.equals(state.virtualizationConfig.getVirtualizer().getId())) { Virtualizer existingImageVirtualizer = MetaDataCache.getVirtualizerById(existingImage.virtId); String existingImageVirtualizerName = "<error>"; if (existingImageVirtualizer != null) @@ -240,15 +257,15 @@ public class ImageUploadPage extends ImageUploadPageLayout { return; } - List<HardDisk> hdds = state.meta.getHdds(); + List<HardDisk> hdds = state.virtualizationConfig.getHdds(); if (hdds.size() == 0 || hdds.get(0).diskImage == null) { - setErrorMessage(I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.noHDD", fileformat)); + setErrorMessage(I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.noHDD", virtualizerName)); setPageComplete(false); return; } if (hdds.size() > 1) { setErrorMessage( - I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.moreThanOneHDD", fileformat)); + I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.moreThanOneHDD", virtualizerName)); setPageComplete(false); return; // Allow to continue!? @@ -290,8 +307,9 @@ public class ImageUploadPage extends ImageUploadPageLayout { } // check if disk image format is supported by the hypervisor's supported disk image formats - final List<ImageFormat> supportedImageFormats = state.meta.getSupportedImageFormats(); - if (!diskFormat.isSupportedbyVirtualizer(supportedImageFormats)) { + final List<ImageFormat> supportedImageFormats = state.virtualizationConfig.getVirtualizer() + .getSupportedImageFormats(); + if (!diskFormat.isSupportedbyVirtualizer( supportedImageFormats )) { Gui.showMessageBox(I18n.PAGE.getString("ImageUpload.Message.warning.diskImageNotSupportedByHypervisor", Branding.getServiceName()), MessageType.WARNING, null, null); setErrorMessage(I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.diskImageNotSupportedByHypervisor")); @@ -300,7 +318,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { } // Warn user about snapshot - if (diskImageIsSnapshot || state.meta.isMachineSnapshot()) { + if (diskImageIsSnapshot || state.virtualizationConfig.isMachineSnapshot()) { Gui.showMessageBox(I18n.PAGE.getString("ImageUpload.Message.warning.diskImageSnapshot", Branding.getServiceName()), MessageType.WARNING, null, null); setErrorMessage(I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.diskImageSnapshot")); @@ -324,11 +342,11 @@ public class ImageUploadPage extends ImageUploadPageLayout { // User didn't enter a name yet or didn't change it -> set String imageName = txtImageName.getText(); if (imageName.isEmpty() || imageName.equals(lastDetectedName)) { - txtImageName.setText(state.meta.getDisplayName()); + txtImageName.setText(state.virtualizationConfig.getDisplayName()); } } - lastDetectedName = state.meta.getDisplayName(); - state.detectedOs = state.meta.getOs(); + lastDetectedName = state.virtualizationConfig.getDisplayName(); + state.detectedOs = state.virtualizationConfig.getOs(); txtImageFile.setText(file.getAbsolutePath()); // let the user know the upload is ready setErrorMessage(null); @@ -393,7 +411,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { if (state.upload == null) { try { state.upload = new UploadInitiator(state.uuid, state.diskFile, - state.meta.getFilteredDefinition()); + ByteBuffer.wrap(state.virtualizationConfig.getConfigurationAsByteArray())); } catch (WrappedException e) { ThriftError.showMessage(this, LOGGER, e.exception, e.displayMessage); return false; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java index 80019440..c1a1ea3c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java @@ -9,8 +9,8 @@ import org.kamranzafar.jtar.TarInputStream; import org.kamranzafar.jtar.TarOutputStream; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.util.TarArchiveUtil; -import org.openslx.vm.DockerMetaDataDummy; -import org.openslx.vm.UnsupportedVirtualizerFormatException; +import org.openslx.virtualization.configuration.VirtualizationConfigurationDocker; +import org.openslx.virtualization.configuration.VirtualizationConfigurationException; import java.io.*; import java.nio.ByteBuffer; @@ -77,12 +77,12 @@ public class ContainerDefinition { return containerMeta; } - public DockerMetaDataDummy createVmMeta() { + public VirtualizationConfigurationDocker createVirtualizationConfig() { byte[] rawContainerRecipe = toByteBuffer().array(); try { - return new DockerMetaDataDummy(MetaDataCache.getOperatingSystems(), rawContainerRecipe, + return new VirtualizationConfigurationDocker(MetaDataCache.getOperatingSystems(), rawContainerRecipe, rawContainerRecipe.length); - } catch (UnsupportedVirtualizerFormatException e) { + } catch (VirtualizationConfigurationException e) { e.printStackTrace(); LOGGER.error("Could not create ContainerMetaDataDummy"); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java b/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java index 4e1dbcdf..cbbaf475 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java @@ -10,7 +10,7 @@ import org.openslx.bwlp.thrift.iface.ShareMode; import org.openslx.dozmod.gui.wizard.WizardPage; import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.UploadInitiator; -import org.openslx.vm.VmMetaData; +import org.openslx.virtualization.configuration.VirtualizationConfiguration; public class UploadWizardState { // -- Objects of the GUI itself -- @@ -20,7 +20,7 @@ public class UploadWizardState { public String description = null; // operating system of the virtual machine to be uploaded public OperatingSystem selectedOs = null; - // What we got from the vmx + // What we got from the virtualization configuration public OperatingSystem detectedOs = null; // description file of the virtual machine to be uploaded public File descriptionFile = null; @@ -52,7 +52,7 @@ public class UploadWizardState { /** * Meta data (description file content) of this VM */ - public VmMetaData<?,?,?,?,?> meta = null; + public VirtualizationConfiguration<?,?,?,?> virtualizationConfig = null; // To be able to call the conversion Page from within the ImageUploadPage // TODO find cleaner approach, this probably shouldn't be in here.. 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 f589a939..f6dfc852 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ImageWrapper.java @@ -7,6 +7,7 @@ import org.openslx.dozmod.gui.helper.I18n; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.model.ContainerDefinition; import org.openslx.thrifthelper.TConst; +import org.openslx.virtualization.configuration.VirtualizationConfigurationException; import org.openslx.vm.disk.DiskImage; import org.openslx.vm.disk.DiskImageException; @@ -79,7 +80,7 @@ public class ImageWrapper { } try (DiskImage diskImage = DiskImage.newInstance(destImage)) { VmWrapper.wrapVm(destImage, imageName, virtualizerConfig, virtualizerId, osId, diskImage); - } catch (VmWrapper.MetaDataMissingException | IOException | DiskImageException e) { + } catch (VirtualizationConfigurationException | IOException | DiskImageException e) { Gui.asyncMessageBox(I18n.THRIFT.getString("ThriftActions.Message.warning.couldNotWrapVM"), MessageType.WARNING, LOGGER, e); } 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 d36384bc..0cce4c45 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmWrapper.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmWrapper.java @@ -1,7 +1,6 @@ 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; @@ -17,6 +16,7 @@ import javax.management.ObjectName; import javax.management.ReflectionException; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.OperatingSystem; @@ -24,11 +24,12 @@ import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.thrifthelper.TConst; -import org.openslx.vm.QemuMetaData; -import org.openslx.vm.VboxMetaData; -import org.openslx.vm.VmMetaData; -import org.openslx.vm.VmwareMetaData; -import org.openslx.vm.VmMetaData.UsbSpeed; +import org.openslx.virtualization.configuration.VirtualizationConfigurationVmware; +import org.openslx.virtualization.configuration.logic.ConfigurationLogicDozModServerToDozModClient; +import org.openslx.virtualization.configuration.transformation.TransformationException; +import org.openslx.virtualization.configuration.VirtualizationConfiguration; +import org.openslx.virtualization.configuration.VirtualizationConfigurationException; +import org.openslx.virtualization.configuration.data.ConfigurationDataDozModServerToDozModClient; import org.openslx.vm.disk.DiskImage; import org.openslx.vm.disk.DiskImageException; import org.openslx.vm.disk.DiskImageVmdk; @@ -38,110 +39,76 @@ public class VmWrapper { private static final Logger LOGGER = Logger.getLogger(VmWrapper.class); public static void wrapVm(File diskFile, String imageName, byte[] machineDescription, - String virtualizerId, int osId, DiskImage diskImageInfo) throws MetaDataMissingException, + String virtualizerId, int osId, DiskImage diskImageInfo) throws VirtualizationConfigurationException, IOException { - if (!diskFile.exists()) - throw new FileNotFoundException("Disk file " + diskFile.getAbsolutePath() + " does not exist"); - if (machineDescription == null || machineDescription.length < 10) { - if (!TConst.VIRT_VMWARE.equals(virtualizerId)) { - throw new MetaDataMissingException(); - } - - if (diskImageInfo instanceof DiskImageVmdk) { + // check if virtualization configuration is missing + if (machineDescription == null) { + // configuration is not available + if (TConst.VIRT_VMWARE.equals(virtualizerId) && diskImageInfo instanceof DiskImageVmdk) { + // get fallback VMX if virtualizer is VMware with VMDK disk image final DiskImageVmdk vmdkImageInfo = DiskImageVmdk.class.cast( diskImageInfo ); try { machineDescription = VmWrapper.getFallbackVmx(vmdkImageInfo); } catch (DiskImageException e) { - throw new MetaDataMissingException(); + throw new VirtualizationConfigurationException("Can not get fallback VMX configuration!"); } } else { - throw new MetaDataMissingException(); + // there is no way to reconstruct a configuration for other virtualizer + throw new VirtualizationConfigurationException("Virtualization configuration is missing!"); } } - // Handle machine description to generate configuration file - VmMetaData<?, ?, ?, ?, ?> vmMeta = VmMetaData.getInstance(MetaDataCache.getOperatingSystems(), - machineDescription, machineDescription.length); - // Append disk & NAT - if (!vmMeta.addDefaultNat() || !vmMeta.addHddTemplate(diskFile, null, null)) { - throw new MetaDataMissingException(); + // get guest operating system if possible + OperatingSystem guestOs = null; + if (osId != 0) { + guestOs = MetaDataCache.getOsById(osId); } - // The guestOS should be in the vmx, but the user could have changed it - // by editing - // the image via the GUI. Those changes are not written back to the - // stored vmx - int osMaxMemMb = 0; - if (virtualizerId != null && osId != 0) { - OperatingSystem os = MetaDataCache.getOsById(osId); - if (os != null && os.virtualizerOsId != null) { - String virtOsId = os.virtualizerOsId.get(virtualizerId); - if (virtOsId != null) { - vmMeta.setOs(virtOsId); - } - if (os.maxMemMb > 0) { - osMaxMemMb = os.maxMemMb; - } - } - } - vmMeta.addDisplayName(imageName); - int mem = getMainMemoryMb() / 2 - 512; - if (mem < 1024) { - mem = 1024; - } - if (osMaxMemMb > 0 && mem > osMaxMemMb) { - mem = osMaxMemMb; - } - vmMeta.addCpuCoreCount(1); - vmMeta.addRam((mem / 4) * 4); - vmMeta.addFloppy(0, null, true); - vmMeta.addFloppy(1, null, true); - vmMeta.addCdrom(""); // ISO-Based with no disk in drive - vmMeta.addCdrom(null); // Autodetect real drive - if (vmMeta.getMaxUsbSpeed() != UsbSpeed.USB3_0) { - vmMeta.setMaxUsbSpeed(UsbSpeed.USB2_0); - } - vmMeta.applySettingsForLocalEdit(); + // handle machine description to generate configuration file + final VirtualizationConfiguration<?, ?, ?, ?> virtualizationConfig = VirtualizationConfiguration + .getInstance(MetaDataCache.getOperatingSystems(), machineDescription, machineDescription.length); - // Output vm - String base = diskFile.getAbsolutePath(); - int dot = base.lastIndexOf('.'); - if (dot > 0) { - base = base.substring(0, dot); + // transform virtualization configuration for local editing + byte[] configuration = null; + try { + final ConfigurationLogicDozModServerToDozModClient downloadLogic = new ConfigurationLogicDozModServerToDozModClient(); + downloadLogic.apply( virtualizationConfig, new ConfigurationDataDozModServerToDozModClient( imageName, + diskFile, guestOs, virtualizerId, getMainMemoryMb() ) ); + configuration = virtualizationConfig.getConfigurationAsByteArray(); + } catch ( TransformationException e ) { + throw new VirtualizationConfigurationException( e.getLocalizedMessage() ); } - String fileType = null; - if (vmMeta instanceof VmwareMetaData) { - fileType = ".vmx"; - // Copy BIOS with both floppies enabled + // save BIOS if virtualizer is VMware + if (virtualizationConfig instanceof VirtualizationConfigurationVmware) { try { FileOutputStream output = new FileOutputStream(new File(diskFile.getAbsoluteFile().getParentFile(), "nvram")); InputStream input = ResourceLoader.getStream("/data/nvram"); IOUtils.copy(input, output); + input.close(); + output.close(); } catch (Exception e) { Gui.asyncMessageBox("Konnte das BIOS für die VM nicht kopieren", MessageType.ERROR, LOGGER, e); } - - } else if (vmMeta instanceof VboxMetaData) { - fileType = ".vbox"; - } else if (vmMeta instanceof QemuMetaData) { - fileType = ".xml"; - } - if (fileType == null) { - LOGGER.warn("file type somehow unclear; application could stop working here!"); } - File vmFile = new File(base + fileType); + // save virtualization configuration as file to disk + final String baseFileName = FilenameUtils.removeExtension( diskFile.getAbsolutePath() ); + final String fileNameExtension = virtualizationConfig.getFileNameExtension(); + final File vmFile = new File(baseFileName + "." + fileNameExtension); + + // delete original virtualization configuration file vmFile.delete(); - // actually write vmx to disk - FileUtils.writeByteArrayToFile(vmFile, vmMeta.getFilteredDefinitionArray()); + + // actually write virtualization configuration to disk + FileUtils.writeByteArrayToFile(vmFile, configuration); } private static byte[] getFallbackVmx(DiskImageVmdk diskImageInfo) throws IOException, DiskImageException { - String vmx = ResourceLoader.getTextFile("/txt/vmx_template"); - return vmx.replace("%VM_HW_VERSION%", Integer.toString(diskImageInfo.getHwVersion())).getBytes( - StandardCharsets.UTF_8); + final String vmx = ResourceLoader.getTextFile("/txt/vmx_template"); + final short hwVersion = diskImageInfo.getHwVersion().getMajor(); + return vmx.replace("%VM_HW_VERSION%", Short.toString(hwVersion)).getBytes(StandardCharsets.UTF_8); } /** @@ -165,10 +132,6 @@ public class VmWrapper { return fileName; } - public static class MetaDataMissingException extends Exception { - private static final long serialVersionUID = -7842986428831219758L; - } - private static int getMainMemoryMb() { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); Object attribute; diff --git a/dozentenmodul/src/main/properties/i18n/page_layout.properties b/dozentenmodul/src/main/properties/i18n/page_layout.properties index 34e7d58e..bc282897 100644 --- a/dozentenmodul/src/main/properties/i18n/page_layout.properties +++ b/dozentenmodul/src/main/properties/i18n/page_layout.properties @@ -25,7 +25,6 @@ ImageTypePageLayout.button.newDocker=New Docker Image ImageMetaData.WizardPage.title=Metadata ImageMetaData.WizardPage.description=Please enter a meaningful name for the new VM. ImageMetaData.Label.OS.text=Operating system -ImageMetaData.Label.startCommand.text=Start command ImageMetaData.Label.description.text=Description ImageMetaData.CheckBox.licenseRestricted.text=VM contains software requiring a license ImageMetaData.CheckBox.isTemplate.text=Create template diff --git a/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties b/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties index 10491635..cd5b7f9e 100644 --- a/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties +++ b/dozentenmodul/src/main/properties/i18n/page_layout_de_DE.properties @@ -25,7 +25,6 @@ ImageTypePageLayout.button.newDocker=Neues Docker-Image ImageMetaData.WizardPage.title=Metadaten ImageMetaData.WizardPage.description=Geben Sie bitte einen aussagekräftigen Namen für die neue VM ein. ImageMetaData.Label.OS.text=Betriebssystem -ImageMetaData.Label.startCommand.text=Startbefehl ImageMetaData.Label.description.text=Beschreibung ImageMetaData.CheckBox.licenseRestricted.text=VM enthält lizenzpflichtige Software ImageMetaData.CheckBox.isTemplate.text=Vorlage erstellen diff --git a/dozentenmodul/src/main/properties/i18n/page_layout_tr_TR.properties b/dozentenmodul/src/main/properties/i18n/page_layout_tr_TR.properties index a791c740..ec69138a 100644 --- a/dozentenmodul/src/main/properties/i18n/page_layout_tr_TR.properties +++ b/dozentenmodul/src/main/properties/i18n/page_layout_tr_TR.properties @@ -14,7 +14,6 @@ ImageCustomPermission.CheckBox.permissionAdmin.text=Yönetim ImageMetaData.WizardPage.title=Meta veriler ImageMetaData.WizardPage.description=Lütfen yeni sanal makine için anlamlı bir isim girin. ImageMetaData.Label.OS.text=İşletim sistemi -ImageMetaData.Label.startCommand.text=Başlangıç komutu ImageMetaData.Label.description.text=Açıklama ImageMetaData.CheckBox.licenseRestricted.text=Sanal makine lisans gerektiren yazılım içeriyor ImageMetaData.CheckBox.isTemplate.text=Şablon oluştur diff --git a/dozentenmodul/src/main/properties/i18n/window_layout.properties b/dozentenmodul/src/main/properties/i18n/window_layout.properties index 503a0535..7077d090 100644 --- a/dozentenmodul/src/main/properties/i18n/window_layout.properties +++ b/dozentenmodul/src/main/properties/i18n/window_layout.properties @@ -235,7 +235,7 @@ VirtDropDownConfigEditor.Label.pnlWarning.text=Here you can modify some settings install the necessary drivers, and re-upload the VM. VirtDropDownConfigEditor.Label.sound.text=Sound card VirtDropDownConfigEditor.Label.3DAcceleration.text=3D-Acceleration -VirtDropDownConfigEditor.Label.HWVersion.text=VMWare HW-Version +VirtDropDownConfigEditor.Label.HWVersion.text=Virtualizer HW-Version VirtDropDownConfigEditor.Label.E0VirtDev.text=Network interface card VirtDropDownConfigEditor.Label.maxUSBSpeed.text=USB VirtDropDownConfigEditor.Button.more.text=Expert mode diff --git a/dozentenmodul/src/main/properties/i18n/window_layout_de_DE.properties b/dozentenmodul/src/main/properties/i18n/window_layout_de_DE.properties index b4b4a9b7..72fef21e 100644 --- a/dozentenmodul/src/main/properties/i18n/window_layout_de_DE.properties +++ b/dozentenmodul/src/main/properties/i18n/window_layout_de_DE.properties @@ -235,7 +235,7 @@ VirtDropDownConfigEditor.Label.pnlWarning.text=Hier können Sie einige Einstellu durchführen, die notwendigen Treiber installieren und die VM wieder hochladen. VirtDropDownConfigEditor.Label.sound.text=Soundkarte VirtDropDownConfigEditor.Label.3DAcceleration.text=3D-Beschleunigung -VirtDropDownConfigEditor.Label.HWVersion.text=VMWare HW-Version +VirtDropDownConfigEditor.Label.HWVersion.text=Virtualisierer HW-Version VirtDropDownConfigEditor.Label.E0VirtDev.text=Netzwerkkarte VirtDropDownConfigEditor.Label.maxUSBSpeed.text=USB VirtDropDownConfigEditor.Button.more.text=Expertenmodus diff --git a/dozentenmodul/src/main/properties/i18n/window_layout_tr_TR.properties b/dozentenmodul/src/main/properties/i18n/window_layout_tr_TR.properties index 77709be6..f28e66ed 100644 --- a/dozentenmodul/src/main/properties/i18n/window_layout_tr_TR.properties +++ b/dozentenmodul/src/main/properties/i18n/window_layout_tr_TR.properties @@ -235,7 +235,7 @@ VirtDropDownConfigEditor.Label.pnlWarning.text=Burada, kullanılan sanal donanı ve sanal makineyi tekrar yüklemeniz gerekir. VirtDropDownConfigEditor.Label.sound.text=Ses kartı VirtDropDownConfigEditor.Label.3DAcceleration.text=3D hızlandırıcı -VirtDropDownConfigEditor.Label.HWVersion.text=VMWare donanım sürümü +VirtDropDownConfigEditor.Label.HWVersion.text=Virtualizer donanım sürümü VirtDropDownConfigEditor.Label.E0VirtDev.text=Ethernet kartı VirtDropDownConfigEditor.Label.maxUSBSpeed.text=USB VirtDropDownConfigEditor.Button.more.text=Uzman modu diff --git a/dozentenmodul/src/main/properties/log4j.properties b/dozentenmodul/src/main/properties/log4j.properties index 21c0faed..8fa5e798 100644 --- a/dozentenmodul/src/main/properties/log4j.properties +++ b/dozentenmodul/src/main/properties/log4j.properties @@ -1,6 +1,13 @@ -log4j.rootLogger=DEBUG, A1 +# root level logging configuration +log4j.rootLogger=ALL, console -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=[%t] %-5p %F - %m%n -log4j.logger.org.apache.directory=ERROR +# NOTE: The file logging appender is added and configured by the Java +# implementation, since the logging file path and logic can only +# be realized by the implementation (using system properties). + +# configuration for console output +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=[%t] %-5p %F - %m%n +log4j.appender.console.encoding=UTF-8 +log4j.appender.console.Threshold=INFO diff --git a/dozentenmodul/src/main/resources/img/qemukvm-icon.png b/dozentenmodul/src/main/resources/img/qemukvm-icon.png Binary files differnew file mode 100644 index 00000000..03d3489c --- /dev/null +++ b/dozentenmodul/src/main/resources/img/qemukvm-icon.png |