Tomas Jelinek has uploaded a new change for review. Change subject: webadmin: allow migration to different cluster ......................................................................
webadmin: allow migration to different cluster Added a list box into the advanced parameters which lets the user change the destination cluster. Since this is quite a dangerous task, added also a warning. Change-Id: I224ac719d16b348bb8ea31b256fe459bc372a88d Bug-Url: https://bugzilla.redhat.com/1150191 Signed-off-by: Tomas Jelinek <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.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/MigrateModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.ui.xml 6 files changed, 203 insertions(+), 86 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/51/34651/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 61fb35b..a76f7ea 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 @@ -706,6 +706,9 @@ @DefaultStringValue("Priority for Run/Migration queue:") String priorForRunMigrationQueueVmPopup(); + @DefaultStringValue("Choosing different cluster may lead to unexpected results. Please consult documentation.") + String migrationToDifferentClusterWarning(); + @DefaultStringValue("Watchdog") String watchdog(); 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 dd51802..cce0872 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 @@ -3579,7 +3579,7 @@ return (Boolean) getConfigValuePreConverted(ConfigurationValues.MixedDomainTypesInDataCenter, version.toString()); } - private static ArrayList<VDSGroup> getClusterByServiceList(ArrayList<VDSGroup> list, + public static ArrayList<VDSGroup> getClusterByServiceList(List<VDSGroup> list, boolean supportsVirtService, boolean supportsGlusterService) { final ArrayList<VDSGroup> filteredList = new ArrayList<VDSGroup>(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/MigrateModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/MigrateModel.java index 0f291fd..1a45e27 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/MigrateModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/MigrateModel.java @@ -1,12 +1,21 @@ package org.ovirt.engine.ui.uicommonweb.models.vms; import java.util.ArrayList; +import java.util.List; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.Linq; +import org.ovirt.engine.ui.uicommonweb.UICommand; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.ListModel; import org.ovirt.engine.ui.uicommonweb.models.Model; +import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.Event; import org.ovirt.engine.ui.uicompat.EventArgs; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; @@ -16,6 +25,8 @@ { private ListModel<VDS> privateHosts; + private VmListModel parentModel; + private VM vm; public ListModel<VDS> getHosts() { @@ -25,6 +36,16 @@ private void setHosts(ListModel<VDS> value) { privateHosts = value; + } + + private ListModel<VDSGroup> clusters; + + public ListModel<VDSGroup> getClusters() { + return clusters; + } + + public void setClusters(ListModel<VDSGroup> clusters) { + this.clusters = clusters; } private ArrayList<VM> privateVmList; @@ -154,8 +175,9 @@ privateSelectDestinationHost_IsSelected = value; } - public MigrateModel() + public MigrateModel(VmListModel parentModel) { + this.parentModel = parentModel; setHosts(new ListModel<VDS>()); getHosts().getSelectedItemChangedEvent().addListener(this); @@ -164,6 +186,117 @@ setSelectDestinationHost_IsSelected(new EntityModel<Boolean>()); getSelectDestinationHost_IsSelected().getEntityChangedEvent().addListener(this); + + setClusters(new ListModel<VDSGroup>()); + getClusters().getSelectedItemChangedEvent().addListener(this); + } + + public void initializeModel() { + if (vm.getVdsGroupId() == null) { + return; + } + + AsyncDataProvider.getClusterList( + new AsyncQuery(MigrateModel.this, new INewAsyncCallback() { + + @Override + public void onSuccess(Object target, Object returnValue) { + List<VDSGroup> clusterList = (List<VDSGroup>) returnValue; + List<VDSGroup> onlyWithArchitecture = AsyncDataProvider.filterClustersWithoutArchitecture(clusterList); + List<VDSGroup> onlyVirt = AsyncDataProvider.getClusterByServiceList(onlyWithArchitecture, true, false); + + + VDSGroup selected = null; + for (VDSGroup cluster : onlyVirt) { + if (cluster.getId().equals(vm.getVdsGroupId())) { + selected = cluster; + break; + } + } + + clusters.setItems(onlyVirt, selected != null ? selected : Linq.firstOrDefault(onlyVirt)); + } + }), + vm.getStoragePoolId()); + } + + private void loadHosts() { + VDSGroup selectedCluster = clusters.getSelectedItem(); + if (selectedCluster == null) { + return; + } + + AsyncDataProvider.getUpHostListByCluster(new AsyncQuery(this, + new INewAsyncCallback() { + @Override + public void onSuccess(Object target, Object returnValue) { + postMigrateGetUpHosts(privateVmList, (ArrayList<VDS>) returnValue); + } + }), selectedCluster.getName()); + } + + private void postMigrateGetUpHosts(List<VM> selectedVms, ArrayList<VDS> hosts) { + setVmsOnSameCluster(true); + setIsSameVdsMessageVisible(false); + setNoSelAvailable(false); + + Guid run_on_vds = null; + boolean allRunOnSameVds = true; + + for (VM item : selectedVms) { + if (!item.getVdsGroupId().equals((selectedVms.get(0)).getVdsGroupId())) { + setVmsOnSameCluster(false); + } + if (run_on_vds == null) { + run_on_vds = item.getRunOnVds(); + } + else if (allRunOnSameVds && !run_on_vds.equals(item.getRunOnVds())) { + allRunOnSameVds = false; + } + } + + setIsHostSelAvailable(getVmsOnSameCluster() && hosts.size() > 0); + + removeUnselectableHosts(hosts, run_on_vds, allRunOnSameVds); + + getCommands().clear(); + + if (hosts.isEmpty()) { + setIsHostSelAvailable(false); + getHosts().setItems(new ArrayList<VDS>()); + + if (allRunOnSameVds) { + setNoSelAvailable(true); + UICommand tempVar = new UICommand("Cancel", parentModel); //$NON-NLS-1$ + tempVar.setTitle(ConstantsManager.getInstance().getConstants().close()); + tempVar.setIsDefault(true); + tempVar.setIsCancel(true); + getCommands().add(tempVar); + } + } else { + getHosts().setItems(hosts, Linq.firstOrDefault(hosts)); + + UICommand tempVar2 = new UICommand("OnMigrate", parentModel); //$NON-NLS-1$ + tempVar2.setTitle(ConstantsManager.getInstance().getConstants().ok()); + tempVar2.setIsDefault(true); + getCommands().add(tempVar2); + UICommand tempVar3 = new UICommand("Cancel", parentModel); //$NON-NLS-1$ + tempVar3.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + tempVar3.setIsCancel(true); + getCommands().add(tempVar3); + } + } + + private void removeUnselectableHosts(ArrayList<VDS> hosts, Guid run_on_vds, boolean allRunOnSameVds) { + if (getVmsOnSameCluster() && allRunOnSameVds) { + VDS runOnSameVDS = null; + for (VDS host : hosts) { + if (host.getId().equals(run_on_vds)) { + runOnSameVDS = host; + } + } + hosts.remove(runOnSameVDS); + } } @Override @@ -173,6 +306,10 @@ if (sender == getHosts() && getVmsOnSameCluster()) { VDS selectedHost = getHosts().getSelectedItem(); + if (selectedHost == null) { + return; + } + sethasSameVdsMessage(false); for (VM vm : getVmList()) { @@ -183,6 +320,10 @@ } } setIsSameVdsMessageVisible(gethasSameVdsMessage()); + } + else if (sender == getClusters()) + { + loadHosts(); } else if (ev.matchesDefinition(EntityModel.entityChangedEventDefinition)) { @@ -196,4 +337,8 @@ } } } + + public void setVm(VM vm) { + this.vm = vm; + } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java index c201e29..29d41d3 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java @@ -28,7 +28,6 @@ import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.Tags; -import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; @@ -1449,7 +1448,7 @@ return; } - MigrateModel model = new MigrateModel(); + MigrateModel model = new MigrateModel(this); setWindow(model); model.setTitle(ConstantsManager.getInstance().getConstants().migrateVirtualMachinesTitle()); model.setHelpTag(HelpTag.migrate_virtual_machine); @@ -1457,15 +1456,8 @@ model.setVmsOnSameCluster(true); model.setIsAutoSelect(true); model.setVmList(Linq.<VM> cast(getSelectedItems())); - - AsyncDataProvider.getUpHostListByCluster(new AsyncQuery(this, - new INewAsyncCallback() { - @Override - public void onSuccess(Object target, Object returnValue) { - VmListModel vmListModel = (VmListModel) target; - vmListModel.postMigrateGetUpHosts((ArrayList<VDS>) returnValue); - } - }), vm.getVdsGroupName()); + model.setVm(vm); + model.initializeModel(); } private void cancelMigration() @@ -1485,74 +1477,6 @@ }, null); } - private void postMigrateGetUpHosts(ArrayList<VDS> hosts) - { - MigrateModel model = (MigrateModel) getWindow(); - Guid run_on_vds = null; - boolean allRunOnSameVds = true; - - for (Object item : getSelectedItems()) - { - VM a = (VM) item; - if (!a.getVdsGroupId().equals(((VM) getSelectedItems().get(0)).getVdsGroupId())) - { - model.setVmsOnSameCluster(false); - } - if (run_on_vds == null) - { - run_on_vds = a.getRunOnVds(); - } - else if (allRunOnSameVds && !run_on_vds.equals(a.getRunOnVds())) - { - allRunOnSameVds = false; - } - } - - model.setIsHostSelAvailable(model.getVmsOnSameCluster() && hosts.size() > 0); - - if (model.getVmsOnSameCluster() && allRunOnSameVds) - { - VDS runOnSameVDS = null; - for (VDS host : hosts) - { - if (host.getId().equals(run_on_vds)) - { - runOnSameVDS = host; - } - } - hosts.remove(runOnSameVDS); - } - if (hosts.isEmpty()) - { - model.setIsHostSelAvailable(false); - - if (allRunOnSameVds) - { - model.setNoSelAvailable(true); - - UICommand tempVar = new UICommand("Cancel", this); //$NON-NLS-1$ - tempVar.setTitle(ConstantsManager.getInstance().getConstants().close()); - tempVar.setIsDefault(true); - tempVar.setIsCancel(true); - model.getCommands().add(tempVar); - } - } - else - { - model.getHosts().setItems(hosts); - model.getHosts().setSelectedItem(Linq.firstOrDefault(hosts)); - - UICommand tempVar2 = new UICommand("OnMigrate", this); //$NON-NLS-1$ - tempVar2.setTitle(ConstantsManager.getInstance().getConstants().ok()); - tempVar2.setIsDefault(true); - model.getCommands().add(tempVar2); - UICommand tempVar3 = new UICommand("Cancel", this); //$NON-NLS-1$ - tempVar3.setTitle(ConstantsManager.getInstance().getConstants().cancel()); - tempVar3.setIsCancel(true); - model.getCommands().add(tempVar3); - } - } - private void onMigrate() { MigrateModel model = (MigrateModel) getWindow(); @@ -1564,13 +1488,15 @@ model.startProgress(null); + Guid targetClusterId = model.getClusters().getSelectedItem() != null ? model.getClusters().getSelectedItem().getId() : null; + if (model.getIsAutoSelect()) { ArrayList<VdcActionParametersBase> list = new ArrayList<VdcActionParametersBase>(); for (Object item : getSelectedItems()) { VM a = (VM) item; - list.add(new MigrateVmParameters(true, a.getId())); + list.add(new MigrateVmParameters(true, a.getId(), targetClusterId)); } Frontend.getInstance().runMultipleAction(VdcActionType.MigrateVm, list, @@ -1592,13 +1518,13 @@ { VM a = (VM) item; - if (a.getRunOnVds().equals(((VDS) model.getHosts().getSelectedItem()).getId())) + if (a.getRunOnVds().equals((model.getHosts().getSelectedItem()).getId())) { continue; } - list.add(new MigrateVmToServerParameters(true, a.getId(), ((VDS) model.getHosts() - .getSelectedItem()).getId())); + list.add(new MigrateVmToServerParameters(true, a.getId(), model.getHosts() + .getSelectedItem().getId(), targetClusterId)); } Frontend.getInstance().runMultipleAction(VdcActionType.MigrateVmToServer, list, diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.java index a03e5c9..98ed351 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.java @@ -1,7 +1,11 @@ package org.ovirt.engine.ui.webadmin.section.main.view.popup.vm; +import com.google.gwt.user.client.ui.Panel; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSGroup; +import org.ovirt.engine.ui.common.idhandler.WithElementId; import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView; +import org.ovirt.engine.ui.common.widget.dialog.AdvancedParametersExpander; import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; import org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; @@ -58,6 +62,19 @@ @Ignore Label message3; + @UiField + @Ignore + AdvancedParametersExpander advancedOptionsExpander; + + @UiField + @Ignore + Panel advancedOptionsExpanderContent; + + @UiField(provided = true) + @Path(value = "clusters.selectedItem") + @WithElementId("clusters") + public ListModelListBoxEditor<VDSGroup> clustersEditor; + private final Driver driver = GWT.create(Driver.class); @Inject @@ -68,6 +85,9 @@ super(eventBus, resources); initEditors(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + + advancedOptionsExpander.initWithContent(advancedOptionsExpanderContent.getElement()); + localize(constants, messages); driver.initialize(this); } @@ -82,12 +102,20 @@ return vds.getName(); } }); + + clustersEditor = new ListModelListBoxEditor<VDSGroup>(new NullSafeRenderer<VDSGroup>() { + @Override + protected String renderNullSafe(VDSGroup cluster) { + return cluster.getName(); + } + }); } void localize(ApplicationConstants constants, ApplicationMessages messages) { selectHostAutomaticallyEditor.setLabel(constants.vmMigratePopupSelectHostAutomaticallyLabel()); selectDestinationHostEditor.setLabel(constants.vmMigratePopupSelectDestinationHostLabel()); hostsListEditor.setLabel(constants.vmMigratePopupHostsListLabel()); + clustersEditor.setLabel(constants.hostClusterVmPopup()); message1.setText(messages.migrateHostDisabledVMsInServerClusters()); message2.setText(messages.migrateSomeVmsAlreadyRunningOnHost()); message3.setText(messages.migrateNoAvailableHost()); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.ui.xml index 31d1355..c10aad8 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/VmMigratePopupView.ui.xml @@ -4,6 +4,8 @@ xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" xmlns:ge="urn:import:org.ovirt.engine.ui.common.widget.editor.generic"> + <ui:with field='constants' type='org.ovirt.engine.ui.common.CommonApplicationConstants'/> + <ui:style> .noteLabel, .errorLabel { @@ -11,7 +13,7 @@ margin-top: 10px; } - .errorLabel { + .errorLabel, .differentClusterWarning { color: #CD2127; } @@ -22,6 +24,14 @@ .contentWidgets { width: 97%; } + + .expanderContent { + padding-left: 10px; + } + + .differentClusterWarning { + font-weight: bold; + } </ui:style> <d:SimpleDialogPanel width="400px" height="300px"> @@ -30,6 +40,11 @@ <ge:EntityModelRadioButtonEditor ui:field="selectHostAutomaticallyEditor" addStyleNames="{style.contentWidgets}"/> <ge:EntityModelRadioButtonEditor ui:field="selectDestinationHostEditor" addStyleNames="{style.contentWidgets}"/> <e:ListModelListBoxEditor ui:field="hostsListEditor" addStyleNames="{style.contentWidgets}"/> + <d:AdvancedParametersExpander ui:field="advancedOptionsExpander"/> + <g:FlowPanel ui:field="advancedOptionsExpanderContent" addStyleNames="{style.expanderContent}"> + <g:Label text="{constants.migrationToDifferentClusterWarning}" addStyleNames="{style.differentClusterWarning}" /> + <e:ListModelListBoxEditor ui:field="clustersEditor" /> + </g:FlowPanel> <g:FlowPanel addStyleNames="{style.messagePanel}" > <g:Label ui:field="message1" addStyleNames="{style.errorLabel}" /> <g:Label ui:field="message2" addStyleNames="{style.noteLabel}" /> -- To view, visit http://gerrit.ovirt.org/34651 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I224ac719d16b348bb8ea31b256fe459bc372a88d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Tomas Jelinek <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
