Created
February 10, 2017 15:45
-
-
Save slaykovsky/f8c3a25c5b3580747e00b2402f70cbbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddFenceAgentCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddFenceAgentCommand.java | |
index ed54ded..3c634f0 100644 | |
--- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddFenceAgentCommand.java | |
+++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddFenceAgentCommand.java | |
@@ -1,13 +1,28 @@ | |
package org.ovirt.engine.core.bll; | |
+import javax.inject.Inject; | |
import org.ovirt.engine.core.bll.context.CommandContext; | |
import org.ovirt.engine.core.common.action.FenceAgentCommandParameterBase; | |
+import org.ovirt.engine.core.common.businessentities.Cluster; | |
+import org.ovirt.engine.core.common.businessentities.VDS; | |
import org.ovirt.engine.core.common.businessentities.pm.FenceAgent; | |
+import org.ovirt.engine.core.common.config.ConfigValues; | |
import org.ovirt.engine.core.common.errors.EngineMessage; | |
import org.ovirt.engine.core.compat.Guid; | |
+import org.ovirt.engine.core.compat.Regex; | |
+import org.ovirt.engine.core.dao.ClusterDao; | |
+import org.ovirt.engine.core.dao.VdsDao; | |
+import org.ovirt.engine.core.utils.pm.FenceConfigHelper; | |
+ | |
public class AddFenceAgentCommand<T extends FenceAgentCommandParameterBase> extends FenceAgentCommandBase { | |
+ @Inject | |
+ private VdsDao vdsDao; | |
+ | |
+ @Inject | |
+ private ClusterDao clusterDao; | |
+ | |
public AddFenceAgentCommand(FenceAgentCommandParameterBase parameters, CommandContext cmdContext) { | |
super(parameters, cmdContext); | |
} | |
@@ -18,6 +33,7 @@ public class AddFenceAgentCommand<T extends FenceAgentCommandParameterBase> exte | |
@Override | |
protected boolean validate() { | |
+ String clusterCompatibilityVersion; | |
if (getParameters() == null | |
|| getParameters().getAgent() == null | |
|| getParameters().getAgent().getIp() == null | |
@@ -27,6 +43,18 @@ public class AddFenceAgentCommand<T extends FenceAgentCommandParameterBase> exte | |
|| getParameters().getAgent().getUser() == null) { | |
return failValidation(EngineMessage.VDS_ADD_FENCE_AGENT_MANDATORY_PARAMETERS_MISSING); | |
} | |
+ | |
+ Guid vdsId = getParameters().getAgent().getHostId(); | |
+ VDS vds = vdsDao.get(vdsId); | |
+ Guid vdsClusterId = vds.getClusterId(); | |
+ Cluster cluster = clusterDao.get(vdsClusterId); | |
+ clusterCompatibilityVersion = cluster.getCompatibilityVersion().toString(); | |
+ | |
+ if (!Regex.isMatch(FenceConfigHelper.getFenceConfigurationValue(ConfigValues.VdsFenceType.name(), | |
+ clusterCompatibilityVersion), String.format("(,|^)%1$s(,|$)", getParameters().getAgent().getType()))) { | |
+ return failValidation(EngineMessage.ACTION_TYPE_FAILED_AGENT_NOT_SUPPORTED); | |
+ } | |
+ | |
return super.validate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment