Oved Ourfali has uploaded a new change for review. Change subject: core+ui: Support lowering cluster CPU level ......................................................................
core+ui: Support lowering cluster CPU level This patch removes the validation of not lowering down the cluster CPU level while VMs are running. A proper warning and confirmation window is displayed instead. Change-Id: I69a32299b5782e69aef8832501dc8969b6dc810c Bug-Url: https://bugzilla.redhat.com/1006209 Signed-off-by: Oved Ourfali <oourf...@redhat.com> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNumberOfActiveVmsInVdsGroupByVdsGroupIdQuery.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.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/clusters/ClusterListModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 11 files changed, 119 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/42/19442/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNumberOfActiveVmsInVdsGroupByVdsGroupIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNumberOfActiveVmsInVdsGroupByVdsGroupIdQuery.java new file mode 100644 index 0000000..f72b597 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNumberOfActiveVmsInVdsGroupByVdsGroupIdQuery.java @@ -0,0 +1,28 @@ +package org.ovirt.engine.core.bll; + +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.VM; +import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.queries.IdQueryParameters; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; + +public class GetNumberOfActiveVmsInVdsGroupByVdsGroupIdQuery<P extends IdQueryParameters> extends QueriesCommandBase<P> { + public GetNumberOfActiveVmsInVdsGroupByVdsGroupIdQuery(P parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + List<VM> vms = DbFacade.getInstance().getVmDao().getAllForVdsGroup(getParameters().getId()); + + // Active VMs are VMs that aren't in Down status + Integer activeVms = 0; + for (VM vm : vms) { + if (vm.getStatus() != VMStatus.Down) { + ++activeVms; + } + } + getQueryReturnValue().setReturnValue(activeVms); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java index 483eafc..8993223 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java @@ -242,10 +242,7 @@ result = false; } else if (notDownVms) { int compareResult = compareCpuLevels(oldGroup); - if (compareResult < 0) { - addCanDoActionMessage(VdcBllMessages.VDS_GROUP_CANNOT_LOWER_CPU_LEVEL); - result = false; - } else if (compareResult > 0) {// Upgrade of CPU in same compability level is allowed if + if (compareResult > 0) {// Upgrade of CPU in same compability level is allowed if // there // are running VMs - but we should warn they // cannot not be hibernated diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index 72c0ba3..3686c09 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -642,7 +642,6 @@ ERROR_CANNOT_REMOVE_ACTIVE_STORAGE_POOL(ErrorType.CONFLICT), USER_FAILED_TO_AUTHENTICATE_WRONG_USERNAME_OR_PASSWORD(ErrorType.NO_AUTHENTICATION), VDS_GROUP_CANNOT_UPDATE_CPU_WITH_SUSPENDED_VMS(ErrorType.CONFLICT), - VDS_GROUP_CANNOT_LOWER_CPU_LEVEL(ErrorType.CONFLICT), USER_FAILED_TO_AUTHENTICATE_ACCOUNT_IS_LOCKED_OR_DISABLED(ErrorType.NO_AUTHENTICATION), ACTION_TYPE_FAILED_CANNOT_REMOVE_BUILTIN_GROUP_EVERYONE(ErrorType.CONFLICT), ACTION_TYPE_FAILED_IMPORT_DATA_DOMAIN_PROHIBITED(ErrorType.BAD_PARAMETERS), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index 4ed7881..2fa9781 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -81,6 +81,7 @@ GetVdsGroupById(VdcQueryAuthType.User), GetVdsGroupByName(VdcQueryAuthType.User), GetVdsGroupsByStoragePoolId(VdcQueryAuthType.User), + GetNumberOfActiveVmsInVdsGroupByVdsGroupId, // Certificate GetCACertificate(VdcQueryAuthType.User), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index a8ec3b3..e6855c9 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -733,7 +733,6 @@ VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP=Cannot add storage server connection when Host status is not up USER_FAILED_TO_AUTHENTICATE_WRONG_USERNAME_OR_PASSWORD=The user name or password is incorrect. VDS_GROUP_CANNOT_UPDATE_CPU_WITH_SUSPENDED_VMS=Cannot update Cluster and change CPU Cluster level if there are suspended VMs in the Cluster -VDS_GROUP_CANNOT_LOWER_CPU_LEVEL=Cannot update Cluster and lower CPU Cluster level if not all virtual machines in Cluster are down CUSTOM_PROPERTIES_INVALID_VALUES_NOT_ALLOWED_IN_CURRENT_CLUSTER=Cannot update Cluster, custom properties are not supported under current Cluster version USER_FAILED_TO_AUTHENTICATE_ACCOUNT_IS_LOCKED_OR_DISABLED=Authentication failed. The user is either locked or disabled USER_FAILED_TO_AUTHENTICATE_DNS_ERROR=Authentication Failed. Error in DNS configuration. Please verify the Engine Host has a valid reverse DNS (PTR) record. diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 6d2c058..cf0d227 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -1969,9 +1969,6 @@ @DefaultStringValue("Cannot update Cluster and change CPU Cluster level if there are suspended VMs in the Cluster") String VDS_GROUP_CANNOT_UPDATE_CPU_WITH_SUSPENDED_VMS(); - @DefaultStringValue("Cannot update Cluster and lower CPU Cluster level if not all virtual machines in Cluster are down") - String VDS_GROUP_CANNOT_LOWER_CPU_LEVEL(); - @DefaultStringValue("Cannot update Cluster, custom properties are not supported under current Cluster version") String CUSTOM_PROPERTIES_INVALID_VALUES_NOT_ALLOWED_IN_CURRENT_CLUSTER(); 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 bddd410..04b6b62 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 @@ -3242,6 +3242,24 @@ Frontend.RunQuery(VdcQueryType.GetVnicProfilesByDataCenterId, new IdQueryParameters(dcId), aQuery); } + public static void getNumberOfActiveVmsInCluster(AsyncQuery aQuery, Guid clusterId) { + // do not replace a converter = just add if none provided + if (aQuery.converterCallback == null) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + if (source == null) + { + return Integer.valueOf(0); + } + return source; + } + }; + } + Frontend.RunQuery(VdcQueryType.GetNumberOfActiveVmsInVdsGroupByVdsGroupId, new IdQueryParameters(clusterId), aQuery); + } + private static ArrayList<VDSGroup> getClusterByServiceList(ArrayList<VDSGroup> list, boolean supportsVirtService, boolean supportsGlusterService) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java index cd545af..5e07104 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/clusters/ClusterListModel.java @@ -571,7 +571,7 @@ .getConstants() .youAreAboutChangeClusterCpuThreadSupportMsg()); - UICommand tempVar = new UICommand("OnSaveInternal", this); //$NON-NLS-1$ + UICommand tempVar = new UICommand("OnSaveConfirmCpuLevel", this); //$NON-NLS-1$ tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok()); tempVar.setIsDefault(true); getConfirmWindow().getCommands().add(tempVar); @@ -580,10 +580,69 @@ tempVar2.setIsCancel(true); getConfirmWindow().getCommands().add(tempVar2); } else { - onSaveInternal(); + onSaveConfirmCpuLevel(); } } + private ServerCpu getVdsGroupServerCpu(ClusterModel model, VDSGroup vdsGroup) { + ServerCpu retVal = null; + for (ServerCpu cpu : (ArrayList<ServerCpu>) model.getCPU().getItems()) { + if (StringHelper.stringsEqual(cpu.getCpuName(), vdsGroup.getcpu_name())) { + retVal = cpu; + break; + } + } + + return retVal; + } + + private void onSaveConfirmCpuLevel() + { + ClusterModel model = (ClusterModel) getWindow(); + + // cancel confirm window if there is one + cancelConfirmation(); + + AsyncQuery _asyncQuery = new AsyncQuery(); + _asyncQuery.setModel(model); + _asyncQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object result) + { + ClusterModel clusterModel = (ClusterModel) model; + Integer activeVms = (Integer) result; + + ServerCpu vdsCpu = getVdsGroupServerCpu(clusterModel, (VDSGroup) getSelectedItem()); + if (activeVms > 0 && vdsCpu != null && ((ServerCpu) clusterModel.getCPU().getSelectedItem()).getLevel() < vdsCpu.getLevel()) { + cpuLevelConfirmationWindow(); + } else { + onSaveInternal(); + } + } + }; + AsyncDataProvider.getNumberOfActiveVmsInCluster(_asyncQuery, ((VDSGroup) getSelectedItem()).getId()); + } + + private void cpuLevelConfirmationWindow() { + ConfirmationModel confirmModel = new ConfirmationModel(); + setConfirmWindow(confirmModel); + confirmModel.setTitle(ConstantsManager.getInstance() + .getConstants() + .changeCpuLevel()); + confirmModel.setHashName("change_cpu_level"); //$NON-NLS-1$ + confirmModel.setMessage(ConstantsManager.getInstance() + .getConstants() + .changeCpuLevelConfirmation()); + + UICommand tempVar = new UICommand("OnSaveInternal", this); //$NON-NLS-1$ + tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok()); + tempVar.setIsDefault(true); + getConfirmWindow().getCommands().add(tempVar); + UICommand tempVar2 = new UICommand("CancelConfirmation", this); //$NON-NLS-1$ + tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + tempVar2.setIsCancel(true); + getConfirmWindow().getCommands().add(tempVar2); + } public void onPreSaveInternal(ClusterModel model) { if ((Boolean) model.getIsImportGlusterConfiguration().getEntity()) @@ -964,6 +1023,10 @@ { onSaveConfirmCpuThreads(); } + else if (StringHelper.stringsEqual(command.getName(), "OnSaveConfirmCpuLevel")) //$NON-NLS-1$ + { + onSaveConfirmCpuLevel(); + } else if (StringHelper.stringsEqual(command.getName(), "OnSaveInternal")) //$NON-NLS-1$ { onSaveInternal(); diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index f01cf7e..9ba529f 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -90,6 +90,12 @@ @DefaultStringValue("Disable CPU Thread Support") String disableClusterCpuThreadSupportTitle(); + @DefaultStringValue("Change Cluster CPU level") + String changeCpuLevel(); + + @DefaultStringValue("There are running VMs. Lowering the Cluster CPU level might prevent migration of these VMs to some of the Hosts in the Cluster. Are you sure you want to continue?") + String changeCpuLevelConfirmation(); + @DefaultStringValue("General") String generalTitle(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 836dbd7..3c8b59d 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -713,7 +713,6 @@ VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP=Cannot add storage server connection when Host status is not up USER_FAILED_TO_AUTHENTICATE_WRONG_USERNAME_OR_PASSWORD=The user name or password is incorrect. VDS_GROUP_CANNOT_UPDATE_CPU_WITH_SUSPENDED_VMS=Cannot update Cluster and change CPU Cluster level if there are suspended VMs in the Cluster -VDS_GROUP_CANNOT_LOWER_CPU_LEVEL=Cannot update Cluster and lower CPU Cluster level if not all virtual machines in Cluster are down CUSTOM_PROPERTIES_INVALID_VALUES_NOT_ALLOWED_IN_CURRENT_CLUSTER=Cannot update Cluster, custom properties are not supported under current Cluster version USER_FAILED_TO_AUTHENTICATE_ACCOUNT_IS_LOCKED_OR_DISABLED=Authentication failed. The user is either locked or disabled USER_FAILED_TO_AUTHENTICATE_DNS_ERROR=Authentication Failed. Error in DNS configuration. Please verify the Engine Host has a valid reverse DNS (PTR) record. diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index c1589d6..40cbfde 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -734,7 +734,6 @@ VDS_ADD_STORAGE_SERVER_STATUS_MUST_BE_UP=Cannot add storage server connection when Host status is not up USER_FAILED_TO_AUTHENTICATE_WRONG_USERNAME_OR_PASSWORD=The user name or password is incorrect. VDS_GROUP_CANNOT_UPDATE_CPU_WITH_SUSPENDED_VMS=Cannot update Cluster and change CPU Cluster level if there are suspended VMs in the Cluster -VDS_GROUP_CANNOT_LOWER_CPU_LEVEL=Cannot update Cluster and lower CPU Cluster level if not all virtual machines in Cluster are down CUSTOM_PROPERTIES_INVALID_VALUES_NOT_ALLOWED_IN_CURRENT_CLUSTER=Cannot update Cluster, custom properties are not supported under current Cluster version USER_FAILED_TO_AUTHENTICATE_ACCOUNT_IS_LOCKED_OR_DISABLED=Authentication failed. The user is either locked or disabled USER_FAILED_TO_AUTHENTICATE_DNS_ERROR=Authentication Failed. Error in DNS configuration. Please verify the Engine Host has a valid reverse DNS (PTR) record. -- To view, visit http://gerrit.ovirt.org/19442 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I69a32299b5782e69aef8832501dc8969b6dc810c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Oved Ourfali <oourf...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches