Search in sources :

Example 21 with EngineException

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);
}
Also used : SetHaMaintenanceParameters(org.ovirt.engine.core.common.action.SetHaMaintenanceParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) SetHaMaintenanceModeVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SetHaMaintenanceModeVDSCommandParameters)

Example 22 with EngineException

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;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 23 with EngineException

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());
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 24 with EngineException

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);
    }
}
Also used : LongRange(org.apache.commons.lang.math.LongRange) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 25 with EngineException

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;
}
Also used : CreateVolumeVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.CreateVolumeVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

EngineException (org.ovirt.engine.core.common.errors.EngineException)107 Guid (org.ovirt.engine.core.compat.Guid)30 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)25 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)25 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)18 ArrayList (java.util.ArrayList)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 HashMap (java.util.HashMap)7 Pair (org.ovirt.engine.core.common.utils.Pair)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Callable (java.util.concurrent.Callable)6 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)6 IOException (java.io.IOException)5 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)5 Map (java.util.Map)4 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 Set (java.util.Set)3 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)3