Sergey Gotliv has uploaded a new change for review.

Change subject: engine: Cleanup of HotPlugDiskToVmCommand
......................................................................

engine: Cleanup of HotPlugDiskToVmCommand

1. Making class member private instead of protected
2. Replacing deprecated message with more specific one
3. Simplifing CDA

Change-Id: I2cdc4e19da8768af9cd6659763af622b3e630e1d
Signed-off-by: Sergey Gotliv <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugDiskToVmCommand.java
1 file changed, 16 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/19302/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugDiskToVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugDiskToVmCommand.java
index 00096dc..b6d9da5 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugDiskToVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HotPlugDiskToVmCommand.java
@@ -25,7 +25,7 @@
 @LockIdNameAttribute
 public class HotPlugDiskToVmCommand<T extends HotPlugDiskToVmParameters> 
extends AbstractDiskVmCommand<T> {
 
-    protected Disk disk;
+    private Disk disk;
     private VmDevice oldVmDevice;
 
     public HotPlugDiskToVmCommand(T parameters) {
@@ -67,31 +67,27 @@
     }
 
     protected StorageDomainValidator getStorageDomainValidator(StorageDomain 
storageDomain) {
-        StorageDomainValidator storageDomainValidator = new 
StorageDomainValidator(storageDomain);
-        return storageDomainValidator;
+        return new StorageDomainValidator(storageDomain);
     }
 
     private boolean checkCanPerformPlugUnPlugDisk() {
-        boolean returnValue = true;
         if (getVm().getStatus().isUpOrPaused()) {
             setVdsId(getVm().getRunOnVds());
-            returnValue =
-                    isHotPlugSupported() && isOsSupportingHotPlug()
-                            && isInterfaceSupportedForPlugUnPlug(disk);
-        }
-        if (returnValue) {
-            oldVmDevice =
-                    getVmDeviceDao().get(new VmDeviceId(disk.getId(), 
getVmId()));
-            if (getPlugAction() == VDSCommandType.HotPlugDisk && 
oldVmDevice.getIsPlugged()) {
-                returnValue = false;
-                
addCanDoActionMessage(VdcBllMessages.HOT_PLUG_DISK_IS_NOT_UNPLUGGED);
-            }
-            if (getPlugAction() == VDSCommandType.HotUnPlugDisk && 
!oldVmDevice.getIsPlugged()) {
-                returnValue = false;
-                
addCanDoActionMessage(VdcBllMessages.HOT_UNPLUG_DISK_IS_NOT_PLUGGED);
+            if (!isHotPlugSupported() || !isOsSupportingHotPlug() || 
!isInterfaceSupportedForPlugUnPlug(disk)) {
+                return false;
             }
         }
-        return returnValue;
+
+        oldVmDevice = getVmDeviceDao().get(new VmDeviceId(disk.getId(), 
getVmId()));
+        if (getPlugAction() == VDSCommandType.HotPlugDisk && 
oldVmDevice.getIsPlugged()) {
+            return  
failCanDoAction(VdcBllMessages.HOT_PLUG_DISK_IS_NOT_UNPLUGGED);
+        }
+
+        if (getPlugAction() == VDSCommandType.HotUnPlugDisk && 
!oldVmDevice.getIsPlugged()) {
+            return  
failCanDoAction(VdcBllMessages.HOT_UNPLUG_DISK_IS_NOT_PLUGGED);
+        }
+
+        return true;
     }
 
     protected VDSCommandType getPlugAction() {
@@ -128,7 +124,7 @@
     @Override
     protected Map<String, Pair<String, String>> getSharedLocks() {
         return Collections.singletonMap(getVmId().toString(),
-                LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM, 
VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
+                LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM, 
VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_LOCKED));
     }
 
     @Override


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cdc4e19da8768af9cd6659763af622b3e630e1d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Sergey Gotliv <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to