Eldan Shachar has uploaded a new change for review. Change subject: userportal\webadmin: cluster parameters override ......................................................................
userportal\webadmin: cluster parameters override This feature allows to configure the 'emulated machine' and 'cpu model'parameters for each VM separately instead of relying on the cluster default. Change-Id: Ia288e46f38c03935ec9b0817833b1921f15ec9f8 Bug-Url: https://bugzilla.redhat.com/838487 Feature-page:http://www.ovirt.org/Features/Cluster_parameters_override Signed-off-by: Eldan Shachar <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/builders/vm/HwOnlyCoreUnitToVmBaseBuilder.java 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/CustomInstanceType.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/ExistingInstanceTypeModelBehavior.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java M frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/models/pools/BaseVmListModelTest.java 16 files changed, 159 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/31582/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java index e0ae04a..faee6e1 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java @@ -553,6 +553,9 @@ @DefaultStringValue("Comment") String commentLabel(); + @DefaultStringValue("Emulated Machine") + String emulatedMachineLabel(); + @DefaultStringValue("Reason") String reasonLabel(); diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java index 99bbd19..052ceb1 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java @@ -7,6 +7,10 @@ import java.util.Arrays; import java.util.List; +import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.ChangeHandler; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.EventBus; import static com.google.gwt.dom.client.Style.Unit; import org.ovirt.engine.core.common.businessentities.BootSequence; @@ -34,6 +38,7 @@ import org.ovirt.engine.ui.common.CommonApplicationTemplates; 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.EntityModelDetachableWidgetWithInfo; import org.ovirt.engine.ui.common.widget.EntityModelWidgetWithInfo; import org.ovirt.engine.ui.common.widget.HasDetachable; @@ -273,6 +278,18 @@ @UiField(provided = true) public EntityModelDetachableWidgetWithLabel corePerSocketEditorWithDetachable; + + @UiField(provided = true) + @WithElementId("emulatedMachineComboBox") + public ComboBox<String> emulatedMachineComboBox; + + @Path(value = "emulatedMachine.selectedItem") + @WithElementId("emulatedMachineListBox") + public ListModelListBoxEditor<String> emulatedMachineListBoxEditor; + + @Path(value = "selectedEmulatedMachine.entity") + @WithElementId("emulatedMachineTextBox") + public StringEntityModelTextBoxEditor emulatedMachineTextBoxEditor; @UiField @Ignore @@ -1139,6 +1156,9 @@ new ModeSwitchingVisibilityRenderer() ); + + initComboBox(); + numOfSocketsEditor = new ListModelListBoxEditor<Integer>(new ModeSwitchingVisibilityRenderer()); numOfSocketsEditorWithDetachable = new EntityModelDetachableWidgetWithLabel(numOfSocketsEditor); corePerSocketEditor = new ListModelListBoxEditor<Integer>(new ModeSwitchingVisibilityRenderer()); @@ -1347,6 +1367,7 @@ totalvCPUsEditor.setLabel(constants.numOfVCPUs()); corePerSocketEditorWithDetachable.setLabel(constants.coresPerSocket()); numOfSocketsEditorWithDetachable.setLabel(constants.numOfSockets()); + emulatedMachineListBoxEditor.setLabel(constants.emulatedMachineLabel()); } protected void applyStyles() { @@ -1807,7 +1828,8 @@ nextTabIndex = vcpusAdvancedParameterExpander.setTabIndexes(nextTabIndex); corePerSocketEditor.setTabIndex(nextTabIndex++); - numOfSocketsEditor.setTabIndex(nextTabIndex++); + numOfSocketsEditor.setTabIndex(nextTabIndex++); + emulatedMachineListBoxEditor.setTabIndex(nextTabIndex++); nextTabIndex = serialNumberPolicyEditor.setTabIndexes(nextTabIndex); // == Pools == @@ -2108,4 +2130,25 @@ return hasValidations; } + + void initComboBox() { + emulatedMachineListBoxEditor = new ListModelListBoxEditor<String>(new ModeSwitchingVisibilityRenderer()); + emulatedMachineTextBoxEditor = new StringEntityModelTextBoxEditor(new ModeSwitchingVisibilityRenderer()); + + emulatedMachineListBoxEditor.asListBox().addDomHandler(new FocusHandler() { + @Override + public void onFocus(FocusEvent event) { + emulatedMachineListBoxEditor.asListBox().setSelectedIndex(-1); + } + }, FocusEvent.getType()); + + emulatedMachineListBoxEditor.asListBox().addDomHandler(new ChangeHandler() { + @Override + public void onChange(ChangeEvent event) { + unitVmModel.emulateMachineBoxChanged(); + } + }, ChangeEvent.getType()); + + emulatedMachineComboBox= new ComboBox<String>(emulatedMachineListBoxEditor, emulatedMachineTextBoxEditor); + } } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml index 3149e91..1cf7fe2 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.ui.xml @@ -481,6 +481,7 @@ <t:DialogTab ui:field="systemTab"> <t:content> <g:FlowPanel> + <ge:EntityModelDetachableWidgetWithLabel ui:field="detachableMemSizeEditor"/> <w:EntityModelDetachableWidgetWithInfo ui:field="totalvCPUsEditorWithInfoIcon" /> <g:FlowPanel addStyleNames="{style.sectionPanel}"> @@ -488,6 +489,7 @@ <g:FlowPanel ui:field="vcpusAdvancedParameterExpanderContent" addStyleNames="{style.generalExpanderContent}"> <ge:EntityModelDetachableWidgetWithLabel ui:field="corePerSocketEditorWithDetachable" /> <ge:EntityModelDetachableWidgetWithLabel ui:field="numOfSocketsEditorWithDetachable" /> + <w:ComboBox ui:field="emulatedMachineComboBox" /> </g:FlowPanel> </g:FlowPanel> <g:Label ui:field="generalLabel" addStyleNames="{style.sectionLabel}" text="{constants.initialRunGeneral}" /> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java index b49fad8..1602117 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java @@ -195,6 +195,7 @@ vm.setVmCreationDate(instance.getVmCreationDate()); vm.setVmDescription(instance.getVmDescription()); vm.setComment(instance.getComment()); + vm.setEmulatedMachine(instance.getEmulatedMachine()); vm.setId(instance.getId()); vm.setVmHost(instance.getVmHost()); vm.setVmIp(instance.getVmIp()); @@ -416,6 +417,7 @@ obj.setCreationDate(instance.getCreationDate()); obj.setDefaultBootSequence(instance.getDefaultBootSequence()); obj.setComment(instance.getComment()); + obj.setEmulatedMachine(instance.getEmulatedMachine()); obj.setFailBack(instance.isFailBack()); obj.setStateless(instance.isStateless()); obj.setMemSizeMb(instance.getMemSizeMb()); @@ -464,6 +466,7 @@ obj.setDedicatedVmForVds(instance.getDedicatedVmForVds()); obj.setDescription(instance.getDescription()); obj.setComment(instance.getComment()); + obj.setEmulatedMachine(instance.getEmulatedMachine()); obj.setInitialized(instance.isInitialized()); obj.setStateless(instance.isStateless()); obj.setRunAndPause(instance.isRunAndPause()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/builders/vm/HwOnlyCoreUnitToVmBaseBuilder.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/builders/vm/HwOnlyCoreUnitToVmBaseBuilder.java index 3105e62..b1fcadf 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/builders/vm/HwOnlyCoreUnitToVmBaseBuilder.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/builders/vm/HwOnlyCoreUnitToVmBaseBuilder.java @@ -21,5 +21,6 @@ vm.setMinAllocatedMem(model.getMinAllocatedMemory().getEntity()); vm.setDefaultBootSequence(model.getBootSequence()); vm.setSingleQxlPci(model.getIsSingleQxlEnabled().getEntity()); + vm.setEmulatedMachine(model.getSelectedEmulatedMachine().getEntity()); } } 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 08b0927..482cf09 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 @@ -3792,4 +3792,26 @@ }; } + public void getEmulatedMachinesByClusterID(AsyncQuery aQuery, Guid clusterId) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + if (source != null) + { + ArrayList<VDS> vdsList = Linq.<VDS> cast((ArrayList<IVdcQueryable>) source); + HashSet<String> emulatedMachineList = new HashSet(); + for (VDS host : vdsList) { + emulatedMachineList.addAll(Arrays.asList(host.getSupportedEmulatedMachines().split(","))); //$NON-NLS-1$ + } + return emulatedMachineList; + } + + return null; + } + }; + + Frontend.getInstance().runQuery(VdcQueryType.GetHostsByClusterId, new IdQueryParameters(clusterId), aQuery); + } + } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/CustomInstanceType.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/CustomInstanceType.java index 1ba62f1..e003ef2 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/CustomInstanceType.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/CustomInstanceType.java @@ -208,4 +208,13 @@ public void setId(Guid id) { } + + public String getEmulatedMachine() { + return null; + } + + public void setEmulatedMachine(String emulatedMachine) { + + } + } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java index d10b285..a39d7e4 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ExistingVmModelBehavior.java @@ -135,6 +135,7 @@ getModel().getName().setEntity(vm.getName()); getModel().getDescription().setEntity(vm.getVmDescription()); getModel().getComment().setEntity(vm.getComment()); + getModel().getSelectedEmulatedMachine().setEntity(vm.getEmulatedMachine()); getModel().getOSType().setSelectedItem(vm.getVmOsId()); getModel().getAllowConsoleReconnect().setEntity(vm.getAllowConsoleReconnect()); @@ -210,6 +211,7 @@ updateCpuSharesAvailability(); updateVirtioScsiAvailability(); updateOSValues(); + updateEmulatedMachines(); instanceTypeManager.updateAll(); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java index d005e93..a35a63f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewTemplateVmModelBehavior.java @@ -349,6 +349,8 @@ BuilderExecutor.build(vm.getStaticData(), getModel(), new SerialNumberPolicyVmBaseToUnitBuilder()); getModel().getBootMenuEnabled().setEntity(vm.isBootMenuEnabled()); + + getModel().getSelectedEmulatedMachine().setEntity(vm.getEmulatedMachine()); } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java index 5f79b01..ae6b7ba 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewVmModelBehavior.java @@ -157,6 +157,8 @@ BuilderExecutor.build(template, getModel(), new SerialNumberPolicyVmBaseToUnitBuilder()); getModel().getBootMenuEnabled().setEntity(template.isBootMenuEnabled()); + + getModel().getSelectedEmulatedMachine().setEntity(template.getEmulatedMachine()); } } @@ -185,6 +187,7 @@ updateCpuSharesAvailability(); updateVirtioScsiAvailability(); activateInstanceTypeManager(); + updateEmulatedMachines(); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java index 3886595..e6de1d9 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/TemplateVmModelBehavior.java @@ -171,6 +171,7 @@ getModel().getName().setEntity(template.getName()); getModel().getDescription().setEntity(template.getDescription()); getModel().getComment().setEntity(template.getComment()); + getModel().getSelectedEmulatedMachine().setEntity(template.getEmulatedMachine()); getModel().getMinAllocatedMemory().setEntity(template.getMinAllocatedMem()); getModel().getMinAllocatedMemory().setIsChangable(false); getModel().getMemSize().setEntity(template.getMemSizeMb()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java index 978e7c6..b3123bc 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java @@ -564,6 +564,26 @@ privateName = value; } + private ListModel<String> emulatedMachine; + + public ListModel<String> getEmulatedMachine() { + return emulatedMachine; + } + + private void setEmulatedMachine(ListModel<String> emulatedMachine) { + this.emulatedMachine = emulatedMachine; + } + + private EntityModel<String> selectedEmulatedMachine; + + public EntityModel<String> getSelectedEmulatedMachine() { + return selectedEmulatedMachine; + } + + private void setSelectedEmulatedMachine(EntityModel<String> selectedEmulatedMachine) { + this.selectedEmulatedMachine = selectedEmulatedMachine; + } + private NotChangableForVmInPoolListModel<Integer> privateOSType; public ListModel<Integer> getOSType() @@ -1530,6 +1550,9 @@ setDataCenterWithClustersList(new NotChangableForVmInPoolListModel<DataCenterWithCluster>()); getDataCenterWithClustersList().getSelectedItemChangedEvent().addListener(this); + setEmulatedMachine(new ListModel<String>()); + setSelectedEmulatedMachine(new EntityModel<String>()); + setTimeZone(new NotChangableForVmInPoolListModel<TimeZoneModel>()); getTimeZone().getSelectedItemChangedEvent().addListener(this); @@ -1733,6 +1756,7 @@ updateDisplayProtocol(); updateMemoryBalloonDevice(); initUsbPolicy(); + behavior.updateEmulatedMachines(); } else if (sender == getTemplate()) { @@ -2630,6 +2654,7 @@ }); getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() }); + getSelectedEmulatedMachine().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() }); } @@ -2683,6 +2708,7 @@ boolean isValid = hwPartValid && vmInitIsValid && getDataCenterWithClustersList().getIsValid() && getDisksAllocationModel().getIsValid() && getTemplate().getIsValid() && getComment().getIsValid() + && getEmulatedMachine().getIsValid() && getDefaultHost().getIsValid() && getTimeZone().getIsValid() && getOSType().getIsValid() && getCdImage().getIsValid() && getKernel_path().getIsValid() @@ -2742,7 +2768,8 @@ setIsSystemTabValid(getMemSize().getIsValid() && getTotalCPUCores().getIsValid() && - getSerialNumberPolicy().getCustomSerialNumber().getIsValid()); + getSerialNumberPolicy().getCustomSerialNumber().getIsValid() && + getSelectedEmulatedMachine().getIsValid()); // Minimum 'Physical Memory Guaranteed' is 1MB validateMemorySize(getMemSize(), Integer.MAX_VALUE, 1); @@ -3042,4 +3069,8 @@ return ((CurrentUserRole) TypeResolver.getInstance().resolve(CurrentUserRole.class)).isCreateInstanceOnly(); } + public void emulateMachineBoxChanged() { + getSelectedEmulatedMachine().setEntity(getEmulatedMachine().getSelectedItem()); + } + } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java index bc3bc7a..e579234 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java @@ -6,8 +6,11 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.TreeSet; + import org.ovirt.engine.core.common.TimeZoneType; import org.ovirt.engine.core.common.businessentities.ActionGroup; import org.ovirt.engine.core.common.businessentities.ArchitectureType; @@ -1080,6 +1083,33 @@ } + /* + * Updates the emulated machine combobox after a cluster change occurs + */ + protected void updateEmulatedMachines() { + VDSGroup cluster = getModel().getSelectedCluster(); + + if (cluster == null) { + return; + } + + AsyncDataProvider.getInstance().getEmulatedMachinesByClusterID(new AsyncQuery(this, + new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object returnValue) { + TreeSet<String> emulatedSet = new TreeSet<String>((HashSet<String>)returnValue); + emulatedSet.add(""); + String lastEmulatedSelected = getModel().getSelectedEmulatedMachine().getEntity(); + getModel().getEmulatedMachine().setItems(emulatedSet); + if (lastEmulatedSelected != null && !lastEmulatedSelected.equals("") && emulatedSet.contains(lastEmulatedSelected)) { //$NON-NLS-1$ + getModel().getEmulatedMachine().setSelectedItem(lastEmulatedSelected); + } else { + getModel().getSelectedEmulatedMachine().setEntity(lastEmulatedSelected); + } + } + }), cluster.getId()); + } + protected void updateSelectedCdImage(VmBase vmBase) { getModel().getCdImage().setSelectedItem(vmBase.getIsoPath()); boolean hasCd = !StringHelper.isNullOrEmpty(vmBase.getIsoPath()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/ExistingInstanceTypeModelBehavior.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/ExistingInstanceTypeModelBehavior.java index d617c19..0c9258c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/ExistingInstanceTypeModelBehavior.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/ExistingInstanceTypeModelBehavior.java @@ -128,6 +128,7 @@ } } )); + getModel().getSelectedEmulatedMachine().setEntity(instanceType.getEmulatedMachine()); } protected void initSoundCard(Guid id) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java index bef5495..7daba8a 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/instancetypes/InstanceTypeManager.java @@ -258,6 +258,8 @@ maybeSetSelectedItem(model.getNumOfSockets(), vmBase.getNumOfSockets()); maybeSetSelectedItem(model.getCoresPerSocket(), vmBase.getCpuPerSocket()); + maybeSetEntity(model.getSelectedEmulatedMachine(), vmBase.getEmulatedMachine()); + model.setSelectedMigrationDowntime(vmBase.getMigrationDowntime()); priorityUtil.initPriority(vmBase.getPriority()); diff --git a/frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/models/pools/BaseVmListModelTest.java b/frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/models/pools/BaseVmListModelTest.java index be68233..a3533cc 100644 --- a/frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/models/pools/BaseVmListModelTest.java +++ b/frontend/webadmin/modules/uicommonweb/src/test/java/org/ovirt/engine/ui/uicommonweb/models/pools/BaseVmListModelTest.java @@ -35,6 +35,7 @@ protected static final int NUM_OF_MONITORS = 2; protected static final String DESCRIPTION = "enterprise VM"; //$NON-NLS-1$ protected static final String COMMENT = "important!"; //$NON-NLS-1$ + protected static final String EMULATED_MACHINE = "rhel_version"; //$NON-NLS-1$ protected static final int MEM_SIZE = 1024; protected static final int MIN_MEM = 100; protected static final Guid CLUSTER_ID = Guid.newGuid(); @@ -80,6 +81,7 @@ when(model.getNumOfMonitors().getSelectedItem()).thenReturn(NUM_OF_MONITORS); when(model.getDescription().getEntity()).thenReturn(DESCRIPTION); when(model.getComment().getEntity()).thenReturn(COMMENT); + when(model.getSelectedEmulatedMachine().getEntity()).thenReturn(EMULATED_MACHINE); when(model.getMemSize().getEntity()).thenReturn(MEM_SIZE); when(model.getMinAllocatedMemory().getEntity()).thenReturn(MIN_MEM); when(model.getSelectedCluster().getId()).thenReturn(CLUSTER_ID); -- To view, visit http://gerrit.ovirt.org/31582 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia288e46f38c03935ec9b0817833b1921f15ec9f8 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eldan Shachar <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
