Search in sources :

Example 11 with FenceOperationResult

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;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 12 with FenceOperationResult

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);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Example 13 with FenceOperationResult

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);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Example 14 with FenceOperationResult

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);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Example 15 with FenceOperationResult

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);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Aggregations

FenceOperationResult (org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult)58 Test (org.junit.Test)43 ArrayList (java.util.ArrayList)2 Action (org.ovirt.engine.api.model.Action)2 FenceAgent (org.ovirt.engine.core.common.businessentities.pm.FenceAgent)2 PowerStatus (org.ovirt.engine.core.common.businessentities.pm.PowerStatus)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 Response (javax.ws.rs.core.Response)1 PowerManagement (org.ovirt.engine.api.model.PowerManagement)1 PowerManagementStatus (org.ovirt.engine.api.model.PowerManagementStatus)1 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)1 HostFenceActionExecutor (org.ovirt.engine.core.bll.pm.HostFenceActionExecutor)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1