Martin Peřina has uploaded a new change for review.

Change subject: core: Move all PM related commands into bll.pm
......................................................................

core: Move all PM related commands into bll.pm

1. Moves following commands into bll.pm subpackage:

   FenceVdsBaseCommand
   RestartVdsCommand
   SshSoftFencingCommand
   StartVdsCommand
   StopVdsCommand
   VdsKdumpDetectionCommand
   VdsNotRespondingTreatmentCommand

2. Adds bll.pm subpackage to packages which contain commands

3. Fixes StartVdsCommandTest

Change-Id: I6651532ae9e753f1d4b1425b99a39f0562a61937
Bug-Url: https://bugzilla.redhat.com/1182510
Signed-off-by: Martin Perina <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/FenceVdsBaseCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/PmHealthCheckManager.java
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/RestartVdsCommand.java
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/SshSoftFencingCommand.java
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StartVdsCommand.java
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StopVdsCommand.java
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsKdumpDetectionCommand.java
R 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsNotRespondingTreatmentCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
R 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/StartVdsCommandTest.java
11 files changed, 39 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/39839/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
index ef64fa2..01436fd 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandsFactory.java
@@ -43,6 +43,7 @@
         "org.ovirt.engine.core.bll.network.template",
         "org.ovirt.engine.core.bll.numa.host",
         "org.ovirt.engine.core.bll.numa.vm",
+        "org.ovirt.engine.core.bll.pm",
         "org.ovirt.engine.core.bll.provider",
         "org.ovirt.engine.core.bll.provider.network",
         "org.ovirt.engine.core.bll.qos",
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/FenceVdsBaseCommand.java
similarity index 95%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/FenceVdsBaseCommand.java
index b642294..367e766 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/FenceVdsBaseCommand.java
@@ -1,12 +1,15 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
+import org.ovirt.engine.core.bll.Backend;
+import org.ovirt.engine.core.bll.LockMessagesMatchUtil;
+import org.ovirt.engine.core.bll.VdsCommand;
 import org.ovirt.engine.core.bll.context.CommandContext;
-import org.ovirt.engine.core.bll.pm.HostFenceActionExecutor;
+import org.ovirt.engine.core.bll.interfaces.BackendInternal;
 import org.ovirt.engine.core.bll.validator.FenceValidator;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.FenceVdsActionParameters;
@@ -195,6 +198,12 @@
         return getVmDAO().getAllRunningForVds(getVdsId());
     }
 
+    // Method needs to be overridden to allow mocking in bll.pm subpackage
+    @Override
+    protected BackendInternal getBackend() {
+        return super.getBackend();
+    }
+
     /**
      * get the event to look for in canDoAction() , if we requested to start 
Host then we should look when we stopped it
      * and vice
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/PmHealthCheckManager.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/PmHealthCheckManager.java
index 1c57e5a..0b38e08 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/PmHealthCheckManager.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/PmHealthCheckManager.java
@@ -11,7 +11,6 @@
 import javax.inject.Singleton;
 
 import org.ovirt.engine.core.bll.Backend;
-import org.ovirt.engine.core.bll.RestartVdsCommand;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.bll.pm.PowerManagementHelper.AgentsIterator;
 import org.ovirt.engine.core.common.AuditLogType;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/RestartVdsCommand.java
similarity index 97%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/RestartVdsCommand.java
index ee455d0..7fbc747 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/RestartVdsCommand.java
@@ -1,4 +1,4 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
 import static 
org.ovirt.engine.core.common.AuditLogType.SYSTEM_FAILED_VDS_RESTART;
 import static org.ovirt.engine.core.common.AuditLogType.SYSTEM_VDS_RESTART;
@@ -13,8 +13,10 @@
 import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
+import org.ovirt.engine.core.bll.LockMessagesMatchUtil;
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.bll.VdsCommand;
 import org.ovirt.engine.core.bll.context.CommandContext;
-import org.ovirt.engine.core.bll.pm.HostFenceActionExecutor;
 import org.ovirt.engine.core.bll.validator.FenceValidator;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.FenceVdsActionParameters;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SshSoftFencingCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/SshSoftFencingCommand.java
similarity index 96%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SshSoftFencingCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/SshSoftFencingCommand.java
index 4ce0090..cfab20c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SshSoftFencingCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/SshSoftFencingCommand.java
@@ -1,10 +1,12 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.bll.VdsCommand;
+import org.ovirt.engine.core.bll.VdsValidator;
 import org.ovirt.engine.core.bll.context.CommandContext;
-import org.ovirt.engine.core.bll.pm.HostFenceActionExecutor;
 import org.ovirt.engine.core.bll.utils.EngineSSHClient;
 import org.ovirt.engine.core.common.action.VdsActionParameters;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StartVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StartVdsCommand.java
similarity index 96%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StartVdsCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StartVdsCommand.java
index 0e421f7..40fef1a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StartVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StartVdsCommand.java
@@ -1,5 +1,7 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.bll.RestartVdsVmsOperation;
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.FenceVdsActionParameters;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StopVdsCommand.java
similarity index 97%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StopVdsCommand.java
index 49aa614..81c67a4 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/StopVdsCommand.java
@@ -1,9 +1,11 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
 import static 
org.ovirt.engine.core.common.errors.VdcBllMessages.VAR__ACTION__STOP;
 
 import java.util.List;
 
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.bll.RestartVdsVmsOperation;
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.FenceVdsActionParameters;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsKdumpDetectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsKdumpDetectionCommand.java
similarity index 97%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsKdumpDetectionCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsKdumpDetectionCommand.java
index f22c9ec..57857a6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsKdumpDetectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsKdumpDetectionCommand.java
@@ -1,9 +1,12 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
 import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
 
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.bll.RestartVdsVmsOperation;
+import org.ovirt.engine.core.bll.VdsCommand;
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.ExternalVariable;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsNotRespondingTreatmentCommand.java
similarity index 98%
rename from 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
rename to 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsNotRespondingTreatmentCommand.java
index 3b8287c..42e2adc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/pm/VdsNotRespondingTreatmentCommand.java
@@ -1,4 +1,4 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
 import java.util.HashMap;
 import java.util.List;
@@ -6,6 +6,8 @@
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang.ObjectUtils;
+import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.bll.VdsValidator;
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.bll.job.ExecutionContext;
 import org.ovirt.engine.core.bll.validator.FenceValidator;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
index 2565fed..ce977cd 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/FenceVdsManualyCommand.java
@@ -4,8 +4,8 @@
 import java.util.List;
 import java.util.Map;
 
-import org.ovirt.engine.core.bll.FenceVdsBaseCommand;
 import org.ovirt.engine.core.bll.context.CommandContext;
+import org.ovirt.engine.core.bll.pm.FenceVdsBaseCommand;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
@@ -37,7 +37,7 @@
  * This command should be run mutually exclusive from other fence actions to 
prevent same action or other fence actions
  * to clear the VMs and start them.
  *
- * @see org.ovirt.engine.core.bll.RestartVdsCommand
+ * @see RestartVdsCommand
  */
 public class FenceVdsManualyCommand<T extends FenceVdsManualyParameters> 
extends StorageHandlingCommandBase<T> {
     private final VDS _problematicVds;
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/StartVdsCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/StartVdsCommandTest.java
similarity index 97%
rename from 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/StartVdsCommandTest.java
rename to 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/StartVdsCommandTest.java
index 3463d98..4d997da 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/StartVdsCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/StartVdsCommandTest.java
@@ -1,4 +1,4 @@
-package org.ovirt.engine.core.bll;
+package org.ovirt.engine.core.bll.pm;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -21,8 +21,8 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.ovirt.engine.core.bll.DbDependentTestBase;
 import org.ovirt.engine.core.bll.interfaces.BackendInternal;
-import org.ovirt.engine.core.bll.pm.HostFenceActionExecutor;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.FenceVdsActionParameters;
 import org.ovirt.engine.core.common.businessentities.AuditLog;
@@ -202,8 +202,8 @@
     public void onSuccessReturnValueOk() {
         mockExecutor(true);
         command.executeCommand();
-        assertTrue(command.getSucceeded());
-        Object commandReturnValue = command.getActionReturnValue();
+        assertTrue(command.getReturnValue().getSucceeded());
+        Object commandReturnValue = 
command.getReturnValue().getActionReturnValue();
         assertNotNull(commandReturnValue);
         assertTrue(commandReturnValue instanceof FenceOperationResult);
         FenceOperationResult commandReturnValueCasted = (FenceOperationResult) 
commandReturnValue;


-- 
To view, visit https://gerrit.ovirt.org/39839
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to