Tomas Jelinek has uploaded a new change for review. Change subject: core: clone vm - if the vm has only sharable disks they are not attached ......................................................................
core: clone vm - if the vm has only sharable disks they are not attached The problem was that the attachDisks() was called only from endSuccessfully() which was called only after the async tasks ended. But when there were no disks to copy, there were no async tasks so this method was not called. Fixed by moving the logic into the overridden addVmImages() method and detaching the disks in case of an error during copying the disks. Change-Id: Ie2a8f4c35c68721e59c0b7e35c9148f148589794 Bug-Url: https://bugzilla.redhat.com/1124340 Signed-off-by: Tomas Jelinek <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java 1 file changed, 23 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/73/32673/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java index cecfda1..96fdd96 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CloneVmCommand.java @@ -159,13 +159,30 @@ } @Override - protected void endSuccessfully() { - super.endSuccessfully(); - attachDisks(); + protected void removeVmRelatedEntitiesFromDb() { + detachDisks(); + super.removeVmRelatedEntitiesFromDb(); + } + + @Override + protected boolean addVmImages() { + if (super.addVmImages()) { + attachDisks(); + return true; + } + + return false; + } + + private void detachDisks() { + attachDetachDisks(VdcActionType.DetachDiskFromVm); } private void attachDisks() { + attachDetachDisks(VdcActionType.AttachDiskToVm); + } + private void attachDetachDisks(VdcActionType actionType) { VdcQueryReturnValue vdcReturnValue = runInternalQuery( VdcQueryType.GetAllDisksByVmId, new IdQueryParameters(oldVmId)); @@ -174,14 +191,14 @@ for (Disk disk : loadedImages) { if (disk.getDiskStorageType() == Disk.DiskStorageType.LUN || disk.isShareable()) { - attachDisk(disk); + attachDetachDisk(disk, actionType); } } } - private void attachDisk(Disk disk) { + private void attachDetachDisk(Disk disk, VdcActionType actionType) { runInternalAction( - VdcActionType.AttachDiskToVm, + actionType, new AttachDetachVmDiskParameters( getParameters().getNewVmGuid(), disk.getId(), -- To view, visit http://gerrit.ovirt.org/32673 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie2a8f4c35c68721e59c0b7e35c9148f148589794 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
