use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceVdsVDSCommand method executeVdsBrokerCommand.
@Override
protected void executeVdsBrokerCommand() {
// ignore starting already started host or stopping already stopped host.
if (getParameters().getAction() == FenceActionType.STATUS || !isAlreadyInRequestedStatus()) {
FenceStatusReturn result = fenceNode(getParameters().getAction());
FenceOperationResult actionResult = new FenceOperationResult(getParameters().getAction(), result.getStatus().code, result.getStatus().message, result.power, result.operationStatus);
setReturnValue(actionResult);
getVDSReturnValue().setSucceeded(actionResult.getStatus() != FenceOperationResult.Status.ERROR);
if (getParameters().getAction() == FenceActionType.STATUS && actionResult.getPowerStatus() == PowerStatus.UNKNOWN && !getParameters().getTargetVdsID().equals(Guid.Empty)) {
alertPowerManagementStatusFailed(actionResult.getMessage());
}
} else {
// start/stop action was skipped, host is already turned on/off
alertActionSkippedAlreadyInStatus();
getVDSReturnValue().setSucceeded(true);
setReturnValue(new FenceOperationResult(FenceOperationResult.Status.SKIPPED_ALREADY_IN_STATUS, PowerStatus.UNKNOWN));
}
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class FenceVdsVDSCommandTest method stopHostWhichIsPoweredDown.
/**
* Test execution of stop action when host is powered down
*/
@Test
public void stopHostWhichIsPoweredDown() {
setupCommand(setupCommandParams(FenceActionType.STOP));
setupBrokerResult(// result of STATUS action executed prior to STOP action
createBrokerResultMap(0, "", "off", null));
command.execute();
FenceOperationResult result = (FenceOperationResult) command.getVDSReturnValue().getReturnValue();
assertEquals(Status.SKIPPED_ALREADY_IN_STATUS, 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 stopHostSkippedDueToFencingPolicy.
/**
* Test execution of stop action when fencing policy forbids stopping host still connected to storage, so stopping
* the host is skipped
*/
@Test
public void stopHostSkippedDueToFencingPolicy() {
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", "skipped"));
command.execute();
FenceOperationResult result = (FenceOperationResult) command.getVDSReturnValue().getReturnValue();
assertEquals(Status.SKIPPED_DUE_TO_POLICY, 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 failedGetStatus.
/**
* Tests result of failed get power status of host
*/
@Test
public void failedGetStatus() {
String agentMessage = "Test failed, status unknown";
setupCommand(setupCommandParams(FenceActionType.STATUS));
setupBrokerResult(createBrokerResultMap(1, agentMessage, "unknown", null));
command.execute();
FenceOperationResult result = (FenceOperationResult) command.getVDSReturnValue().getReturnValue();
assertEquals(Status.ERROR, result.getStatus());
assertEquals(PowerStatus.UNKNOWN, result.getPowerStatus());
assertEquals(agentMessage, result.getMessage());
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult in project ovirt-engine by oVirt.
the class ConcurrentAgentsFenceActionExecutor method fenceConcurrently.
/**
* Executes specified fence action on all fence agents concurrently
*/
protected FenceOperationResult fenceConcurrently(FenceActionType fenceAction) {
List<FenceOperationResult> results = new ArrayList<>(fenceAgents.size());
FenceOperationResult taskResult;
ExecutorCompletionService<FenceOperationResult> tasksExecutor = ThreadPoolUtil.createCompletionService();
List<Future<FenceOperationResult>> futures = ThreadPoolUtil.submitTasks(tasksExecutor, createTasks(fenceAction));
for (int i = 0; i < fenceAgents.size(); ++i) {
try {
taskResult = tasksExecutor.take().get();
} catch (ExecutionException | InterruptedException e) {
taskResult = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN, e.getMessage());
log.error("Error getting task result: {}", e.getMessage());
log.debug("Exception", e);
}
results.add(taskResult);
if (tasksProcessor.isGoalReached(taskResult)) {
// action goal is reach, cancel all remaining tasks
for (Future<FenceOperationResult> future : futures) {
future.cancel(true);
}
break;
}
}
return tasksProcessor.createActionResult(results);
}
Aggregations