use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class VdsEventListener method onMomPolicyChange.
// TODO asynch event handler - design infra code to allow async events in segregated thread
public void onMomPolicyChange(@Observes @MomPolicyUpdate final Cluster cluster) {
if (cluster == null) {
return;
}
List<VDS> activeHostsInCluster = vdsDao.getAllForClusterWithStatus(cluster.getId(), VDSStatus.Up);
// collect all Active hosts into a callable list
List<Callable<Object>> callables = new LinkedList<>();
for (final VDS vds : activeHostsInCluster) {
callables.add(() -> {
try {
resourceManagerProvider.get().runVdsCommand(VDSCommandType.SetMOMPolicyParameters, new MomPolicyVDSParameters(vds, cluster.isEnableBallooning(), cluster.isEnableKsm(), cluster.isKsmMergeAcrossNumaNodes()));
} catch (EngineException e) {
log.error("Could not update MoM policy on host '{}'", vds.getName());
}
return null;
});
}
// run all VDSCommands concurrently with executor
if (callables.size() > 0) {
ThreadPoolUtil.invokeAll(callables);
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class LoginOnBehalfCommand method getDbUserForPrincipalName.
private DbUser getDbUserForPrincipalName(String principalName, String authzName) {
Map<String, Object> response = SsoOAuthServiceUtils.fetchPrincipalRecord(getSessionDataContainer().getSsoAccessToken(getParameters().getSessionId()), authzName, principalName, false, false);
ExtMap principalRecord = null;
if (response.containsKey("result")) {
Collection<ExtMap> records = (Collection<ExtMap>) response.get("result");
if (!records.isEmpty()) {
principalRecord = records.iterator().next();
}
}
if (principalRecord == null) {
throw new EngineException(EngineError.PRINCIPAL_NOT_FOUND, String.format("%s in domain '%s", principalName, authzName));
}
DbUser user = new DbUser(directoryUtils.mapPrincipalRecordToDirectoryUser(authzName, principalRecord));
user.setId(Guid.newGuid());
return user;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class ConvertVmCommand method executeVmCommand.
@Override
protected void executeVmCommand() {
try {
VDSReturnValue retValue = runVdsCommand();
if (retValue.getSucceeded()) {
monitorV2VJob(JobStatus.WAIT_FOR_START);
setSucceeded(true);
} else {
log.error("Failed to convert VM");
setCommandStatus(CommandStatus.FAILED);
}
} catch (EngineException e) {
log.error("Failed to convert VM", e);
setCommandStatus(CommandStatus.FAILED);
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method executeCommand.
@Override
protected void executeCommand() {
if (noChangesDetected()) {
log.info("No changes were detected in setup networks for host '{}' (ID: '{}')", getVdsName(), getVdsId());
setSucceeded(true);
return;
}
try (EngineLock monitoringLock = acquireMonitorLock("Host setup networks")) {
int timeout = getSetupNetworksTimeout();
FutureVDSCall<VDSReturnValue> setupNetworksTask = invokeSetupNetworksCommand(timeout);
try {
VDSReturnValue retVal = setupNetworksTask.get(timeout, TimeUnit.SECONDS);
if (retVal != null) {
if (!retVal.getSucceeded() && retVal.getVdsError() == null && getParameters().rollbackOnFailure()) {
throw new EngineException(EngineError.SETUP_NETWORKS_ROLLBACK, retVal.getExceptionString());
}
VdsHandler.handleVdsResult(retVal);
if (retVal.getSucceeded()) {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetCapabilities, new VdsIdAndVdsVDSCommandParametersBase(getVds()));
VDS updatedHost = (VDS) returnValue.getReturnValue();
persistNetworkChanges(updatedHost);
}
setSucceeded(true);
}
} catch (TimeoutException e) {
log.debug("Host Setup networks command timed out for {} seconds", timeout);
}
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class VdsCommandsHelper method runVdsCommand.
private VDSReturnValue runVdsCommand(VDSCommandType vdsCommandType, VdsIdVDSCommandParametersBase params, Guid storagePoolId, CommandBase<?> cmd, boolean performFailover) {
Set<Guid> executedHosts = new HashSet<>();
VDSReturnValue returnValue = null;
if (params.getVdsId() == null) {
chooseHostForExecution(params, storagePoolId, cmd, Collections.emptyList());
if (params.getVdsId() == null) {
throw new EngineException(EngineError.RESOURCE_MANAGER_VDS_NOT_FOUND, "No host was found to perform the operation");
}
}
int attempts = 0;
while (attempts <= Config.<Integer>getValue(ConfigValues.HsmCommandFailOverRetries)) {
try {
attempts++;
returnValue = resourceManager.runVdsCommand(vdsCommandType, params);
if (returnValue != null && returnValue.getSucceeded()) {
return returnValue;
}
} catch (EngineException e) {
returnValue = e.getVdsReturnValue();
}
executedHosts.add(params.getVdsId());
if (!performFailover || (returnValue != null && !returnValue.isCanTryOnDifferentVds())) {
break;
}
chooseHostForExecution(params, storagePoolId, cmd, executedHosts);
if (params.getVdsId() == null) {
break;
}
}
return VdsHandler.handleVdsResult(returnValue);
}
Aggregations