Search in sources :

Example 66 with EngineException

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

the class BaseIscsiBondCommand method connectAllHostsToStorage.

protected void connectAllHostsToStorage(List<String> connectionIds) {
    List<Callable<Void>> tasks = new ArrayList<>();
    final List<StorageServerConnections> connections = storageServerConnectionDao.getByIds(connectionIds);
    List<VDS> hosts = vdsDao.getAllForStoragePoolAndStatus(getIscsiBond().getStoragePoolId(), VDSStatus.Up);
    for (final VDS host : hosts) {
        tasks.add(() -> {
            try {
                final List<StorageServerConnections> conns = iscsiStorageHelper.updateIfaces(connections, host.getId());
                VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(host.getId(), Guid.Empty, StorageType.ISCSI, conns));
                final Map<String, String> iscsiMap = (Map<String, String>) returnValue.getReturnValue();
                List<String> failedConnectionsList = iscsiMap.entrySet().stream().filter(e -> !"0".equals(e.getValue())).map(Map.Entry::getKey).collect(Collectors.toList());
                if (!failedConnectionsList.isEmpty()) {
                    log.error("Host '{}' - '{}' encounter problems to connect to the iSCSI Storage" + " Server. The following connections were problematic" + "" + " (connectionid=vdsm result): {}", host.getName(), host.getId(), iscsiMap.toString());
                    encounterConnectionProblems = true;
                }
            } catch (EngineException e) {
                log.error("Could not connect Host '{}' - '{}' to Iscsi Storage Server: {}", host.getName(), host.getId(), e.getMessage());
                log.debug("Exception", e);
                encounterConnectionProblems = true;
            }
            return null;
        });
    }
    ThreadPoolUtil.invokeAll(tasks);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) EngineException(org.ovirt.engine.core.common.errors.EngineException) Callable(java.util.concurrent.Callable) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) Map(java.util.Map)

Example 67 with EngineException

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

the class AbstractDiskVmCommand method performPlugCommand.

protected void performPlugCommand(VDSCommandType commandType, Disk disk, VmDevice vmDevice) {
    if (disk.getDiskStorageType() == DiskStorageType.LUN) {
        LunDisk lunDisk = (LunDisk) disk;
        if (commandType == VDSCommandType.HotPlugDisk) {
            LUNs lun = lunDisk.getLun();
            updateLUNConnectionsInfo(lun);
            lun.getLunConnections().stream().map(StorageServerConnections::getStorageType).distinct().forEach(t -> {
                if (!getStorageHelper(t).connectStorageToLunByVdsId(null, getVm().getRunOnVds(), lun, getVm().getStoragePoolId())) {
                    throw new EngineException(EngineError.StorageServerConnectionError);
                }
            });
        }
    } else if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
        CinderDisk cinderDisk = (CinderDisk) disk;
        setStorageDomainId(cinderDisk.getStorageIds().get(0));
        getCinderBroker().updateConnectionInfoForDisk(cinderDisk);
    }
    Map<String, String> diskAddressMap = getDiskAddressMap(vmDevice, getDiskVmElement().getDiskInterface());
    runVdsCommand(commandType, new HotPlugDiskVDSParameters(getVm().getRunOnVds(), getVm(), disk, vmDevice, diskAddressMap, getDiskVmElement().getDiskInterface(), getDiskVmElement().isPassDiscard()));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) EngineException(org.ovirt.engine.core.common.errors.EngineException) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) HotPlugDiskVDSParameters(org.ovirt.engine.core.common.vdscommands.HotPlugDiskVDSParameters)

Example 68 with EngineException

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

