use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class RestartVdsCommand method wasSkippedDueToPolicy.
/**
* Determines according to the return status from the Ovirt command whether the fence-operation has been skipped due
* to policy.
*/
protected boolean wasSkippedDueToPolicy(ActionReturnValue result) {
boolean skipped = false;
if (result.getActionReturnValue() instanceof FenceOperationResult) {
FenceOperationResult fenceResult = result.getActionReturnValue();
skipped = fenceResult.getStatus() == Status.SKIPPED_DUE_TO_POLICY;
}
return skipped;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class SingleAgentFenceActionExecutor method changeStatus.
/**
* Executes start or stop fence operation using specified agent
*/
protected FenceOperationResult changeStatus(FenceActionType fenceAction) {
FenceAgentExecutor agentExecutor = createAgentExecutor();
FenceOperationResult statusResult = null;
// start at -1 because 1st fence attempt is regular and not a retry
int fenceRetries = -1;
do {
FenceOperationResult result = agentExecutor.fence(fenceAction, fenceAgent);
if (result.getStatus() == Status.SKIPPED_ALREADY_IN_STATUS) {
// action skipped already in status, so report it as success with correct power status
return new FenceOperationResult(Status.SUCCESS, fenceAction == FenceActionType.START ? PowerStatus.ON : PowerStatus.OFF);
} else if (result.getStatus() == Status.SKIPPED_DUE_TO_POLICY) {
// skipped due to policy is handled in caller
return result;
}
if (result.getStatus() == Status.SUCCESS) {
// fence operation was successful, verify if host power status changed
statusResult = waitForStatus(fenceAction);
if (isRequestedStatusAchieved(statusResult)) {
// requested host power status reached, end with success
return statusResult;
}
}
fenceRetries++;
} while (fenceRetries < allowedFenceActionRetries);
return new FenceOperationResult(Status.ERROR, // fail safe, at least one fence attempt should always be executed, so statusResult shouldn't be null
statusResult == null ? PowerStatus.UNKNOWN : statusResult.getPowerStatus(), "Allowed retries to verify host power status exceeded");
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class BackendHostResourceTest method testFenceStatus.
@Test
public void testFenceStatus() throws Exception {
FenceOperationResult retVal = new FenceOperationResult(FenceOperationResult.Status.SUCCESS, PowerStatus.ON);
setUpEntityQueryExpectations(QueryType.GetVdsFenceStatus, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, retVal);
Action action = new Action();
action.setFenceType(FenceType.STATUS.value());
verifyActionResponse(resource.fence(action));
PowerManagementStatus status = action.getPowerManagement().getStatus();
assertEquals(PowerManagementStatus.ON, status);
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceAgentModel method test.
/**
* Execute the fence agent test.
*/
public void test() {
validatePmModels();
if (!isValid()) {
return;
}
setMessage(ConstantsManager.getInstance().getConstants().testingInProgressItWillTakeFewSecondsPleaseWaitMsg());
getTestCommand().setIsExecutionAllowed(false);
Cluster cluster = getHost().getCluster().getSelectedItem();
GetFenceAgentStatusParameters param = new GetFenceAgentStatusParameters();
FenceAgent agent = new FenceAgent();
if (getHost().getHostId() != null) {
param.setVdsId(getHost().getHostId());
}
agent.setOrder(getOrder().getEntity());
agent.setIp(getManagementIp().getEntity());
agent.setType(getPmType().getSelectedItem());
agent.setUser(getPmUserName().getEntity());
agent.setPassword(getPmPassword().getEntity());
agent.setPort(getPmPort().getEntity());
agent.setOptionsMap(getPmOptionsMap());
param.setAgent(agent);
param.setStoragePoolId(cluster.getStoragePoolId() != null ? cluster.getStoragePoolId() : Guid.Empty);
param.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(getHost().getPmProxyPreferences()));
param.setVdsName(getHost().getName().getEntity());
param.setHostName(getHost().getHost().getEntity());
param.setClusterId(cluster.getId());
Frontend.getInstance().runQuery(QueryType.GetFenceAgentStatus, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
String msg;
if (returnValue == null) {
msg = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
} else {
FenceOperationResult result = returnValue.getReturnValue();
if (result.getStatus() == FenceOperationResult.Status.SUCCESS) {
msg = ConstantsManager.getInstance().getMessages().testSuccessfulWithPowerStatus(result.getPowerStatus() == PowerStatus.ON ? ConstantsManager.getInstance().getConstants().powerOn() : ConstantsManager.getInstance().getConstants().powerOff());
} else {
msg = ConstantsManager.getInstance().getMessages().testFailedWithErrorMsg(result.getMessage());
}
}
setMessage(msg);
getTestCommand().setIsExecutionAllowed(true);
}, true));
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceVdsVDSCommand method getReturnStatus.
@Override
protected Status getReturnStatus() {
Status status = new Status();
FenceOperationResult result = (FenceOperationResult) getReturnValue();
if (result == null) {
// unexpected error happened
status.code = 1;
status.message = "";
} else {
// status result from action result
status.code = result.getStatus() == FenceOperationResult.Status.ERROR ? 1 : 0;
status.message = result.getMessage();
}
return status;
}
Aggregations