diff options
author | ralph isenmann | 2021-02-15 11:42:17 +0100 |
---|---|---|
committer | ralph isenmann | 2021-02-15 11:42:17 +0100 |
commit | 793b25c3029250567454aa542b78cfe83745edc3 (patch) | |
tree | 8407d5dc0a14641ab985f19bc40bbbeb5a74672f /dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page | |
parent | [client] Add ContainerPanel in ImageDetails and LectureDetails (diff) | |
download | tutor-module-793b25c3029250567454aa542b78cfe83745edc3.tar.gz tutor-module-793b25c3029250567454aa542b78cfe83745edc3.tar.xz tutor-module-793b25c3029250567454aa542b78cfe83745edc3.zip |
[client] Update ImageCreation for Container Images workflow
Remove Container Runtime specific informations (Run and Mount Options). These Options can be defined in the LectureDetails Window.
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java | 72 | ||||
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java | 21 |
2 files changed, 61 insertions, 32 deletions
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 f784d844..234e0a0e 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 @@ -4,7 +4,9 @@ import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; import org.openslx.dozmod.Config; +import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.helper.I18n; +import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.QFileChooser; import org.openslx.dozmod.gui.helper.TextChangeListener; import org.openslx.dozmod.gui.wizard.Wizard; @@ -13,6 +15,10 @@ import org.openslx.dozmod.model.ContainerBuildContextMethod; import org.openslx.dozmod.model.ContainerDefinition; import org.openslx.dozmod.model.ContainerMeta; import org.openslx.dozmod.state.UploadWizardState; +import org.openslx.dozmod.thrift.ThriftActions; +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.util.vm.DockerMetaDataDummy; @@ -43,10 +49,9 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { private final ImageDetailsRead existingImage; private final ContainerDefinition containerDefinition; - public ContainerUploadPage(Wizard wizard, final UploadWizardState state, - ContainerDefinition containerDefinition) { + public ContainerUploadPage(Wizard wizard, final UploadWizardState state) { super(wizard); - this.containerDefinition = containerDefinition; + this.containerDefinition = new ContainerDefinition(); this.state = state; canComeBack = false; @@ -103,11 +108,6 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { reactOnUserInput(); } }); - txtContainerRun.getDocument().addDocumentListener(new TextChangeListener() { - @Override public void changed() { - reactOnUserInput(); - } - }); tpInput.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -207,10 +207,10 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { return false; } - if (txtContainerRun.getText() == null || txtContainerRun.getText().isEmpty()) { - setWarningMessage(I18n.PAGE.getString("ContainerUploadPage.Warning.NoRunOptions")); - return false; - } +// if (txtContainerRun.getText() == null || txtContainerRun.getText().isEmpty()) { +// setWarningMessage(I18n.PAGE.getString("ContainerUploadPage.Warning.NoRunOptions")); +// return false; +// } return true; } @@ -219,7 +219,6 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { ContainerMeta containerMeta = containerDefinition.getContainerMeta(); containerMeta.setBuildContextMethod(getBuildContextMethod().ordinal()); containerMeta.setImageName(txtImageName.getText()); - containerMeta.setRunOptions(txtContainerRun.getText()); switch (containerDefinition.getBuildContextMethod()) { case FILE: containerDefinition.setContainerRecipe(state.descriptionFile); @@ -233,10 +232,57 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { return containerDefinition.createVmMeta(); } + /** + * This function starts the image creation process. It is triggered by the + * "Next" button. + * + * Depending on the state, it will first try to get a UUID for the new image by + * calling createImage() of the thrift API. If a UUID is received, it will + * request an upload with requestImageVersionUpload(). If granted, it will + * finally start a thread for the UploadTask. + * + * Then a callback to the Gui is executed where we can process the upload state + * and give the user feedback about it. + * + */ @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(); state.meta = 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); + } + } else { + state.uuid = existingImage.getImageBaseId(); + } + // 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, + state.meta.getFilteredDefinition()); + } catch (WrappedException e) { + ThriftError.showMessage(this, LOGGER, e.exception, e.displayMessage); + return false; + } catch (IOException e) { + Gui.showMessageBox(this, + I18n.PAGE.getString("ImageUpload.Message.error.uploadInitiatorFailed"), + MessageType.ERROR, LOGGER, e); + return false; + } + } + // Start the hash check now + state.upload.startHashing(); return true; } 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 f2010da1..a20ef8b6 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 @@ -1,10 +1,5 @@ package org.openslx.dozmod.gui.wizard.page; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Collections; -import java.util.List; - import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.ShareMode; @@ -13,7 +8,6 @@ import org.openslx.dozmod.gui.helper.I18n; import org.openslx.dozmod.gui.helper.TextChangeListener; import org.openslx.dozmod.gui.wizard.Wizard; import org.openslx.dozmod.gui.wizard.layout.ImageMetaDataPageLayout; -import org.openslx.dozmod.model.ContainerDefinition; import org.openslx.dozmod.state.UploadWizardState; import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.cache.MetaDataCache; @@ -36,13 +30,10 @@ import java.util.List; private final static Logger LOGGER = Logger.getLogger(ImageMetaDataPage.class); private UploadWizardState state; - private final ContainerDefinition containerDefinition; - public ImageMetaDataPage(Wizard wizard, UploadWizardState uploadWizardState, - ContainerDefinition containerDefinition) { + public ImageMetaDataPage(Wizard wizard, UploadWizardState uploadWizardState) { super(wizard); this.state = uploadWizardState; - this.containerDefinition = containerDefinition; setPageComplete(false); // HACK set fixed uploadWizardState to test functions uploadWizardState.shareMode = ShareMode.LOCAL; @@ -78,9 +69,7 @@ import java.util.List; }); } - - @Override - protected void onPageEnter() { + @Override protected void onPageEnter() { // Preselect OS if possible if (state.detectedOs != null) { cboOperatingSystem.setSelectedItem(state.detectedOs); @@ -99,10 +88,6 @@ import java.util.List; state.isTemplate = chkIsTemplate.isSelected(); state.isRestricted = chkLicenseRestricted.isSelected(); - if (state.meta instanceof DockerMetaDataDummy) { - containerDefinition.getContainerMeta().setBindMountConfig(bindMountConfigurator.getData()); - state.meta = containerDefinition.createVmMeta(); - } return state.selectedOs != null && state.description != null; } @@ -134,8 +119,6 @@ import java.util.List; } if (state.meta instanceof DockerMetaDataDummy) { - bindMountConfigurator.setVisible(true); - // TODO we need Information about a OS in Container? Currently use "Other (32 Bit)" as default lblOperatingSystem.setVisible(false); cboOperatingSystem.setVisible(false); |