Omer Frenkel has uploaded a new change for review. Change subject: core: allow hibernate for vm without image disks (#928708) ......................................................................
core: allow hibernate for vm without image disks (#928708) remove check for image disks, move storage domain space check to storage domain selection method Change-Id: I83a5ffc4653929c65174e27eae3e605dbef75c4c Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=928708 Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.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/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 6 files changed, 22 insertions(+), 24 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/13395/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java index ab5e134..de3c61f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java @@ -1,6 +1,5 @@ package org.ovirt.engine.core.bll; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -12,14 +11,13 @@ import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.asynctasks.AsyncTaskType; -import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType; +import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.VolumeFormat; import org.ovirt.engine.core.common.businessentities.VolumeType; -import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.errors.VdcBLLException; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.vdscommands.CreateImageVDSCommandParameters; @@ -58,6 +56,14 @@ private Guid _storageDomainId = Guid.Empty; + /* + * find a storage domain to store the hibernation volumes + * domain must: + * be data domain (or master) + * be active + * have enough space for the volumes + * return Guid.Empty if no domain found + */ @Override public NGuid getStorageDomainId() { if (_storageDomainId.equals(Guid.Empty) && getVm() != null) { @@ -67,7 +73,9 @@ for (StorageDomain currDomain : domainsInPool) { if ((currDomain.getStorageDomainType().equals(StorageDomainType.Master) || currDomain.getStorageDomainType().equals(StorageDomainType.Data)) - && currDomain.getStatus() == StorageDomainStatus.Active) { + && currDomain.getStatus() == StorageDomainStatus.Active + && doesStorageDomainhaveSpaceForRequest(currDomain, (getImageSizeInBytes() + + getMetaDataSizeInBytes()) / BYTES_IN_GB)) { _storageDomainId = currDomain.getId(); break; } @@ -232,7 +240,7 @@ // ReturnValue.CanDoActionMessages.Add(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW.toString()); // } else if (getStorageDomainId().equals(Guid.Empty)) { - addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST); + addCanDoActionMessage(VdcBllMessages.CANNOT_HIBERNATE_NO_SUITABLE_DOMAIN_FOUND); retValue = false; } else { if (getVm().getStatus() == VMStatus.WaitForLaunch || getVm().getStatus() == VMStatus.NotResponding) { @@ -258,24 +266,6 @@ retValue = false; addCanDoActionMessage(VdcBllMessages.VM_CANNOT_SUSPEND_VM_FROM_POOL); } - - if (retValue) { - Collection<DiskImage> disksImages = - ImagesHandler.filterImageDisks(getVm().getDiskMap().values(), false, false); - if (disksImages.isEmpty()) { - retValue = false; - addCanDoActionMessage(VdcBllMessages.VM_CANNOT_SUSPEND_VM_WITHOUT_IMAGE_DISKS); - } - } - - // Check storage before trying to create Images for hibernation. - StorageDomain domain = - DbFacade.getInstance().getStorageDomainDao().get(getStorageDomainId().getValue()); - if (retValue - && !doesStorageDomainhaveSpaceForRequest(domain, (getImageSizeInBytes() - + getMetaDataSizeInBytes())/BYTES_IN_GB)) { - return false; - } } } } @@ -283,7 +273,8 @@ } protected boolean doesStorageDomainhaveSpaceForRequest(StorageDomain storageDomain, long sizeRequested) { - return validate(new StorageDomainValidator(storageDomain).isDomainHasSpaceForRequest(sizeRequested)); + // not calling validate in order not to add the messages per domain + return (new StorageDomainValidator(storageDomain).isDomainHasSpaceForRequest(sizeRequested)).isValid(); } @Override diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index 9f9c596..4b6eaf5 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -699,6 +699,7 @@ ACTION_TYPE_FAILED_SERVER_NAME_REQUIRED, SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER, SSH_AUTHENTICATION_FAILED, + CANNOT_HIBERNATE_NO_SUITABLE_DOMAIN_FOUND, VM_INTERFACE_NOT_EXIST, ACTION_TYPE_FAILED_CANNOT_REMOVE_ACTIVE_DEVICE, 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 5a80d60..1e5ce79 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -836,6 +836,7 @@ SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER=One or more servers are already part of an existing cluster. SSH_AUTHENTICATION_FAILED=SSH Authentication failed. Please make sure password is correct. ======= +CANNOT_HIBERNATE_NO_SUITABLE_DOMAIN_FOUND=Cannot Hibernate VM, No active data Storage Domain with enough storage was found in the Data Center. # External Events Errors Messages VAR__TYPE__EXTERNAL_EVENT=$type External Event ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLEGAL_ORIGIN=Cannot ${action} ${type}. Illegal Origin for External Event : oVirt 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 2acfbb2..99bc620 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 @@ -2223,4 +2223,7 @@ @DefaultStringValue("SSH Authentication failed. Please make sure password is correct.") String SSH_AUTHENTICATION_FAILED(); + + @DefaultStringValue("Cannot Hibernate VM, No active data Storage Domain with enough storage was found in the Data Center.") + String CANNOT_HIBERNATE_NO_SUITABLE_DOMAIN_FOUND(); } 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 20b32a6..0019bfb 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 @@ -772,6 +772,7 @@ USER_CANNOT_FORCE_RECONNECT_TO_VM=Console connection denied. Another user has already accessed the console of this VM. The VM should be rebooted to allow another user to access it, or changed by an admin to not enforce reboot between users accessing its console. ENGINE_IS_RUNNING_IN_MAINTENANCE_MODE=Engine is running in Maintenance mode and is not accepting commands. ENGINE_IS_RUNNING_IN_PREPARE_MODE=This action is not allowed when Engine is preparing for maintenance. +CANNOT_HIBERNATE_NO_SUITABLE_DOMAIN_FOUND=Cannot Hibernate VM, No active data Storage Domain with enough storage was found in the Data Center. # External Events Errors Messages VAR__TYPE__EXTERNAL_EVENT=$type External Event ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLEGAL_ORIGIN=Cannot ${action} ${type}. Illegal Origin for External Event : oVirt 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 5f7c9ed..39c7e49 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 @@ -774,6 +774,7 @@ ENGINE_IS_RUNNING_IN_PREPARE_MODE=This action is not allowed when Engine is preparing for maintenance. SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER=One or more servers are already part of an existing cluster. SSH_AUTHENTICATION_FAILED=SSH Authentication failed. Please make sure password is correct. +CANNOT_HIBERNATE_NO_SUITABLE_DOMAIN_FOUND=Cannot Hibernate VM, No active data Storage Domain with enough storage was found in the Data Center. # External Events Errors Messages VAR__TYPE__EXTERNAL_EVENT=$type External Event ACTION_TYPE_FAILED_EXTERNAL_EVENT_ILLEGAL_ORIGIN=Cannot ${action} ${type}. Illegal Origin for External Event : oVirt -- To view, visit http://gerrit.ovirt.org/13395 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I83a5ffc4653929c65174e27eae3e605dbef75c4c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches