Liron Aravot has uploaded a new change for review.

Change subject: core: ImportVM - attempt to revert tasks.
......................................................................

core: ImportVM - attempt to revert tasks.

When failing on import vm command, we need to attempt to perform
rollback to added disks in order to be able to import without clone
again in case of a failure, this is done by calling endWithFailure of each
child command that was executed during the import process.

Change-Id: I216d51dff960cffea245ad783ab2e2ff6d8c29b0
Bug-Url: https://bugzilla.redhat.com/890922
Signed-off-by: Liron Aravot <lara...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java
2 files changed, 11 insertions(+), 11 deletions(-)


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

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
index d95cbaf..d313a85 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
@@ -26,6 +26,7 @@
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.ImportVmParameters;
 import org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters;
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdcReturnValueBase;
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
@@ -931,21 +932,20 @@
     }
 
     @Override
+    protected void endActionOnAllImageGroups() {
+        for (VdcActionParametersBase p : 
getParameters().getImagesParameters()) {
+            p.setTaskGroupSuccess(getParameters().getTaskGroupSuccess());
+            getBackend().EndAction(getImagesActionType(), p);
+        }
+    }
+
+    @Override
     protected void endWithFailure() {
         setVm(null); // Going to try and refresh the VM by re-loading
         // it form DB
         VM vmFromParams = getParameters().getVm();
         if (getVm() != null) {
-            VmHandler.UnLockVm(getVm());
-            for (DiskImage disk : imageList) {
-                getDiskImageDynamicDAO().remove(disk.getImageId());
-                getImageDao().remove(disk.getImageId());
-
-                List<DiskImage> imagesForDisk = 
getDiskImageDao().getAllSnapshotsForImageGroup(disk.getId());
-                if (imagesForDisk == null || imagesForDisk.isEmpty()) {
-                    getBaseDiskDao().remove(disk.getId());
-                }
-            }
+            endActionOnAllImageGroups();
             removeVmNetworkInterfaces();
             new SnapshotsManager().removeSnapshots(getVm().getId());
             getVmDynamicDAO().remove(getVmId());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java
index a3f2e84..e7f79f8 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java
@@ -190,7 +190,7 @@
     @Override
     protected void revertTasks() {
         // Revert should be performed only for AddVmFromSnapshot at this point.
-        if (getParameters().getParentCommand() == 
VdcActionType.AddVmFromSnapshot) {
+        if (getParameters().getParentCommand() == 
VdcActionType.AddVmFromSnapshot || getParameters().getParentCommand() == 
VdcActionType.ImportVm) {
             Guid destImageId = getParameters().getDestinationImageId();
             RemoveImageParameters removeImageParams =
                     new RemoveImageParameters(destImageId);


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I216d51dff960cffea245ad783ab2e2ff6d8c29b0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <lara...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to