Omer Frenkel has uploaded a new change for review.

Change subject: core: don't allow snapshot for suspended vm
......................................................................

core: don't allow snapshot for suspended vm

creating snapshot while vm is suspended is problematic,
since when resuming, vdsm still use the old volumes,
another problem is that the hibernation volumes info is not saved in the ovf.

Change-Id: Icf2c4c3ec3561df1d35f5e4da964664d63598434
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1120232
Signed-off-by: Omer Frenkel <ofren...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/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
7 files changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/34731/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
index 0d01a91..a161fb6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
@@ -543,7 +543,8 @@
 
     protected boolean validateVM(VmValidator vmValidator) {
         return canDoSnapshot(getVm()) &&
-                validate(vmValidator.vmNotSavingRestoring());
+                validate(vmValidator.vmNotSavingRestoring()) &&
+                validate(vmValidator.vmNotSuspended());
     }
 
     private boolean isSpecifiedDisksExist(List<DiskImage> disks) {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java
index 361d393..1b5f150 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidator.java
@@ -104,6 +104,16 @@
         return ValidationResult.VALID;
     }
 
+    public ValidationResult vmNotSuspended() {
+        for (VM vm : vms) {
+            if (vm.getStatus() == VMStatus.Suspended) {
+                return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_SUSPENDED);
+            }
+        }
+
+        return ValidationResult.VALID;
+    }
+
     public ValidationResult vmNotIlegal() {
         for (VM vm : vms) {
             if (vm.getStatus() == VMStatus.ImageIllegal) {
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 3e584fa..14771a1 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
@@ -167,6 +167,7 @@
     ACTION_TYPE_FAILED_VM_IS_NOT_DOWN_OR_UP(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VM_HOST_CANNOT_LIVE_MERGE(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VM_IS_SAVING_RESTORING(ErrorType.CONFLICT),
+    ACTION_TYPE_FAILED_VM_IS_SUSPENDED(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VM_IS_DURING_SNAPSHOT(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_VM_NOT_FOUND(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_CANNOT_USE_LATEST_WITH_CLONE(ErrorType.BAD_PARAMETERS),
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 b4b1970..3e05600 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -184,6 +184,7 @@
 ACTION_TYPE_FAILED_VM_HOST_CANNOT_LIVE_MERGE=Cannot ${action} ${type}. The 
host running VM ${VmName} is not capable of live merging snapshots.
 ACTION_TYPE_FAILED_VM_IS_SAVING_RESTORING=Cannot ${action} ${type}. VM is in 
saving/restoring state.\n\
        -Please try again when the VM is either up or down.
+ACTION_TYPE_FAILED_VM_IS_SUSPENDED=Cannot ${action} ${type}. VM is suspended.
 ACTION_TYPE_FAILED_VM_IS_DURING_SNAPSHOT=Cannot ${action} ${type}. The VM is 
performing an operation on a Snapshot. Please wait for the operation to finish, 
and try again.
 ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL=Cannot ${action} ${type} because the VM 
is in ${vmStatus} status.
 ACTION_TYPE_FAILED_VM_RUNNING_STATELESS=Cannot ${action} ${type}. The VM is 
running as Stateless. Please try again when VM is not running as Stateless.
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 70cc80f..a23417b 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
@@ -475,6 +475,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. VM is in saving/restoring 
state.\n-Please try again when the VM is either up or down.")
     String ACTION_TYPE_FAILED_VM_IS_SAVING_RESTORING();
 
+    @DefaultStringValue("Cannot ${action} ${type}. VM is suspended.")
+    String ACTION_TYPE_FAILED_VM_IS_SUSPENDED();
+
     @DefaultStringValue("Cannot ${action} ${type}. The VM is performing an 
operation on a Snapshot. Please wait for the operation to finish, and try 
again.")
     String ACTION_TYPE_FAILED_VM_IS_DURING_SNAPSHOT();
 
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 52c500e..d5481e3 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
@@ -166,6 +166,7 @@
 ACTION_TYPE_FAILED_VM_HOST_CANNOT_LIVE_MERGE=Cannot ${action} ${type}. The 
host running VM ${VmName} is not capable of live merging snapshots.
 ACTION_TYPE_FAILED_VM_IS_SAVING_RESTORING=Cannot ${action} ${type}. VM is in 
saving/restoring state.\n\
        -Please try again when the VM is either up or down.
+ACTION_TYPE_FAILED_VM_IS_SUSPENDED=Cannot ${action} ${type}. VM is suspended.
 ACTION_TYPE_FAILED_VM_IS_DURING_SNAPSHOT=Cannot ${action} ${type}. The VM is 
performing an operation on a Snapshot. Please wait for the operation to finish, 
and try again.
 ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL=Cannot ${action} ${type} because the VM 
is in ${vmStatus} status.
 ACTION_TYPE_FAILED_VM_RUNNING_STATELESS=Cannot ${action} ${type}. The VM is 
running as Stateless. Please try again when VM is not running as Stateless.
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 27f3aae..046f89f 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
@@ -180,6 +180,7 @@
 ACTION_TYPE_FAILED_VM_HOST_CANNOT_LIVE_MERGE=Cannot ${action} ${type}. The 
host running VM ${VmName} is not capable of live merging snapshots.
 ACTION_TYPE_FAILED_VM_IS_SAVING_RESTORING=Cannot ${action} ${type}. VM is in 
saving/restoring state.\n\
        -Please try again when the VM is either up or down.
+ACTION_TYPE_FAILED_VM_IS_SUSPENDED=Cannot ${action} ${type}. VM is suspended.
 ACTION_TYPE_FAILED_VM_IS_DURING_SNAPSHOT=Cannot ${action} ${type}. The VM is 
performing an operation on a Snapshot. Please wait for the operation to finish, 
and try again.
 ACTION_TYPE_FAILED_VM_STATUS_ILLEGAL=Cannot ${action} ${type} because the VM 
is in ${vmStatus} status.
 ACTION_TYPE_FAILED_VM_RUNNING_STATELESS=Cannot ${action} ${type}. The VM is 
running as Stateless. Please try again when VM is not running as Stateless.


-- 
To view, visit http://gerrit.ovirt.org/34731
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf2c4c3ec3561df1d35f5e4da964664d63598434
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

Reply via email to