use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceAgentExecutor method fence.
/**
* Executes specified fence action using specified agent
*
* @param action
* specified fence action
* @param agent
* specified fence agent
* @return result of fence operation
*/
public FenceOperationResult fence(FenceActionType action, FenceAgent agent) {
FenceOperationResult result;
VDS proxyHost = getProxyLocator().findProxyHost(isRetryEnabled(action));
if (proxyHost == null) {
return new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN, String.format("Failed to run %s on host '%s'. No other host was available to serve as proxy for the operation.", getActionText(action), fencedHost.getHostName()));
}
try {
result = executeFenceAction(action, agent, proxyHost);
if (result.getStatus() == Status.ERROR) {
log.warn("Fence action failed using proxy host '{}', trying another proxy", proxyHost.getHostName());
VDS alternativeProxy = getProxyLocator().findProxyHost(isRetryEnabled(action), proxyHost.getId());
if (alternativeProxy != null) {
result = executeFenceAction(action, agent, alternativeProxy);
} else {
log.warn("Failed to find another proxy to re-run failed fence action, " + "retrying with the same proxy '{}'", proxyHost.getHostName());
result = executeFenceAction(action, agent, proxyHost);
}
}
} catch (EngineException e) {
log.debug("Exception", e);
result = new FenceOperationResult(FenceOperationResult.Status.ERROR, PowerStatus.UNKNOWN, e.getMessage());
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class ConcurrentAgentsFenceActionExecutorTest method failedStatusWhenAllAgentsFailed.
/**
* Test failed status action, when all agents failed to get status
*/
@Test
public void failedStatusWhenAllAgentsFailed() {
FenceOperationResult expectedResult = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN);
mockSingleAgentResult(singleExecutor1, new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN));
mockSingleAgentResult(singleExecutor2, new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN));
FenceOperationResult result = executor.fence(FenceActionType.STATUS);
validateResult(expectedResult, result);
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class ConcurrentAgentsFenceActionExecutorTest method statusOnWhenOneReportsOn.
/**
* Test status action with power on result, when one agent reports power on
*/
@Test
public void statusOnWhenOneReportsOn() {
FenceOperationResult expectedResult = new FenceOperationResult(Status.SUCCESS, PowerStatus.ON);
mockSingleAgentResult(singleExecutor1, new FenceOperationResult(Status.SUCCESS, PowerStatus.OFF));
mockSingleAgentResult(singleExecutor2, new FenceOperationResult(Status.SUCCESS, PowerStatus.ON));
FenceOperationResult result = executor.fence(FenceActionType.STATUS);
validateResult(expectedResult, result);
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class ConcurrentAgentsFenceActionExecutorTest method failedStopWhenOneSuccessfulAndAnotherFailed.
/**
* Test failed stop action, when one agent was successful and another failed
*/
@Test
public void failedStopWhenOneSuccessfulAndAnotherFailed() {
FenceOperationResult expectedResult = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN);
mockSingleAgentResult(singleExecutor1, new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN));
mockSingleAgentResult(singleExecutor2, new FenceOperationResult(Status.SUCCESS, PowerStatus.OFF));
FenceOperationResult result = executor.fence(FenceActionType.STOP);
validateResult(expectedResult, result);
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class ConcurrentAgentsFenceActionExecutorTest method failedStopWhenAllAgentsFailed.
/**
* Test failed stop action, when all agents failed
*/
@Test
public void failedStopWhenAllAgentsFailed() {
FenceOperationResult expectedResult = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN);
mockSingleAgentResult(singleExecutor1, new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN));
mockSingleAgentResult(singleExecutor2, new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN));
FenceOperationResult result = executor.fence(FenceActionType.STOP);
validateResult(expectedResult, result);
}
Aggregations