Frank Kobzik has uploaded a new change for review. Change subject: frontend: Allow using any domain for sysprep ......................................................................
frontend: Allow using any domain for sysprep This patch allows user to alter domain name for sysprep when running the machine using "run once". The problem was caused by wrong condition when filling from model to RunVmOnceParams. Fixed by adjusting the condition. There was also another issue with the ComboBox, which wasn't working correctly when there is a custom text put in and user wants to apply a value from the drop-down menu. In this case the value is not updated. Hot-fixed by manual handling of DOM events. Change-Id: Iff87239de98694cf124a44e7cb39f6d9e867ce93 Signed-off-by: Frantisek Kobzik <fkob...@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/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalRunOnceModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java 4 files changed, 47 insertions(+), 59 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/19846/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 4730f95..b914bbe 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 @@ -1,5 +1,7 @@ package org.ovirt.engine.ui.common.widget.uicommon.popup.vm; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.ui.common.CommonApplicationConstants; import org.ovirt.engine.ui.common.CommonApplicationResources; @@ -328,6 +330,20 @@ sysPrepDomainNameListBoxEditor = new ListModelListBoxEditor<Object>(); sysPrepDomainNameTextBoxEditor = new EntityModelTextBoxEditor(); + sysPrepDomainNameListBoxEditor.asListBox().addDomHandler(new FocusHandler() { + @Override + public void onFocus(FocusEvent event) { + sysPrepDomainNameListBoxEditor.asListBox().setSelectedIndex(-1); + } + }, FocusEvent.getType()); + + sysPrepDomainNameListBoxEditor.asListBox().addDomHandler(new ChangeHandler() { + @Override + public void onChange(ChangeEvent event) { + runOnceModel.sysPrepListBoxChanged(); + } + }, ChangeEvent.getType()); + sysPrepDomainNameComboBox = new ComboBox(sysPrepDomainNameListBoxEditor, sysPrepDomainNameTextBoxEditor); defaultHostEditor = new ListModelListBoxEditor<Object>(new NullSafeRenderer<Object>() { 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 314def4..8c32155 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 @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import org.ovirt.engine.core.common.action.RunVmOnceParams; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DisplayType; @@ -552,7 +551,6 @@ // Initial Boot tab - Sysprep setSysPrepDomainName(new ListModel()); - getSysPrepDomainName().getSelectedItemChangedEvent().addListener(this); setSysPrepSelectedDomainName(new EntityModel()); setSysPrepUserName(new EntityModel().setIsChangable(false)); @@ -630,7 +628,6 @@ getIsLinuxOptionsAvailable().setEntity(getIsLinuxOS()); setIsWindowsOS(AsyncDataProvider.isWindowsOsType(vm.getVmOsId())); getIsVmFirstRun().setEntity(!vm.isInitialized()); - getSysPrepDomainName().setSelectedItem(vm.getVmDomain()); getCloudInit().init(vm, null); @@ -707,6 +704,11 @@ params.setUseVnc((Boolean) getDisplayConsole_Vnc_IsSelected().getEntity()); } + String selectedDomain = (String) getSysPrepSelectedDomainName().getEntity(); + if (!StringHelper.isNullOrEmpty(selectedDomain)) { + params.setSysPrepDomainName(selectedDomain); + } + return params; } @@ -719,8 +721,7 @@ VM selectedVM = (VM) vm; List<String> images = (List<String>) returnValue; - if (AsyncDataProvider.isWindowsOsType(selectedVM.getVmOsId())) - { + if (AsyncDataProvider.isWindowsOsType(selectedVM.getVmOsId())) { // Add a pseudo floppy disk image used for Windows' sysprep. if (!selectedVM.isInitialized()) { images.add(0, "[sysprep]"); //$NON-NLS-1$ @@ -744,30 +745,29 @@ Frontend.RunQuery(VdcQueryType.GetAllDisksByVmId, new IdQueryParameters(vm.getId()), new AsyncQuery(this, new INewAsyncCallback() { - @Override - public void onSuccess(Object model, Object returnValue) { - ArrayList<Disk> vmDisks = (ArrayList<Disk>) ((VdcQueryReturnValue) returnValue).getReturnValue(); + @Override + public void onSuccess(Object model, Object returnValue) { + ArrayList<Disk> vmDisks = (ArrayList<Disk>) ((VdcQueryReturnValue) returnValue).getReturnValue(); - if (vmDisks.isEmpty()) { - getRunAsStateless().setIsChangable(false); - getRunAsStateless() - .setChangeProhibitionReason(ConstantsManager.getInstance() - .getMessages() - .disklessVmCannotRunAsStateless()); - getRunAsStateless().setEntity(false); - } + if (vmDisks.isEmpty()) { + getRunAsStateless().setIsChangable(false); + getRunAsStateless() + .setChangeProhibitionReason(ConstantsManager.getInstance() + .getMessages() + .disklessVmCannotRunAsStateless()); + getRunAsStateless().setEntity(false); + } - if (!isDisksContainBootableDisk(vmDisks)) - { - BootSequenceModel bootSequenceModel = getBootSequence(); - bootSequenceModel.getHardDiskOption().setIsChangable(false); - bootSequenceModel.getHardDiskOption() - .setChangeProhibitionReason(ConstantsManager.getInstance() - .getMessages() - .bootableDiskIsRequiredToBootFromDisk()); - } - } - })); + if (!isDisksContainBootableDisk(vmDisks)) { + BootSequenceModel bootSequenceModel = getBootSequence(); + bootSequenceModel.getHardDiskOption().setIsChangable(false); + bootSequenceModel.getHardDiskOption() + .setChangeProhibitionReason(ConstantsManager.getInstance() + .getMessages() + .bootableDiskIsRequiredToBootFromDisk()); + } + } + })); } private boolean isDisksContainBootableDisk(List<Disk> disks) { @@ -857,6 +857,10 @@ }), true); } + public void sysPrepListBoxChanged() { + getSysPrepSelectedDomainName().setEntity(getSysPrepDomainName().getSelectedItem()); + } + @Override public void eventRaised(Event ev, Object sender, EventArgs args) { @@ -871,10 +875,6 @@ else if (sender == getFloppyImage()) { floppyImage_SelectedItemChanged(); - } - else if (sender == getSysPrepDomainName()) - { - sysPrepDomainName_SelectedItemChanged(); } } else if (ev.matchesDefinition(EntityModel.EntityChangedEventDefinition)) @@ -947,11 +947,6 @@ private void IsoImage_SelectedItemChanged() { updateInitialRunFields(); - } - - private void sysPrepDomainName_SelectedItemChanged() - { - getSysPrepSelectedDomainName().setEntity(getSysPrepDomainName().getSelectedItem()); } private void isAutoAssign_EntityChanged(Object sender, EventArgs args) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalRunOnceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalRunOnceModel.java index d52eed7..26768d2 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalRunOnceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalRunOnceModel.java @@ -1,8 +1,6 @@ package org.ovirt.engine.ui.uicommonweb.models.vms; import java.util.ArrayList; - -import org.ovirt.engine.core.common.action.RunVmOnceParams; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.ui.frontend.Frontend; @@ -26,18 +24,6 @@ setIsCustomPropertiesSheetVisible(false); getCustomProperties().setEntity(vm.getCustomProperties()); - } - - @Override - protected RunVmOnceParams createRunVmOnceParams() { - RunVmOnceParams params = super.createRunVmOnceParams(); - // Sysprep params - if (getSysPrepDomainName().getSelectedItem() != null) - { - params.setSysPrepDomainName((String) getSysPrepDomainName().getSelectedItem()); - } - - return params; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java index bb8c90a..96e25cb 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/WebadminRunOnceModel.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; - import org.ovirt.engine.core.common.action.RunVmOnceParams; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.VDS; @@ -70,14 +69,6 @@ // set destination host if specified VDS defaultHost = (VDS) getDefaultHost().getSelectedItem(); params.setDestinationVdsId(defaultHost != null ? defaultHost.getId() : null); - } - - // Sysprep params - if (getSysPrepDomainName().getSelectedItem() != null) - { - params.setSysPrepDomainName(getSysPrepSelectedDomainName().getEntity().equals("") ? //$NON-NLS-1$ - (String) getSysPrepSelectedDomainName().getEntity() - : (String) getSysPrepDomainName().getSelectedItem()); } return params; -- To view, visit http://gerrit.ovirt.org/19846 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iff87239de98694cf124a44e7cb39f6d9e867ce93 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Frank Kobzik <fkob...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches