use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class SetHaMaintenanceCommand method executeCommand.
@Override
protected void executeCommand() {
boolean succeeded = false;
SetHaMaintenanceParameters params = getParameters();
try {
succeeded = runVdsCommand(VDSCommandType.SetHaMaintenanceMode, new SetHaMaintenanceModeVDSCommandParameters(getVds(), params.getMode(), params.getIsEnabled())).getSucceeded();
} catch (EngineException e) {
log.error("Could not {} {} Hosted Engine HA maintenance mode on host '{}'", params.getIsEnabled() ? "enable" : "disable", params.getMode().name().toLowerCase(), getVdsName());
}
getReturnValue().setSucceeded(succeeded);
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class FenceAgentExecutor method fence.
/**
* Executes specified fence action using specified agent
*
* @param action
* specified fence action
* @param agent
* specified fence agent
* @return result of fence operation
*/
public FenceOperationResult fence(FenceActionType action, FenceAgent agent) {
FenceOperationResult result;
VDS proxyHost = getProxyLocator().findProxyHost(isRetryEnabled(action));
if (proxyHost == null) {
return new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN, String.format("Failed to run %s on host '%s'. No other host was available to serve as proxy for the operation.", getActionText(action), fencedHost.getHostName()));
}
try {
result = executeFenceAction(action, agent, proxyHost);
if (result.getStatus() == Status.ERROR) {
log.warn("Fence action failed using proxy host '{}', trying another proxy", proxyHost.getHostName());
VDS alternativeProxy = getProxyLocator().findProxyHost(isRetryEnabled(action), proxyHost.getId());
if (alternativeProxy != null) {
result = executeFenceAction(action, agent, alternativeProxy);
} else {
log.warn("Failed to find another proxy to re-run failed fence action, " + "retrying with the same proxy '{}'", proxyHost.getHostName());
result = executeFenceAction(action, agent, proxyHost);
}
}
} catch (EngineException e) {
log.debug("Exception", e);
result = new FenceOperationResult(FenceOperationResult.Status.ERROR, PowerStatus.UNKNOWN, e.getMessage());
}
return result;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class MacPoolUsingRanges method initialize.
void initialize(boolean engineStartup, List<String> macsForMacPool) {
log.info("Initializing {}", this);
this.macsStorage = createMacsStorage(this.rangesBoundaries);
log.debug("Initializing {} with macs: {}", this, macsForMacPool);
List<String> notAddedMacs = addMacs(macsForMacPool);
if (!notAddedMacs.isEmpty()) {
if (engineStartup) {
String auditLogMessage = "Following MACs violates duplicity restriction, and was pushed into MAC pool without respect to it:" + notAddedMacs;
auditLogDirector.log(new AuditLogableImpl(), AuditLogType.MAC_ADDRESS_VIOLATES_NO_DUPLICATES_SETTING, auditLogMessage);
forceAddMacs(notAddedMacs);
} else {
throw new EngineException(EngineError.MAC_POOL_INITIALIZATION_FAILED, "Unable to initialize MAC pool due to existing duplicates");
}
}
log.info("Finished initializing {}. Available MACs in pool: {}", this, macsStorage.getAvailableMacsCount());
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class MacPoolUsingRanges method createMacsStorage.
/**
* create and initialize internal structures to accommodate all macs specified in {@code rangesString} up to {@code
* maxMacsInPool}.
*
* @return initialized {@link MacsStorage} instance.
*/
private MacsStorage createMacsStorage(Collection<LongRange> rangesBoundaries) {
MacsStorage macsStorage = new MacsStorage(allowDuplicates);
for (LongRange range : rangesBoundaries) {
log.debug("Adding range {} to pool {}.", range, this);
macsStorage.addRange(range.getMinimumLong(), range.getMaximumLong());
}
if (macsStorage.availableMacExist()) {
return macsStorage;
} else {
throw new EngineException(EngineError.MAC_POOL_INITIALIZATION_FAILED);
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class CreateSnapshotCommand method performImageVdsmOperation.
@Override
protected boolean performImageVdsmOperation() {
setDestinationImageId(Guid.isNullOrEmpty(getParameters().getDestinationImageId()) ? Guid.newGuid() : getParameters().getDestinationImageId());
persistCommandIfNeeded();
newDiskImage = cloneDiskImage(getDestinationImageId());
newDiskImage.setStorageIds(new ArrayList<>(Arrays.asList(getDestinationStorageDomainId())));
setStoragePoolId(newDiskImage.getStoragePoolId() != null ? newDiskImage.getStoragePoolId() : Guid.Empty);
getParameters().setStoragePoolId(getStoragePoolId());
// override volume type and volume format to sparse and cow according to
// storage team request
newDiskImage.setVolumeType(VolumeType.Sparse);
newDiskImage.setVolumeFormat(VolumeFormat.COW);
try {
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.CreateVolume, new CreateVolumeVDSCommandParameters(getStoragePoolId(), getDestinationStorageDomainId(), getImageGroupId(), getImage().getImageId(), getDiskImage().getSize(), newDiskImage.getVolumeType(), newDiskImage.getVolumeFormat(), getDiskImage().getId(), getDestinationImageId(), "", getStoragePool().getCompatibilityVersion(), getDiskImage().getContentType()));
if (vdsReturnValue != null && vdsReturnValue.getSucceeded()) {
getParameters().setVdsmTaskIds(new ArrayList<>());
getParameters().getVdsmTaskIds().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId(), getParameters().getDestinationImageId()));
getReturnValue().getInternalVdsmTaskIdList().add(getParameters().getVdsmTaskIds().get(0));
// Shouldn't happen anymore:
if (getDestinationImageId().equals(Guid.Empty)) {
throw new RuntimeException();
}
return true;
}
} catch (Exception e) {
log.error("Failed creating snapshot from image id '{}'", getImage().getImageId());
commandCoordinatorUtil.logAndFailTaskOfCommandWithEmptyVdsmId(getAsyncTaskId(), "Create snapshot failed at VDSM. DB task ID is " + getAsyncTaskId());
throw new EngineException(EngineError.VolumeCreationError);
}
return false;
}
Aggregations