diff options
author | ralph isenmann | 2020-07-17 16:07:56 +0200 |
---|---|---|
committer | ralph isenmann | 2020-09-15 13:45:52 +0200 |
commit | 7bb0147bc19a1da692ea6ff75863165633a3f55f (patch) | |
tree | f511cce78c8bb8d3810db17861bc9007170b8f2b | |
parent | [client] Modify Image Download to handle Dockerfiles (diff) | |
download | tutor-module-7bb0147bc19a1da692ea6ff75863165633a3f55f.tar.gz tutor-module-7bb0147bc19a1da692ea6ff75863165633a3f55f.tar.xz tutor-module-7bb0147bc19a1da692ea6ff75863165633a3f55f.zip |
[client] Allow user to update a docker entry by upload a new dockerfile
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java | 15 | ||||
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/DockerfileUploadPage.java | 65 |
2 files changed, 57 insertions, 23 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java index b7f5370c..8152b019 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java @@ -10,11 +10,13 @@ import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.QuitNotification; import org.openslx.dozmod.gui.helper.UiFeedback; +import org.openslx.dozmod.gui.wizard.page.DockerfileUploadPage; import org.openslx.dozmod.gui.wizard.page.ImageUploadPage; import org.openslx.dozmod.gui.wizard.page.ImageUploadSummaryPage; import org.openslx.dozmod.state.UploadWizardState; import org.openslx.dozmod.thrift.ThriftActions; import org.openslx.dozmod.thrift.UploadInitiator.GotUploadTokenCallback; +import org.openslx.thrifthelper.TConst; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; @@ -29,8 +31,17 @@ public class ImageUpdateWizard extends Wizard implements UiFeedback, QuitNotific public ImageUpdateWizard(final Window parent, final ImageDetailsRead image) { super(parent); - imageUploadPage = new ImageUploadPage(this, state, image); - addPage(imageUploadPage); + // TODO allow user to update the plain dockerfile + switch (image.virtId){ + case TConst.VIRT_DOCKER: + addPage(new DockerfileUploadPage(this,state, image)); + break; + case TConst.VIRT_QEMU: + case TConst.VIRT_VIRTUALBOX: + case TConst.VIRT_VMWARE: + addPage(new ImageUploadPage(this, state, image)); + break; + } } @Override 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 b78ffd6e..01f291e7 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 @@ -1,6 +1,7 @@ package org.openslx.dozmod.gui.wizard.page; 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.*; @@ -27,17 +28,46 @@ public class DockerfileUploadPage extends ImageUploadPageLayout { * @param wizard */ private final UploadWizardState state; - + private final ImageDetailsRead existingImage; public DockerfileUploadPage(Wizard wizard, final UploadWizardState state) { super(wizard); this.canComeBack = false; this.state = state; + existingImage = null; + + state.meta = new DockerMetaDataDummy(MetaDataCache.getOperatingSystems()); + + init(); + } + + public DockerfileUploadPage(Wizard wizard, UploadWizardState state, ImageDetailsRead image) { + super(wizard); + + this.state = state; + this.existingImage = image; + lblImageName.setEnabled(existingImage == null); + txtImageName.setEnabled(existingImage == null); + txtInfoText.setVisible(existingImage == null); + state.name = image.imageName; state.meta = new DockerMetaDataDummy(MetaDataCache.getOperatingSystems()); - //state.meta = new VmMetaDataDummy(MetaDataCache.getOperatingSystems()); + + state.defaultPermissions = image.getDefaultPermissions(); + // state.permissionMap // TODO do i need that ? + state.description = image.getDescription(); + state.detectedOs = MetaDataCache.getOsById(image.getOsId()); + state.selectedOs = MetaDataCache.getOsById(image.getOsId()); + state.tags = image.getTags(); + state.defaultPermissions = image.getUserPermissions(); + + state.uuid = image.getImageBaseId(); + init(); + } + + private void init() { this.txtImageFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -60,8 +90,8 @@ public class DockerfileUploadPage extends ImageUploadPageLayout { state.name = imageName; } }); - btnBrowseForImage.requestFocus(); + btnBrowseForImage.requestFocus(); txtInfoText.setText("Many Text"); } @@ -80,17 +110,19 @@ public class DockerfileUploadPage extends ImageUploadPageLayout { return; txtImageFile.setText(file.getAbsolutePath()); - txtImageName.setText(file.getParentFile().getName()); + + if (existingImage == null) + txtImageName.setText(file.getParentFile().getName()); + else + txtImageName.setText(existingImage.getImageName()); state.descriptionFile = file; state.diskFile = file; // TODO no disk file in docker context (DUMMY SET) - state.name = file.getParentFile().getName(); Config.setUploadPath(file.getParent()); setPageComplete(true); } - private class DockerfileFilter extends FileFilter { @Override public boolean accept(File f) { @@ -106,23 +138,14 @@ public class DockerfileUploadPage extends ImageUploadPageLayout { } } - - @Override - protected boolean wantNextOrFinish() { -// // Check for vmware player lock files - warn user if found, might corrupt upload -// if (askCancelLockFile(state.descriptionFile.getAbsolutePath() + ".lck", -// state.diskFile.getAbsolutePath() + ".lck")) { -// setErrorMessage("Die gewählte VM wird noch verwendet"); -// return false; -// } - + @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.name = existingImage != null ? existingImage.getImageName() : txtImageName.getText(); // -- create image to get uuid -- -// if (existingImage == null) { + // if (existingImage == null) { if (state.uuid == null) { state.uuid = ThriftActions.createImage(JOptionPane.getFrameForComponent(this), state.name); if (state.uuid == null) @@ -131,9 +154,9 @@ public class DockerfileUploadPage extends ImageUploadPageLayout { 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) { |