use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class BackendHostResourceTest method testFenceStatusFailure.
@Test
public void testFenceStatusFailure() throws Exception {
FenceOperationResult retVal = new FenceOperationResult(FenceOperationResult.Status.ERROR, PowerStatus.UNKNOWN, "some_error");
setUpEntityQueryExpectations(QueryType.GetVdsFenceStatus, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, retVal);
Action action = new Action();
action.setFenceType(FenceType.STATUS.value());
Response response = resource.fence(action);
Action actionReturned = (Action) response.getEntity();
assertEquals(actionReturned.getStatus(), CreationStatus.FAILED.value());
assertNotNull(actionReturned.getFault());
assertEquals("some_error", actionReturned.getFault().getReason());
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class SingleAgentFenceActionExecutor method waitForStatus.
/**
* Executes status operation until requested host power status is reached or allowed number of retries exceeded
* to determine of start/stop fence operation was successful
*/
protected FenceOperationResult waitForStatus(FenceActionType fenceAction) {
FenceOperationResult statusResult = null;
// start at -1, because the 1st iteration is regular and not a retry
int statusRetries = -1;
int unknownStatusReceived = 0;
log.info("Waiting for host '{}' to reach status '{}'", fencedHost.getHostName(), requestedPowerStatus);
// Waiting before first attempt to check the host status.
// This is done because if we will attempt to get host status immediately
// in most cases it will not turn from on/off to off/on and we will need
// to wait a full cycle for it.
ThreadUtils.sleep(getSleepBeforeFirstAttempt());
while (statusRetries < allowedWaitForStatusRetries) {
log.info("Attempt {} to get host '{}' status", statusRetries + 2, fencedHost.getHostName());
statusResult = getStatus();
if (statusResult.getStatus() == Status.SUCCESS) {
if (statusResult.getPowerStatus() == PowerStatus.UNKNOWN) {
if (unknownStatusReceived < getUnknownResultLimit() && statusRetries < allowedWaitForStatusRetries) {
// unknown power status received, wait a while and retry
ThreadUtils.sleep(delayBetweenRetries);
statusRetries++;
unknownStatusReceived++;
} else {
// No need to retry, agent definitions are corrupted
log.error("Host '{}' PM Agent definitions are corrupted, aborting fence operation.", fencedHost.getHostName());
return new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN, statusResult.getMessage());
}
} else if (statusResult.getPowerStatus() == requestedPowerStatus) {
log.info("Host '{}' status is '{}'", fencedHost.getHostName(), requestedPowerStatus);
return new FenceOperationResult(Status.SUCCESS, requestedPowerStatus);
} else {
// host is still not in requested power status
statusRetries++;
if (statusRetries < allowedWaitForStatusRetries) {
ThreadUtils.sleep(delayBetweenRetries);
}
}
} else {
log.error("Failed to get host '{}' status.", fencedHost.getHostName());
return statusResult;
}
}
auditVerifyStatusRetryLimitExceeded(fenceAction);
return new FenceOperationResult(Status.ERROR, statusResult == null ? PowerStatus.UNKNOWN : statusResult.getPowerStatus(), statusResult == null ? "" : statusResult.getMessage());
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceVdsVDSCommand method isAlreadyInRequestedStatus.
/**
* Checks if Host is already in the requested status. If Host is Down and a Stop command is issued or if Host is Up
* and a Start command is issued command should do nothing.
*/
private boolean isAlreadyInRequestedStatus() {
FenceStatusReturn result = fenceNode(FenceActionType.STATUS);
FenceOperationResult actionResult = new FenceOperationResult(FenceActionType.STATUS, result.getStatus().code, result.getStatus().message, result.power, result.operationStatus);
return actionResult.getStatus() == FenceOperationResult.Status.SUCCESS && actionResult.getPowerStatus() == getRequestedPowerStatus(getParameters().getAction());
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceVdsVDSCommandTest method stopHostWithUnknownPowerStatus.
/**
* Test execution of stop action when host power status cannot be determined
*/
@Test
public void stopHostWithUnknownPowerStatus() {
setupCommand(setupCommandParams(FenceActionType.STOP));
setupBrokerResult(// result of STATUS action executed prior to STOP action
createBrokerResultMap(1, "", "unknown", null), // result of actual STOP action
createBrokerResultMap(0, "", "unknown", "initiated"));
command.execute();
FenceOperationResult result = (FenceOperationResult) command.getVDSReturnValue().getReturnValue();
assertEquals(Status.SUCCESS, result.getStatus());
assertEquals(PowerStatus.UNKNOWN, result.getPowerStatus());
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceVdsVDSCommandTest method stopHostWhichIsPoweredUp.
/**
* Test execution of stop action when host is powered up
*/
@Test
public void stopHostWhichIsPoweredUp() {
setupCommand(setupCommandParams(FenceActionType.STOP));
setupBrokerResult(// result of STATUS action executed prior to STOP action
createBrokerResultMap(0, "", "on", null), // result of actual STOP action
createBrokerResultMap(0, "", "unknown", "initiated"));
command.execute();
FenceOperationResult result = (FenceOperationResult) command.getVDSReturnValue().getReturnValue();
assertEquals(Status.SUCCESS, result.getStatus());
assertEquals(PowerStatus.UNKNOWN, result.getPowerStatus());
}
Aggregations