Martin Mucha has uploaded a new change for review. Change subject: webadmin: offering files of unknown type as candidates for kernel and initrd images ......................................................................
webadmin: offering files of unknown type as candidates for kernel and initrd images • to keep things simple, when refreshing list of images, ALL type is used to refresh all files (since there's no way how to tell vdsm 'refresh all files but ...'), but only images of type UNKNOWN are presented to the user, since there's not specific type for kernel initrd images and we know, that we do not want to offer them iso's, floppies, or others. To do that, RepoImageToImageFileNameAsyncConverter converter callback was altered to allow filtering. Subclass used for obtaining images of UNKNOWN type then can query all and filter unwanted by that type. • when passing image name back to backend, it must start with prefix 'iso://' otherwise root of iso domain for given data-center won't be added before selected filename. To do that, RepoImageToImageFileNameAsyncConverter converter callback was altered to provide overridable method for converting each record, and subclass of this callback used for obtaining images of UNKNOWN type prepends "iso://" prefix to image name. That way, all images in comboboxes starts with 'iso://', which may seem ackward at first, but it offers clear distinction, that this is the image from iso domain Note: technically run once dialog coud use only one call to get all images, categorize them by type and use where approriate, instead of current three calls, and refreshed could refresh files of specific type(when type's known) or all files (where it's unknown), but that would be harder to implement in given time window, so easier solution was selected. Change-Id: Ic5ce60fb187fbfd6efe1b6e497f21157bd7a9484 Signed-off-by: Martin Mucha <mmu...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java 4 files changed, 183 insertions(+), 79 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/58/41358/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java index aa91469..0d8e767 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java @@ -10,6 +10,7 @@ import org.ovirt.engine.ui.common.idhandler.WithElementId; import org.ovirt.engine.ui.common.widget.Align; import org.ovirt.engine.ui.common.widget.ComboBox; +import org.ovirt.engine.ui.common.widget.VisibilityRenderer; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadChangeableListBoxEditor; import org.ovirt.engine.ui.common.widget.editor.VncKeyMapRenderer; @@ -161,18 +162,18 @@ @WithElementId("runAndPause") EntityModelCheckBoxEditor runAndPauseEditor; - @UiField - @Path(value = "kernel_path.entity") - @WithElementId("kernelPath") - StringEntityModelTextBoxEditor kernelPathEditor; + @UiField(provided = true) + @Path(value = "kernelImage.selectedItem") + @WithElementId("kernelImage") + ListModelTypeAheadChangeableListBoxEditor kernelImageEditor; + + @UiField(provided = true) + @Path(value = "initrdImage.selectedItem") + @WithElementId("initrdImage") + ListModelTypeAheadChangeableListBoxEditor initrdImageEditor; @UiField - @Path(value = "initrd_path.entity") - @WithElementId("initrdPath") - StringEntityModelTextBoxEditor initrdPathEditor; - - @UiField - @Path(value = "kernel_parameters.entity") + @Path(value = "kernelParameters.entity") @WithElementId("kernelParameters") StringEntityModelTextBoxEditor kernelParamsEditor; @@ -283,7 +284,11 @@ @UiField @Ignore - ButtonBase refreshButton; + ButtonBase isoImagesRefreshButton; + + @UiField + @Ignore + ButtonBase linuxBootOptionsRefreshButton; private RunOnceModel runOnceModel; @@ -324,8 +329,8 @@ bootSequenceLabel.setText(constants.runOncePopupBootSequenceLabel()); // Linux Boot Options - kernelPathEditor.setLabel(constants.runOncePopupKernelPathLabel()); - initrdPathEditor.setLabel(constants.runOncePopupInitrdPathLabel()); + kernelImageEditor.setLabel(constants.runOncePopupKernelPathLabel()); + initrdImageEditor.setLabel(constants.runOncePopupInitrdPathLabel()); kernelParamsEditor.setLabel(constants.runOncePopupKernelParamsLabel()); // Cloud Init @@ -368,6 +373,29 @@ void initListBoxEditors() { vncKeyboardLayoutEditor = new ListModelListBoxEditor<>(new VncKeyMapRenderer()); + this.kernelImageEditor = new ListModelTypeAheadChangeableListBoxEditor( + new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() { + + @Override + public String getDisplayStringNullSafe(String data) { + return typeAheadNameTemplateNullSafe(data); + } + }, + false, + new VisibilityRenderer.SimpleVisibilityRenderer(), + constants.empty()); + + this.initrdImageEditor = new ListModelTypeAheadChangeableListBoxEditor( + new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() { + + @Override + public String getDisplayStringNullSafe(String data) { + return typeAheadNameTemplateNullSafe(data); + } + }, + false, + new VisibilityRenderer.SimpleVisibilityRenderer(), + constants.empty()); } void initRadioButtonEditors() { @@ -575,11 +603,16 @@ vmInitWidget.setCloudInitContentVisible(selected && possible); } - @UiHandler("refreshButton") - void handleRefreshButtonClick(ClickEvent event) { + @UiHandler("isoImagesRefreshButton") + void handleIsoImagesRefreshButtonClick(ClickEvent event) { runOnceModel.updateIsoList(true); } + @UiHandler("linuxBootOptionsRefreshButton") + void handleLinuxBootOptionsRefreshButtonRefreshButtonClick(ClickEvent event) { + runOnceModel.updateUnknownTypeImagesList(true); + } + @UiHandler("bootSequenceUpButton") void handleBootSequenceUpButtonClick(ClickEvent event) { if (bootSequenceModel != null) { diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml index 3399beb..5bfc7bc 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.ui.xml @@ -175,7 +175,7 @@ <g:HorizontalPanel> <ge:EntityModelCheckBoxEditor ui:field="attachIsoEditor" addStyleNames="{style.attachImageCheckbox}" /> <e:ListModelListBoxEditor ui:field="isoImageEditor" addStyleNames="{style.attachImageSelectbox}" /> - <g:PushButton ui:field="refreshButton" addStyleNames="{style.refreshButton}"> + <g:PushButton ui:field="isoImagesRefreshButton" addStyleNames="{style.refreshButton}"> <g:upFace image='{resources.refreshButtonImage}' /> </g:PushButton> </g:HorizontalPanel> @@ -203,8 +203,16 @@ <g:DisclosurePanel ui:field="linuxBootOptionsPanel" label="{constants.runOncePopupLinuxBootOptionsLabel}" addStyleNames="{style.panelStyle}"> <g:VerticalPanel addStyleNames="{style.linuxBootOptionsPanel}"> - <ge:StringEntityModelTextBoxEditor ui:field="kernelPathEditor" addStyleNames="{style.linuxBootOption}" /> - <ge:StringEntityModelTextBoxEditor ui:field="initrdPathEditor" addStyleNames="{style.linuxBootOption}" /> + <g:HorizontalPanel> + <e:ListModelTypeAheadChangeableListBoxEditor ui:field="kernelImageEditor" + addStyleNames="{style.linuxBootOption}"/> + <g:PushButton ui:field="linuxBootOptionsRefreshButton" addStyleNames="{style.refreshButton}"> + <g:upFace image='{resources.refreshButtonImage}'/> + </g:PushButton> + </g:HorizontalPanel> + + <e:ListModelTypeAheadChangeableListBoxEditor ui:field="initrdImageEditor" + addStyleNames="{style.linuxBootOption}"/> <ge:StringEntityModelTextBoxEditor ui:field="kernelParamsEditor" addStyleNames="{style.linuxBootOption}" /> </g:VerticalPanel> </g:DisclosurePanel> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index e65f8d3..74cbdcf 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -193,6 +193,8 @@ public class AsyncDataProvider { + //TODO MM: fix duplicity with org.ovirt.engine.core.bll.RunVmCommand.ISO_PREFIX ? + public static final String ISO_PREFIX = "iso://"; //$NON-NLS-1$ private static AsyncDataProvider instance; public static AsyncDataProvider getInstance() { @@ -643,11 +645,43 @@ getIrsImageList(aQuery, storagePoolId, false, ImageFileType.Floppy); } + public void getUnknownImageList(AsyncQuery aQuery, Guid storagePoolId, boolean forceRefresh) { + getIrsImageList(aQuery, + storagePoolId, + forceRefresh, + ImageFileType.All, + new RepoImageToImageFileNameAsyncConverter() { + + + @Override + protected String transform(ArrayList<String> fileNameList, RepoImage repoImage) { + return ISO_PREFIX + super.transform(fileNameList, repoImage); + } + + @Override + protected boolean desiredImage(RepoImage repoImage) { + return ImageFileType.Unknown == repoImage.getFileType(); + } + }); + } + public void getIrsImageList(AsyncQuery aQuery, Guid storagePoolId, boolean forceRefresh, ImageFileType imageFileType) { - aQuery.converterCallback = new RepoImageToImageFileNameAsyncConverter(); + + + getIrsImageList(aQuery, storagePoolId, forceRefresh, imageFileType, + new RepoImageToImageFileNameAsyncConverter()); + } + + private void getIrsImageList(AsyncQuery aQuery, + Guid storagePoolId, + boolean forceRefresh, + ImageFileType imageFileType, + IAsyncConverter converterCallBack) { + + aQuery.converterCallback = converterCallBack; GetImagesListByStoragePoolIdParameters parameters = new GetImagesListByStoragePoolIdParameters(storagePoolId, imageFileType); @@ -4197,7 +4231,9 @@ ArrayList<RepoImage> repoList = (ArrayList<RepoImage>) source; ArrayList<String> fileNameList = new ArrayList<String>(); for (RepoImage repoImage : repoList) { - fileNameList.add(repoImage.getRepoImageId()); + if (desiredImage(repoImage)) { + fileNameList.add(transform(fileNameList, repoImage)); + } } Collections.sort(fileNameList, String.CASE_INSENSITIVE_ORDER); @@ -4205,5 +4241,13 @@ } return new ArrayList<String>(); } + + protected String transform(ArrayList<String> fileNameList, RepoImage repoImage) { + return repoImage.getRepoImageId(); + } + + protected boolean desiredImage(RepoImage repoImage) { + return true; + } } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java index d860eb6..28210a2 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java @@ -116,6 +116,26 @@ privateIsoImage = value; } + private ListModel<String> kernelImage; + + public ListModel<String> getKernelImage() { + return kernelImage; + } + + public void setKernelImage(ListModel<String> kernelImage) { + this.kernelImage = kernelImage; + } + + private ListModel<String> initrdImage; + + public ListModel<String> getInitrdImage() { + return initrdImage; + } + + public void setInitrdImage(ListModel<String> initrdImage) { + this.initrdImage = initrdImage; + } + private ListModel<EntityModel<DisplayType>> privateDisplayProtocol; public ListModel<EntityModel<DisplayType>> getDisplayProtocol() @@ -128,42 +148,18 @@ privateDisplayProtocol = value; } - private EntityModel<String> privateInitrd_path; - - public EntityModel<String> getInitrd_path() - { - return privateInitrd_path; - } - - private void setInitrd_path(EntityModel<String> value) - { - privateInitrd_path = value; - } - - private EntityModel<String> privateKernel_path; - - public EntityModel<String> getKernel_path() - { - return privateKernel_path; - } - - private void setKernel_path(EntityModel<String> value) - { - privateKernel_path = value; - } - // Linux Boot Options tab - private EntityModel<String> privateKernel_parameters; + private EntityModel<String> privateKernelParameters; - public EntityModel<String> getKernel_parameters() + public EntityModel<String> getKernelParameters() { - return privateKernel_parameters; + return privateKernelParameters; } private void setKernel_parameters(EntityModel<String> value) { - privateKernel_parameters = value; + privateKernelParameters = value; } // Initial Boot tab - Sysprep @@ -617,8 +613,8 @@ // Linux Boot Options tab setKernel_parameters(new EntityModel<String>()); - setKernel_path(new EntityModel<String>()); - setInitrd_path(new EntityModel<String>()); + setKernelImage(new ListModel<String>()); + setInitrdImage(new ListModel<String>()); // Initial Boot tab - Sysprep setIsCloudInitEnabled(new EntityModel<Boolean>(false)); @@ -716,9 +712,7 @@ setHwAcceleration(true); // passing Kernel parameters - getKernel_parameters().setEntity(vm.getKernelParams()); - getKernel_path().setEntity(vm.getKernelUrl()); - getInitrd_path().setEntity(vm.getInitrdUrl()); + getKernelParameters().setEntity(vm.getKernelParams()); setIsLinuxOS(AsyncDataProvider.getInstance().isLinuxOsType(vm.getVmOsId())); getIsLinuxOptionsAvailable().setEntity(getIsLinuxOS()); @@ -731,6 +725,7 @@ updateDomainList(); updateSystemTabLists(); updateIsoList(); + updateUnknownTypeImagesList(); updateDisplayProtocols(); updateFloppyImages(); updateInitialRunFields(); @@ -804,17 +799,18 @@ params.setCustomProperties(getCustomPropertySheet().serialize()); // kernel params - if (getKernel_path().getEntity() != null) - { - params.setKernelUrl(getKernel_path().getEntity()); + String selectedKernelImage = getKernelImage().getSelectedItem(); + if (selectedKernelImage != null) { + params.setKernelUrl(selectedKernelImage); } - if (getKernel_parameters().getEntity() != null) - { - params.setKernelParams(getKernel_parameters().getEntity()); + + if (getKernelParameters().getEntity() != null) { + params.setKernelParams(getKernelParameters().getEntity()); } - if (getInitrd_path().getEntity() != null) - { - params.setInitrdUrl(getInitrd_path().getEntity()); + + String selectedInitrdImage = getInitrdImage().getSelectedItem(); + if (selectedInitrdImage != null) { + params.setInitrdUrl(selectedInitrdImage); } // Sysprep params @@ -976,6 +972,29 @@ public void updateIsoList() { updateIsoList(false); + } + + public void updateUnknownTypeImagesList() { + updateUnknownTypeImagesList(false); + } + + public void updateUnknownTypeImagesList(boolean forceRefresh) { + INewAsyncCallback callback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object returnValue) { + List<String> images = (List<String>) returnValue; + + getKernelImage().setItems(images); + getInitrdImage().setItems(images); + + getKernelImage().setSelectedItem(null); + getInitrdImage().setSelectedItem(null); + } + }; + + + AsyncQuery aQuery = new AsyncQuery(this, callback); + AsyncDataProvider.getInstance().getUnknownImageList(aQuery, vm.getStoragePoolId(), forceRefresh); } public void updateIsoList(boolean forceRefresh) { @@ -1236,26 +1255,26 @@ boolean customPropertyValidation = getCustomPropertySheet().validate(); if (getIsLinuxOS()) { - getKernel_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() }); - getInitrd_path().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() }); - getKernel_parameters().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() }); + getKernelImage().validateSelectedItem(new IValidation[] { new NoTrimmingWhitespacesValidation() }); + getInitrdImage().validateSelectedItem(new IValidation[] { new NoTrimmingWhitespacesValidation() }); + getKernelParameters().validateEntity(new IValidation[] { new NoTrimmingWhitespacesValidation() }); // initrd path and kernel params require kernel path to be filled - if (StringHelper.isNullOrEmpty(getKernel_path().getEntity())) { + if (StringHelper.isNullOrEmpty(getKernelImage().getSelectedItem())) { final UIConstants constants = ConstantsManager.getInstance().getConstants(); - if (!StringHelper.isNullOrEmpty(getInitrd_path().getEntity())) { - getInitrd_path().getInvalidityReasons().add(constants.initrdPathInvalid()); - getInitrd_path().setIsValid(false); - getKernel_path().getInvalidityReasons().add(constants.initrdPathInvalid()); - getKernel_path().setIsValid(false); + if (!StringHelper.isNullOrEmpty(getInitrdImage().getSelectedItem())) { + getInitrdImage().getInvalidityReasons().add(constants.initrdPathInvalid()); + getInitrdImage().setIsValid(false); + getKernelImage().getInvalidityReasons().add(constants.initrdPathInvalid()); + getKernelImage().setIsValid(false); } - if (!StringHelper.isNullOrEmpty(getKernel_parameters().getEntity())) { - getKernel_parameters().getInvalidityReasons().add(constants.kernelParamsInvalid()); - getKernel_parameters().setIsValid(false); - getKernel_path().getInvalidityReasons().add(constants.kernelParamsInvalid()); - getKernel_path().setIsValid(false); + if (!StringHelper.isNullOrEmpty(getKernelParameters().getEntity())) { + getKernelParameters().getInvalidityReasons().add(constants.kernelParamsInvalid()); + getKernelParameters().setIsValid(false); + getKernelImage().getInvalidityReasons().add(constants.kernelParamsInvalid()); + getKernelImage().setIsValid(false); } } } @@ -1285,9 +1304,9 @@ return getIsoImage().getIsValid() && getFloppyImage().getIsValid() - && getKernel_path().getIsValid() - && getInitrd_path().getIsValid() - && getKernel_parameters().getIsValid() + && getKernelImage().getIsValid() + && getInitrdImage().getIsValid() + && getKernelParameters().getIsValid() && getDefaultHost().getIsValid() && customPropertyValidation && cloudInitIsValid -- To view, visit https://gerrit.ovirt.org/41358 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic5ce60fb187fbfd6efe1b6e497f21157bd7a9484 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Mucha <mmu...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches