Arik Hadas has uploaded a new change for review.

Change subject: core: cleanup related to removal of memory volumes
......................................................................

core: cleanup related to removal of memory volumes

1. Move VmCommand#shouldRemoveMemoryVolumes method to
RemoveSnapshotCommand as it is used only by this class and rename it to
isMemoryVolumeRemoveable

2. Remove RemoveVmCommand#shouldRemoveMemoryVolumes method which is not
in use

Change-Id: I55df977799f79cf91defc111d32b7663a305e60b
Signed-off-by: Arik Hadas <aha...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java
3 files changed, 10 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/23221/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
index 40465f7..da927b9 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveSnapshotCommand.java
@@ -93,7 +93,7 @@
         final Snapshot snapshot = 
getSnapshotDao().get(getParameters().getSnapshotId());
 
         boolean snapshotHasImages = hasImages();
-        boolean removeSnapshotMemory = 
shouldRemoveMemorySnapshotVolumes(snapshot.getMemoryVolume());
+        boolean removeSnapshotMemory = 
isMemoryVolumeRemoveable(snapshot.getMemoryVolume());
 
         // If the VM hasn't got any images and memory - simply remove the 
snapshot.
         // No need for locking, VDSM tasks, and all that jazz.
@@ -118,6 +118,15 @@
         setSucceeded(true);
     }
 
+    /**
+     * There is a one to many relation between memory volumes and snapshots, 
so memory
+     * volumes should be removed only if the only snapshot that points to them 
is removed
+     */
+    protected boolean isMemoryVolumeRemoveable(String memoryVolume) {
+        return !memoryVolume.isEmpty() &&
+                
getDbFacade().getSnapshotDao().getNumOfSnapshotsByMemory(memoryVolume) == 1;
+    }
+
     private void removeMemory(final Snapshot snapshot) {
         boolean success = removeMemoryVolumes(snapshot.getMemoryVolume(), 
getActionType(), false);
         if (!success) {
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 c0ccd32..6cccb55 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
@@ -79,12 +79,6 @@
         setSucceeded(removeVm());
     }
 
-    @Override
-    protected boolean shouldRemoveMemorySnapshotVolumes(String memoryVolume) {
-        return !memoryVolume.isEmpty() &&
-                
getDbFacade().getSnapshotDao().getNumOfSnapshotsByMemory(memoryVolume) == 0;
-    }
-
     private boolean removeVm() {
         final List<DiskImage> diskImages = 
ImagesHandler.filterImageDisks(getVm().getDiskList(),
                 true,
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java
index b3f7d58..bfb07b1 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmCommand.java
@@ -198,15 +198,6 @@
         return new SnapshotsManager().removeSnapshots(getVmId());
     }
 
-    /**
-     * There is a one to many relation between memory volumes and snapshots, 
so memory
-     * volumes should be removed only if the only snapshot that points to them 
is removed
-     */
-    protected boolean shouldRemoveMemorySnapshotVolumes(String memoryVolume) {
-        return !memoryVolume.isEmpty() &&
-                
getDbFacade().getSnapshotDao().getNumOfSnapshotsByMemory(memoryVolume) == 1;
-    }
-
     protected void removeVmUsers() {
         List<TagsVmMap> all = 
getTagDao().getTagVmMapByVmIdAndDefaultTag(getVmId());
         for (TagsVmMap tagVm : all) {


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

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

Reply via email to