use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class StartVdsCommandTest method onSuccessReturnValueOk.
/**
* This test verifies that when the fence operation is successful, the return value contains all that is should:
* succeeded=true, the agents used, and the object returned.
*/
@Test
public void onSuccessReturnValueOk() {
mockExecutor(true);
doNothing().when(command).teardown();
command.executeCommand();
assertTrue(command.getReturnValue().getSucceeded());
Object commandReturnValue = command.getReturnValue().getActionReturnValue();
assertNotNull(commandReturnValue);
assertTrue(commandReturnValue instanceof FenceOperationResult);
FenceOperationResult commandReturnValueCasted = (FenceOperationResult) commandReturnValue;
assertEquals(Status.SUCCESS, commandReturnValueCasted.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class StartVdsCommandTest method mockExecutor.
private void mockExecutor(boolean success) {
FenceOperationResult result;
if (success) {
result = new FenceOperationResult(Status.SUCCESS, PowerStatus.ON);
} else {
result = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN);
}
doReturn(result).when(executor).fence(any());
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceAgentExecutor method executeFenceAction.
protected FenceOperationResult executeFenceAction(FenceActionType action, FenceAgent agent, VDS proxyHost) {
FenceAgent realAgent = createRealAgent(agent, proxyHost);
auditFenceActionExecution(action, realAgent, proxyHost);
VDSReturnValue retVal = resourceManager.runVdsCommand(VDSCommandType.FenceVds, new FenceVdsVDSCommandParameters(proxyHost.getId(), fencedHost.getId(), realAgent, action, convertFencingPolicy(proxyHost)));
FenceOperationResult result = (FenceOperationResult) retVal.getReturnValue();
log.debug("Result of '{}' fence action: {}", result);
if (result == null) {
log.error("FenceVdsVDSCommand finished with null return value: succeeded={}, exceptionString='{}'", retVal.getSucceeded(), retVal.getExceptionString());
log.debug("Exception", retVal.getExceptionObject());
result = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN, retVal.getExceptionString());
}
if (result.getStatus() == Status.ERROR) {
auditFenceActionFailure(action, realAgent, proxyHost);
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceVdsBaseCommand method executeCommand.
@Override
protected void executeCommand() {
log.info("Power-Management: {} of host '{}' initiated.", getAction(), getVdsName());
audit(AuditLogType.FENCE_OPERATION_STARTED);
VDSStatus lastStatus = getVds().getStatus();
FenceOperationResult result = null;
try {
setup();
result = createHostFenceActionExecutor(getVds(), getParameters().getFencingPolicy()).fence(getAction());
handleResult(result);
if (getSucceeded()) {
log.info("Power-Management: {} host '{}' succeeded.", getAction(), getVdsName());
audit(AuditLogType.FENCE_OPERATION_SUCCEEDED);
} else {
log.info("Power-Management: {} host '{}' failed.", getAction(), getVdsName());
audit(AuditLogType.FENCE_OPERATION_FAILED);
}
} finally {
if (!getSucceeded()) {
setStatus(lastStatus);
if (result != null && result.getStatus() != Status.SKIPPED_DUE_TO_POLICY) {
// show alert only if command was not skipped due to fencing policy
alertIfPowerManagementOperationFailed();
}
throw new EngineException(EngineError.VDS_FENCE_OPERATION_FAILED);
} else {
teardown();
}
}
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class HostFenceActionExecutor method fence.
/**
* Executes specified fence action using specified fence agents
*/
protected FenceOperationResult fence(FenceActionType fenceAction, List<FenceAgent> fenceAgents) {
PowerManagementHelper.AgentsIterator iterator = createFenceAgentsIterator(fenceAgents);
FenceOperationResult result = null;
while (iterator.hasNext()) {
result = createFenceActionExecutor(iterator.next()).fence(fenceAction);
if (result.getStatus() == Status.SUCCESS) {
break;
}
}
return result;
}
Aggregations