the class AddVdsCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid oVirtId = getParameters().getVdsForUniqueId();
    if (oVirtId != null) {
        // if fails to remove deprecated entry, we might attempt to add new oVirt host with an existing unique-id.
        if (!removeDeprecatedOvirtEntry(oVirtId)) {
            log.error("Failed to remove duplicated oVirt entry with id '{}'. Abort adding oVirt Host type", oVirtId);
            throw new EngineException(EngineError.HOST_ALREADY_EXISTS);
        }
    }
    completeOpenstackNetworkProviderId();
    TransactionSupport.executeInNewTransaction(() -> {
        addVdsStaticToDb();
        addVdsDynamicToDb();
        addVdsStatisticsToDb();
        addAffinityLabels();
        getCompensationContext().stateChanged();
        return null;
    });
    if (getParameters().isProvisioned()) {
        HostProviderProxy proxy = providerProxyFactory.create(getHostProvider());
        proxy.provisionHost(getParameters().getvds(), getParameters().getHostGroup(), getParameters().getComputeResource(), getParameters().getHostMac(), getParameters().getDiscoverName(), getParameters().getPassword(), getParameters().getDiscoverIp());
        addCustomValue("HostGroupName", getParameters().getHostGroup().getName());
        auditLogDirector.log(this, AuditLogType.VDS_PROVISION);
    }
    // set vds spm id
    if (getCluster().getStoragePoolId() != null) {
        VdsActionParameters tempVar = new VdsActionParameters(getVdsIdRef());
        tempVar.setSessionId(getParameters().getSessionId());
        tempVar.setCompensationEnabled(true);
        ActionReturnValue addVdsSpmIdReturn = runInternalAction(ActionType.AddVdsSpmId, tempVar, cloneContext().withoutLock().withoutExecutionContext());
        if (!addVdsSpmIdReturn.getSucceeded()) {
            setSucceeded(false);
            getReturnValue().setFault(addVdsSpmIdReturn.getFault());
            return;
        }
    }
    TransactionSupport.executeInNewTransaction(() -> {
        initializeVds(true);
        alertIfPowerManagementNotConfigured(getParameters().getVdsStaticData());
        testVdsPowerManagementStatus(getParameters().getVdsStaticData());
        setSucceeded(true);
        setActionReturnValue(getVdsIdRef());
        // If the installation failed, we don't want to compensate for the failure since it will remove the
        // host, but instead the host should be left in an "install failed" status.
        getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand();
        return null;
    });
    // clients). they are installed as part of the approve process or automatically after provision
    if (Config.<Boolean>getValue(ConfigValues.InstallVds) && !getParameters().isPending() && !getParameters().isProvisioned()) {
        final InstallVdsParameters installVdsParameters = new InstallVdsParameters(getVdsId(), getParameters().getPassword());
        installVdsParameters.setAuthMethod(getParameters().getAuthMethod());
        installVdsParameters.setOverrideFirewall(getParameters().getOverrideFirewall());
        installVdsParameters.setActivateHost(getParameters().getActivateHost());
        installVdsParameters.setNetworkProviderId(getParameters().getVdsStaticData().getOpenstackNetworkProviderId());
        installVdsParameters.setNetworkMappings(getParameters().getNetworkMappings());
        installVdsParameters.setEnableSerialConsole(getParameters().getEnableSerialConsole());
        if (getParameters().getHostedEngineDeployConfiguration() != null) {
            Map<String, String> vdsDeployParams = hostedEngineHelper.createVdsDeployParams(getVdsId(), getParameters().getHostedEngineDeployConfiguration().getDeployAction());
            installVdsParameters.setHostedEngineConfiguration(vdsDeployParams);
        }
        Map<String, String> values = new HashMap<>();
        values.put(VdcObjectType.VDS.name().toLowerCase(), getParameters().getvds().getName());
        Step installStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), StepEnum.INSTALLING_HOST, ExecutionMessageDirector.resolveStepMessage(StepEnum.INSTALLING_HOST, values));
        final ExecutionContext installCtx = new ExecutionContext();
        installCtx.setJob(getExecutionContext().getJob());
        installCtx.setStep(installStep);
        installCtx.setMonitored(true);
        installCtx.setShouldEndJob(true);
        ThreadPoolUtil.execute(() -> runInternalAction(ActionType.InstallVdsInternal, installVdsParameters, cloneContextAndDetachFromParent().withExecutionContext(installCtx)));
        ExecutionHandler.setAsyncJob(getExecutionContext(), true);
    }
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) HashMap(java.util.HashMap) InstallVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.InstallVdsParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) Guid(org.ovirt.engine.core.compat.Guid) Step(org.ovirt.engine.core.common.job.Step) HostProviderProxy(org.ovirt.engine.core.bll.host.provider.HostProviderProxy)

Example 69 with EngineException

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

the class AttachDiskToVmCommand method updateDiskVmSnapshotId.

private void updateDiskVmSnapshotId() {
    Guid snapshotId = snapshotDao.getId(getVmId(), SnapshotType.ACTIVE);
    if (disk.getDiskStorageType().isInternal()) {
        DiskImage diskImage = (DiskImage) disk;
        imageDao.updateImageVmSnapshotId(diskImage.getImageId(), snapshotId);
    } else {
        throw new EngineException(EngineError.StorageException, "update of snapshot id was initiated for unsupported disk type");
    }
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 70 with EngineException

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

the class CreateSnapshotDiskCommand method executeCommand.

@Override
protected void executeCommand() {
    for (DiskImage disk : getDisksList()) {
        if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
            CreateCinderSnapshotParameters params = buildChildCommandParameters(disk);
            params.setQuotaId(disk.getQuotaId());
            Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.CreateCinderSnapshot, params, cloneContext().withoutCompensationContext().withoutLock());
            try {
                ActionReturnValue actionReturnValue = future.get();
                if (!actionReturnValue.getSucceeded()) {
                    log.error("Error creating snapshot for Cinder disk '{}'", disk.getDiskAlias());
                    throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
                }
            } catch (InterruptedException | ExecutionException e) {
                log.error("Error creating snapshot for Cinder disk '{}': {}", disk.getDiskAlias(), e.getMessage());
                throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
            }
            continue;
        }
        ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshot, buildCreateSnapshotParameters(disk), ExecutionHandler.createDefaultContextForTasks(getContext()));
        if (actionReturnValue.getSucceeded()) {
            getTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
        } else {
            throw new EngineException(actionReturnValue.getFault().getError(), "Failed to create snapshot!");
        }
    }
    setSucceeded(true);
}
Also used : CreateCinderSnapshotParameters(org.ovirt.engine.core.common.action.CreateCinderSnapshotParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) ExecutionException(java.util.concurrent.ExecutionException) 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