Search in sources :

Example 86 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class UpdateStoragePoolCommand method updateStoragePoolFormatType.

private void updateStoragePoolFormatType() {
    final StoragePool storagePool = getStoragePool();
    final Guid spId = storagePool.getId();
    final Version spVersion = storagePool.getCompatibilityVersion();
    final Version oldSpVersion = getOldStoragePool().getCompatibilityVersion();
    if (oldSpVersion.equals(spVersion)) {
        return;
    }
    StorageFormatType targetFormat = updatePoolAndDomainsFormat(spVersion);
    if (getOldStoragePool().getStatus() == StoragePoolStatus.Up) {
        try {
            // No need to worry about "reupgrading" as VDSM will silently ignore
            // the request.
            runVdsCommand(VDSCommandType.UpgradeStoragePool, new UpgradeStoragePoolVDSCommandParameters(spId, targetFormat));
        } catch (EngineException e) {
            log.warn("Upgrade process of Storage Pool '{}' has encountered a problem due to following reason: {}", spId, e.getMessage());
            auditLogDirector.log(this, AuditLogType.UPGRADE_STORAGE_POOL_ENCOUNTERED_PROBLEMS);
            // and return.
            if (e.getVdsError() != null && e.getErrorCode() == EngineError.PoolUpgradeInProgress) {
                updatePoolAndDomainsFormat(oldSpVersion);
                return;
            }
        }
    }
    runSynchronizeOperation(new RefreshPoolSingleAsyncOperationFactory(), new ArrayList<Guid>());
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Version(org.ovirt.engine.core.compat.Version) StorageFormatType(org.ovirt.engine.core.common.businessentities.StorageFormatType) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) UpgradeStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.UpgradeStoragePoolVDSCommandParameters)

Example 87 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class RecoveryStoragePoolCommand method executeCommand.

@Override
protected void executeCommand() {
    StorageDomain newMasterDomain = loadTargetedMasterDomain();
    if (storageHelperDirector.getItem(newMasterDomain.getStorageType()).connectStorageToDomainByVdsId(newMasterDomain, getVds().getId())) {
        getEventQueue().submitEventSync(new Event(getParameters().getStoragePoolId(), getParameters().getNewMasterDomainId(), null, EventType.RECOVERY, ""), () -> {
            getParameters().setStorageDomainId(getMasterDomainIdFromDb());
            StoragePoolIsoMap domainPoolMap = new StoragePoolIsoMap(getParameters().getNewMasterDomainId(), getParameters().getStoragePoolId(), StorageDomainStatus.Active);
            storagePoolIsoMapDao.save(domainPoolMap);
            getParameters().setVdsId(getVds().getId());
            ActionReturnValue returnVal = runInternalAction(ActionType.ReconstructMasterDomain, getParameters(), cloneContextAndDetachFromParent());
            boolean reconstructVerbExecuted = (returnVal.getActionReturnValue() != null) ? (Boolean) returnVal.getActionReturnValue() : false;
            storagePoolDao.updateStatus(getStoragePool().getId(), StoragePoolStatus.NonResponsive);
            if (!reconstructVerbExecuted) {
                storagePoolIsoMapDao.remove(domainPoolMap.getId());
            }
            if (returnVal.getSucceeded()) {
                updateStorageDomainFormatIfNeeded(loadTargetedMasterDomain());
            }
            setSucceeded(returnVal.getSucceeded());
            return new EventResult(reconstructVerbExecuted, EventType.RECONSTRUCT);
        });
    } else {
        getReturnValue().setFault(new EngineFault(new EngineException(EngineError.StorageServerConnectionError, "Failed to connect storage"), EngineError.StorageServerConnectionError));
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) EngineException(org.ovirt.engine.core.common.errors.EngineException) Event(org.ovirt.engine.core.common.eventqueue.Event)

Example 88 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class ExternalNetworkManager method deallocateIfExternal.

/**
 * Deallocate the vNIC from the external network, if it's attached to a network and the network is indeed an
 * external network (otherwise, nothing is done).
 */
public void deallocateIfExternal() {
    if (getNetwork() != null && getNetwork().isExternal()) {
        Provider<?> provider = providerDao.get(getNetwork().getProvidedBy().getProviderId());
        NetworkProviderProxy providerProxy = providerProxyFactory.create(provider);
        try {
            providerProxy.deallocate(nic);
        } catch (EngineException e) {
            AuditLogable removePortFailureEvent = new AuditLogableImpl();
            removePortFailureEvent.addCustomValue("NicName", nic.getName());
            removePortFailureEvent.addCustomValue("NicId", nic.getId().toString());
            removePortFailureEvent.addCustomValue("ProviderName", provider.getName());
            auditLogDirector.log(removePortFailureEvent, AuditLogType.REMOVE_PORT_FROM_EXTERNAL_PROVIDER_FAILED);
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) EngineException(org.ovirt.engine.core.common.errors.EngineException) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy)

Example 89 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class AddNetworkParametersBuilder method buildParameters.

public ArrayList<ActionParametersBase> buildParameters(Network network, List<VdsNetworkInterface> nics) {
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (VdsNetworkInterface nic : nics) {
        PersistentHostSetupNetworksParameters setupNetworkParams = createHostSetupNetworksParameters(nic.getVdsId());
        setupNetworkParams.setNetworkNames(network.getName());
        VdsNetworkInterface nicToConfigure = getNicToConfigure(getNics(nic.getVdsId()), nic.getId());
        if (nicToConfigure == null) {
            throw new EngineException(EngineError.LABELED_NETWORK_INTERFACE_NOT_FOUND);
        }
        NetworkAttachment networkAttachment = new NetworkAttachment(nicToConfigure, network, NetworkUtils.createIpConfigurationFromVdsNetworkInterface(getVlanDevice(nicToConfigure, network.getVlanId())));
        setupNetworkParams.getNetworkAttachments().add(networkAttachment);
        addBootProtocolForRoleNetworkAttachment(nicToConfigure, network, networkAttachment);
        parameters.add(setupNetworkParams);
    }
    return parameters;
}
Also used : PersistentHostSetupNetworksParameters(org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters) ArrayList(java.util.ArrayList) EngineException(org.ovirt.engine.core.common.errors.EngineException) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 90 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class ExportVmCommand method moveOrCopyAllImageGroups.

@Override
protected void moveOrCopyAllImageGroups(Guid containerID, Iterable<DiskImage> disks) {
    for (DiskImage disk : disks) {
        ActionReturnValue vdcRetValue = runInternalActionWithTasksContext(ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForDisk(containerID, disk));
        if (!vdcRetValue.getSucceeded()) {
            throw new EngineException(vdcRetValue.getFault().getError(), "Failed during ExportVmCommand");
        }
        // TODO: Currently REST-API doesn't support coco for async commands, remove when bug 1199011 fixed
        getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList());
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

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