diff options
author | Victor Mocanu | 2018-04-16 16:12:42 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-04-16 16:12:42 +0200 |
commit | ebd9d933431fdf2cd8cc2da2720a0be8362c0849 (patch) | |
tree | fac61f345ba6117e580d22eed889ace224068636 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard | |
parent | [server] Calculate DNBD3-CRC32 list of incoming transfers and dump to disk (diff) | |
download | tutor-module-ebd9d933431fdf2cd8cc2da2720a0be8362c0849.tar.gz tutor-module-ebd9d933431fdf2cd8cc2da2720a0be8362c0849.tar.xz tutor-module-ebd9d933431fdf2cd8cc2da2720a0be8362c0849.zip |
[*] Add virtualbox support
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard')
3 files changed, 84 insertions, 21 deletions
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 abd554a4..358fdd0d 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 @@ -20,6 +20,9 @@ public abstract class ImageMetaDataPageLayout extends WizardPage { 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; @@ -47,7 +50,19 @@ public abstract class ImageMetaDataPageLayout extends WizardPage { grid.add(osCaption); grid.add(cboOperatingSystem); - QLabel descriptionCation = new QLabel("Beschreibung"); + sCommandCaption = new QLabel("Startbefehl"); + 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(); + + QLabel descriptionCaption = new QLabel("Beschreibung"); txtDescription = new JTextArea(5, 50); txtDescription.setMinimumSize(Gui.getScaledDimension(0, 70)); txtDescription.setLineWrap(true); @@ -55,7 +70,7 @@ public abstract class ImageMetaDataPageLayout extends WizardPage { JScrollPane descPane = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); descPane.setMinimumSize(txtDescription.getMinimumSize()); - grid.add(descriptionCation); + grid.add(descriptionCaption); grid.add(descPane).fill(true, false).expand(true, false); grid.nextRow(); @@ -75,5 +90,4 @@ public abstract class ImageMetaDataPageLayout extends WizardPage { public String getImageDescription() { return txtDescription.getText(); } - } 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 da572a02..1ec57fce 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 @@ -18,6 +18,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.util.vm.QemuMetaData; /** * Page for setting the details of an image. @@ -79,6 +80,8 @@ 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(); @@ -114,6 +117,12 @@ public class ImageMetaDataPage extends ImageMetaDataPageLayout { setPageComplete(false); return; } + + if (state.meta instanceof QemuMetaData) { + sCommandCaption.setVisible(true); + startCommandPane.setVisible(true); + } + // evaluate description field state.description = txtDescription.getText(); if (state.description == null || state.description.isEmpty()) { 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 f5a10b44..ec501234 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 @@ -29,6 +29,9 @@ import org.openslx.dozmod.thrift.WrappedException; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.util.vm.DiskImage; import org.openslx.util.vm.DiskImage.UnknownImageFormatException; +import org.openslx.util.vm.QemuMetaData; +import org.openslx.util.vm.VboxMetaData; +import org.openslx.util.vm.VmMetaData; import org.openslx.util.vm.VmMetaData.HardDisk; import org.openslx.util.vm.VmwareMetaData; @@ -44,6 +47,15 @@ public class ImageUploadPage extends ImageUploadPageLayout { private String lastDetectedName = null; private ImageDetailsRead existingImage = null; + private final FileNameExtensionFilter allSupportedFilter = new FileNameExtensionFilter("All Supported", + "vmx", "vbox", "qcow", "qcow2"); + private final FileNameExtensionFilter vmxFilter = new FileNameExtensionFilter("VMware Virtual Machine", + "vmx"); + private final FileNameExtensionFilter vboxFilter = new FileNameExtensionFilter( + "VirtualBox Virtual Machine", "vbox"); + private final FileNameExtensionFilter qemuFilter = new FileNameExtensionFilter("Qemu Virtual Machine", + "qcow2", "qcow"); + public ImageUploadPage(Wizard wizard, UploadWizardState uploadWizardState, final ImageDetailsRead existingImage) { super(wizard); @@ -55,7 +67,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { lblImageName.setVisible(existingImage == null); txtImageName.setVisible(existingImage == null); txtInfoText.setVisible(existingImage == null); - // show the licenced software checkbox since we are uploading new version + // show the licensed software checkbox since we are uploading new version chkLicenseRestricted.setVisible(existingImage != null); chkLicenseRestricted.setSelected(existingImage != null); // TODO selected by default? @@ -80,44 +92,71 @@ public class ImageUploadPage extends ImageUploadPageLayout { private void browseForVm() { QFileChooser fc = new QFileChooser(Config.getUploadPath(), false); - FileNameExtensionFilter filter = new FileNameExtensionFilter("VMware Virtual Machine", "vmx"); - fc.setFileFilter(filter); + fc.setAcceptAllFileFilterUsed(false); + fc.addChoosableFileFilter(vmxFilter); + fc.addChoosableFileFilter(vboxFilter); + fc.addChoosableFileFilter(qemuFilter); + fc.addChoosableFileFilter(allSupportedFilter); + // differentiate between existing and new VMs + if (existingImage != null) { + if (existingImage.virtId.equals("vmware")) { + fc.setFileFilter(vmxFilter); + } else if (existingImage.virtId.equals("vbox")) { + fc.setFileFilter(vboxFilter); + } + } else { + fc.setFileFilter(allSupportedFilter); + } int action = fc.showOpenDialog(getDialog()); File file = fc.getSelectedFile(); + if (action != JFileChooser.APPROVE_OPTION || file == null) return; - vmxSelected(file.getAbsoluteFile()); + vmSelected(file.getAbsoluteFile()); } - private void vmxSelected(File file) { + private void vmSelected(File file) { Config.setUploadPath(file.getParent()); txtImageFile.setText(""); txtImageName.setText(""); try { - state.meta = new VmwareMetaData(MetaDataCache.getOperatingSystems(), file); + // gets the metadata object of the selected VM depending on its type + state.meta = VmMetaData.getInstance(MetaDataCache.getOperatingSystems(), file); } catch (IOException e) { Gui.showMessageBox(this, "Konnte " + file.getPath() + " nicht lesen", MessageType.ERROR, LOGGER, e); setPageComplete(false); return; } + + String fileformat = "Konfigurations"; + if (state.meta instanceof VmwareMetaData) { + fileformat = "vmx"; + } else if (state.meta instanceof VboxMetaData) { + fileformat = "vbox"; + } else if (state.meta instanceof QemuMetaData) { + fileformat = "qcow"; + } + + // TODO too much header? if (state.meta == null || state.meta.getDisplayName() == null) { - setErrorMessage("Ungültige vmx-Datei ausgewählt!"); + setErrorMessage("Ungültige " + fileformat + "-Datei ausgewählt!"); setPageComplete(false); return; } List<HardDisk> hdds = state.meta.getHdds(); if (hdds.size() == 0 || hdds.get(0).diskImage == null) { - setErrorMessage("Die gewählte vmx-Datei enthält keine virtuelle Festplatte!"); + setErrorMessage("Die gewählte " + fileformat + "-Datei enthält keine virtuelle Festplatte!"); setPageComplete(false); return; } if (hdds.size() > 1) { - setErrorMessage("Die gewählte vmx-Datei enthält mehr als eine virtuelle Festplatte!"); + setErrorMessage("Die gewählte " + fileformat + + "-Datei enthält mehr als eine virtuelle Festplatte!"); setPageComplete(false); return; - // Allow to continue!? + // Allow to continue!? } // now check the disk files @@ -125,8 +164,8 @@ public class ImageUploadPage extends ImageUploadPageLayout { File vmDiskFileInfo = new File(hdds.get(0).diskImage); if (!vmDiskFileInfo.isAbsolute()) { // it's relative, compose path using the vmx location - File vmxBaseDirectory = file.getParentFile(); - vmDiskFileInfo = new File(vmxBaseDirectory, hdds.get(0).diskImage); + File vmBaseDirectory = file.getParentFile(); + vmDiskFileInfo = new File(vmBaseDirectory, hdds.get(0).diskImage); } DiskImage diskImage; try { @@ -141,6 +180,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { return; } catch (UnknownImageFormatException e) { setErrorMessage("'" + vmDiskFileInfo.getName() + "' hat unbekanntes Dateiformat!"); + LOGGER.debug("Selected disk file has unknown format.", e); setPageComplete(false); return; } @@ -156,10 +196,10 @@ public class ImageUploadPage extends ImageUploadPageLayout { return; } if (!diskImage.isStandalone) { - Gui.showMessageBox( - "Die zu dieser VM gehörige VMDK (Virtuelle Festplatte) ist im Format '" + diskImage.subFormat + "'.\n" - + "Dieses Format wird von bwLehrpool nicht unterstützt. Bitte konvertieren Sie die VM\n" - + "in das Format 'monolithicSparse'.", MessageType.WARNING, null, null); + Gui.showMessageBox("Die zu dieser VM gehörige Virtuelle Festplatte ist im Format '" + + diskImage.subFormat + "'.\n" + + "Dieses Format wird von bwLehrpool nicht unterstützt. Bitte konvertieren Sie die VM\n" + + "in das Format 'monolithicSparse'.", MessageType.WARNING, null, null); setErrorMessage("Die VMDK Datei der VM hat ein inkompatibles Format"); setPageComplete(false); return; @@ -234,7 +274,6 @@ public class ImageUploadPage extends ImageUploadPageLayout { state.uuid = ThriftActions.createImage(JOptionPane.getFrameForComponent(this), state.name); if (state.uuid == null) return false; - txtImageName.setEnabled(false); btnBrowseForImage.setEnabled(false); txtImageFile.setEnabled(false); @@ -242,7 +281,8 @@ public class ImageUploadPage extends ImageUploadPageLayout { } else { state.uuid = existingImage.getImageBaseId(); } - // Create upload initiator that will manage requesting a token, hashing the file, connecting for upload... + // Create upload initiator that will manage requesting a token, hashing the + // file, connecting for upload... if (state.upload == null) { try { state.upload = new UploadInitiator(state.uuid, state.diskFile, |