Maor Lipchuk has uploaded a new change for review. Change subject: core: Support remove of VM with Cinder disks ......................................................................
core: Support remove of VM with Cinder disks Add a support for removeing a VM with Cinder disks Change-Id: I1bf8b7e54542bd0673c5c26e98fbe0335d74a79b Bug-Url: https://bugzilla.redhat.com/?????? Signed-off-by: Maor Lipchuk <mlipc...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java 1 file changed, 36 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/30/39230/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java index b5e4f9d..b0b1927 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import javax.enterprise.event.Event; import javax.inject.Inject; @@ -29,6 +31,7 @@ import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.LockProperties; import org.ovirt.engine.core.common.action.LockProperties.Scope; +import org.ovirt.engine.core.common.action.RemoveAllVmCinderDisksParameters; import org.ovirt.engine.core.common.action.RemoveAllVmImagesParameters; import org.ovirt.engine.core.common.action.RemoveMemoryVolumesParameters; import org.ovirt.engine.core.common.action.RemoveVmParameters; @@ -38,6 +41,7 @@ import org.ovirt.engine.core.common.asynctasks.EntityInfo; import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.network.VmNic; +import org.ovirt.engine.core.common.businessentities.storage.CinderDisk; import org.ovirt.engine.core.common.businessentities.storage.Disk; import org.ovirt.engine.core.common.businessentities.storage.DiskImage; import org.ovirt.engine.core.common.businessentities.storage.ImageStatus; @@ -55,6 +59,8 @@ @Inject private Event<Guid> vmDeleted; + + private Collection<CinderDisk> failedRemoveCinderDisks = null; /** * Constructor for command creation when compensation is applied on startup @@ -123,8 +129,12 @@ } }); - if (getParameters().isRemoveDisks() && !diskImages.isEmpty()) { - Collection<DiskImage> unremovedDisks = (Collection<DiskImage>)removeVmImages(diskImages).getActionReturnValue(); + Collection<DiskImage> unremovedDisks = Collections.emptyList(); + if (getParameters().isRemoveDisks()) { + if (!diskImages.isEmpty()) { + unremovedDisks = (Collection<DiskImage>) removeVmImages(diskImages).getActionReturnValue(); + } + unremovedDisks.addAll(failedRemoveCinderDisks); if (!unremovedDisks.isEmpty()) { processUnremovedDisks(unremovedDisks); return false; @@ -305,6 +315,7 @@ protected void removeVmFromDb() { removeLunDisks(); + removeCinderDisks(); removeVmUsers(); removeVmNetwork(); removeVmSnapshots(); @@ -323,6 +334,27 @@ } } + /** + * The following method will perform a removing of all cinder disks from vm. These is only DB operation + */ + private void removeCinderDisks() { + if (getParameters().isRemoveDisks()) { + List<CinderDisk> cinderDisks = + ImagesHandler.filterDiskBasedOnCinder(getVm().getDiskMap().values()); + RemoveAllVmCinderDisksParameters param = new RemoveAllVmCinderDisksParameters(getVmId(), cinderDisks); + Future<VdcReturnValueBase> future = CommandCoordinatorUtil.executeAsyncCommand( + VdcActionType.RemoveAllVmCinderDisks, + withRootCommandInfo(param, getActionType()), + cloneContextAndDetachFromParent()); + try { + failedRemoveCinderDisks = future.get().getActionReturnValue(); + } catch (InterruptedException | ExecutionException e) { + failedRemoveCinderDisks.addAll(cinderDisks); + log.error("Exception", e); + } + } + } + @Override protected void endVmCommand() { // no audit log print here as the vm was already removed during the execute phase. @@ -331,8 +363,8 @@ setSucceeded(true); } - private void processUnremovedDisks(Collection<DiskImage> diskImages) { - List<String> disksLeftInVm = new ArrayList<String>(); + private void processUnremovedDisks(Collection<? extends DiskImage> diskImages) { + List<String> disksLeftInVm = new ArrayList<>(); for (DiskImage diskImage : diskImages) { disksLeftInVm.add(diskImage.getDiskAlias()); } -- To view, visit https://gerrit.ovirt.org/39230 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1bf8b7e54542bd0673c5c26e98fbe0335d74a79b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches