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

Change subject: core: FenceVdsVDSCommandParameters code cleanup
......................................................................

core: FenceVdsVDSCommandParameters code cleanup

1. Use FenceAgent class instead of its attributes
2. Code cleanup

Change-Id: I055276a4012180fda23bb2063c38df3bdd6ce876
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/FenceExecutor.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/FenceVdsVDSCommandParameters.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
3 files changed, 51 insertions(+), 67 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/61/38061/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
index 904393c..f294dc2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceExecutor.java
@@ -181,12 +181,12 @@
         return getBackend().getResourceManager()
                     .RunVdsCommand(
                             VDSCommandType.FenceVds,
-                        new FenceVdsVDSCommandParameters(proxyHost.getId(), 
_vds.getId(), agent.getIp(),
-                                String.valueOf(agent.getPort()),
-                                VdsFenceOptions.getRealAgent(agent.getType()),
-                                agent.getUser(),
-                                agent.getPassword(),
-                                getOptions(agent), action, fencingPolicy));
+                        new FenceVdsVDSCommandParameters(
+                                proxyHost.getId(),
+                                _vds.getId(),
+                                agent,
+                                action,
+                                fencingPolicy));
     }
 
     private void auditFenceAction(FenceActionType action, FenceAgent agent, 
VDS proxyHost) {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/FenceVdsVDSCommandParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/FenceVdsVDSCommandParameters.java
index a33f6ca..ba2118d 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/FenceVdsVDSCommandParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/FenceVdsVDSCommandParameters.java
@@ -1,70 +1,44 @@
 package org.ovirt.engine.core.common.vdscommands;
 
+import org.ovirt.engine.core.common.businessentities.FenceAgent;
 import org.ovirt.engine.core.common.businessentities.pm.FenceActionType;
 import org.ovirt.engine.core.common.businessentities.FencingPolicy;
 import org.ovirt.engine.core.compat.Guid;
 
 public class FenceVdsVDSCommandParameters extends 
VdsIdVDSCommandParametersBase {
-    public FenceVdsVDSCommandParameters(Guid vdsId, Guid targetVdsId, String 
ip, String port, String type, String user,
-            String password, String options, FenceActionType action, 
FencingPolicy fencingPolicy) {
-        super(vdsId);
-        _targetVdsId = targetVdsId;
-        _ip = ip;
-        _port = port;
-        _type = type;
-        _user = user;
-        _password = password;
-        _action = action;
-        _options = options;
+    private Guid targetVdsId;
+    private FenceAgent fenceAgent;
+    private FenceActionType action;
+    private FencingPolicy fencingPolicy;
+
+    private FenceVdsVDSCommandParameters() {
+        action = FenceActionType.RESTART;
+        fenceAgent = new FenceAgent();
+    }
+
+    public FenceVdsVDSCommandParameters(
+            Guid proxyVdsId,
+            Guid targetVdsId,
+            FenceAgent fenceAgent,
+            FenceActionType action,
+            FencingPolicy fencingPolicy) {
+        super(proxyVdsId);
+        this.targetVdsId = targetVdsId;
+        this.fenceAgent = fenceAgent;
+        this.action = action;
         this.fencingPolicy = fencingPolicy;
     }
 
-    private Guid _targetVdsId;
-    private String _ip;
-    private String _port;
-    private String _type;
-    private String _user;
-    private String _password;
-    private String _options;
-    private FenceActionType _action;
-
-    private FencingPolicy fencingPolicy;
-
     public Guid getTargetVdsID() {
-        return _targetVdsId;
+        return targetVdsId;
     }
 
-    public String getIp() {
-        return _ip;
-    }
-
-    public String getPort() {
-        return _port;
-    }
-
-    public String getType() {
-        return _type;
-    }
-
-    public String getUser() {
-        return _user;
-    }
-
-    public String getPassword() {
-        return _password;
-    }
-
-    public String getOptions() {
-        return _options;
+    public FenceAgent getFenceAgent() {
+        return fenceAgent;
     }
 
     public FenceActionType getAction() {
-        return _action;
-    }
-
-    public FenceVdsVDSCommandParameters() {
-        _options = "";
-        _action = FenceActionType.RESTART;
+        return action;
     }
 
     public FencingPolicy getFencingPolicy() {
@@ -73,9 +47,17 @@
 
     @Override
     public String toString() {
-        return String.format("%s, targetVdsId = %s, action = %s, ip = %s, port 
= %s, type = %s, user = %s, " +
-                "password = %s, options = '%s', policy = '%s'", 
super.toString(), getTargetVdsID(), getAction(),
-                getIp(), getPort(), getType(), getUser(), (getPassword() == 
null ? null : "******"), getOptions(),
+        return String.format(
+                "%s, targetVdsId = %s, action = %s, ip = %s, port = %s, type = 
%s, user = %s, "
+                        + "password = ***, options = '%s', policy = '%s'",
+                super.toString(),
+                getTargetVdsID(),
+                getAction(),
+                getFenceAgent().getIp(),
+                getFenceAgent().getPort(),
+                getFenceAgent().getType(),
+                getFenceAgent().getUser(),
+                getFenceAgent().getOptions(),
                 getFencingPolicy());
     }
 }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
index 920734d..0a7c635 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FenceVdsVDSCommand.java
@@ -171,16 +171,18 @@
 
     protected FenceStatusReturnForXmlRpc fenceNode(FenceActionType actionType, 
boolean applyFencingPolicy) {
         return getBroker().fenceNode(
-                getParameters().getIp(),
-                getParameters().getPort() == null ? "" : 
getParameters().getPort(),
-                getParameters().getType(),
-                getParameters().getUser(),
-                getParameters().getPassword(),
+                getParameters().getFenceAgent().getIp(),
+                getParameters().getFenceAgent().getPort() == null
+                        ? ""
+                        : getParameters().getFenceAgent().getPort().toString(),
+                getParameters().getFenceAgent().getType(),
+                getParameters().getFenceAgent().getUser(),
+                getParameters().getFenceAgent().getPassword(),
                 actionType.getValue(),
                 "",
                 getVdsFenceOptions(
-                        getParameters().getType(),
-                        getParameters().getOptions(),
+                        getParameters().getFenceAgent().getType(),
+                        getParameters().getFenceAgent().getOptions(),
                         
getProxyVds().getVdsGroupCompatibilityVersion().toString()),
                 applyFencingPolicy ? convertFencingPolicy() : null);
     }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I055276a4012180fda23bb2063c38df3bdd6ce876
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