Search in sources :

Example 21 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class DisconnectHostFromStoragePoolServersCommand method disconnectStorageByType.

private void disconnectStorageByType(StorageType storageType, List<StorageServerConnections> connections) {
    /*
         * HE SD should only be connected/disconnected by the HE tools, not
         * by the engine.
         */
    Set<String> heIds = storageDomainDao.getHostedEngineStorageDomainIds().stream().map(storageDomainDao::get).map(StorageDomain::getStorageStaticData).map(StorageDomainStatic::getStorage).collect(Collectors.toSet());
    connections = connections.stream().filter(c -> !heIds.contains(c.getId())).collect(Collectors.toList());
    storageHelperDirector.getItem(storageType).prepareDisconnectHostFromStoragePoolServers(getParameters(), connections);
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.DisconnectStorageServer, new StorageServerConnectionManagementVDSParameters(getVds().getId(), getStoragePool().getId(), storageType, connections));
    setSucceeded(vdsReturnValue.getSucceeded());
    if (!vdsReturnValue.getSucceeded()) {
        storageHelperDirector.getItem(storageType).isConnectSucceeded((HashMap<String, String>) vdsReturnValue.getReturnValue(), connections);
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 22 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class ReconstructMasterDomainCommand method connectAndRefreshAllUpHosts.

private void connectAndRefreshAllUpHosts(final boolean commandSucceeded) {
    if (isLastMaster || !commandSucceeded) {
        log.warn("skipping connect and refresh for all hosts, last master '{}', command status '{}'", isLastMaster, commandSucceeded);
        return;
    }
    List<Callable<Void>> tasks = new ArrayList<>();
    for (final VDS vds : getAllRunningVdssInPool()) {
        tasks.add(() -> {
            try {
                if (!connectVdsToNewMaster(vds)) {
                    log.warn("failed to connect vds '{}' to the new master '{}'", vds.getId(), getNewMasterStorageDomainId());
                    return null;
                }
                List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(getStoragePool().getId());
                try {
                    runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, getStoragePool(), getNewMasterStorageDomainId(), storagePoolIsoMap, true));
                } catch (EngineException ex) {
                    if (EngineError.StoragePoolUnknown == ex.getVdsError().getCode()) {
                        VDSReturnValue returnVal = runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, getStoragePool(), getNewMasterStorageDomainId(), storagePoolIsoMap));
                        if (!returnVal.getSucceeded()) {
                            log.error("Post reconstruct actions (connectPool) did not complete on host '{}' in the pool. error {}", vds.getId(), returnVal.getVdsError().getMessage());
                        }
                    } else {
                        log.error("Post reconstruct actions (refreshPool)" + " did not complete on host '{}' in the pool. error {}", vds.getId(), ex.getMessage());
                    }
                }
            } catch (Exception e) {
                log.error("Post reconstruct actions (connectPool,refreshPool,disconnect storage)" + " did not complete on host '{}' in the pool: {}", vds.getId(), e.getMessage());
                log.debug("Exception", e);
            }
            return null;
        });
    }
    ThreadPoolUtil.invokeAll(tasks);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ArrayList(java.util.ArrayList) EngineException(org.ovirt.engine.core.common.errors.EngineException) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters) Callable(java.util.concurrent.Callable) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 23 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class GetUnregisteredBlockStorageDomainsQuery method getStorageDomainById.

/**
 * Retrieve a storage domain using a specified storage domain ID.
 *
 * @param storageDomainId the domain's ID
 * @return the storage domain
 */
@SuppressWarnings("unchecked")
protected StorageDomain getStorageDomainById(Guid storageDomainId) {
    VDSReturnValue returnValue;
    try {
        returnValue = executeHSMGetStorageDomainInfo(new HSMGetStorageDomainInfoVDSCommandParameters(getParameters().getVdsId(), storageDomainId));
    } catch (RuntimeException e) {
        log.error("Could not get info for storage domain ID: '{}': {}", storageDomainId, e.getMessage());
        log.debug("Exception", e);
        return null;
    }
    Pair<StorageDomainStatic, SANState> result = (Pair<StorageDomainStatic, SANState>) returnValue.getReturnValue();
    StorageDomainStatic storageDomainStatic = result.getFirst();
    storageDomainStatic.setStorageType(getParameters().getStorageType());
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setStorageStaticData(storageDomainStatic);
    return storageDomain;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HSMGetStorageDomainInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters) SANState(org.ovirt.engine.core.common.businessentities.SANState) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 24 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class IsoDomainListSynchronizer method updateAllFileListFromVDSM.

private boolean updateAllFileListFromVDSM(Guid repoStoragePoolId, Guid repoStorageDomainId) {
    VDSReturnValue fileStatsVDSReturnValue = getFileStats(repoStoragePoolId, repoStorageDomainId, ALL_FILES_PATTERN);
    Map<String, Map<String, Object>> fileStats = fileStatsFromVDSReturnValue(fileStatsVDSReturnValue);
    updateIsoListFromVDSM(repoStoragePoolId, repoStorageDomainId, removeFileStatsForComplyingFileNames(fileStats, ISO_FILE_PATTERN_REGEX));
    updateFloppyListFromVDSM(repoStoragePoolId, repoStorageDomainId, removeFileStatsForComplyingFileNames(fileStats, FLOPPY_FILE_PATTERN_REGEX));
    // all remaining fileStats are uncategorized, of ImageFileType.Unknown type
    return refreshVdsmFileList(repoStoragePoolId, repoStorageDomainId, ImageFileType.Unknown, fileStats, null);
}
Also used : Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 25 with VDSReturnValue

use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.

the class RunVmCommandTest method succesfull.

private VDSReturnValue succesfull() {
    VDSReturnValue v = new VDSReturnValue();
    v.setSucceeded(true);
    return v;
}
Also used : VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)250 Guid (org.ovirt.engine.core.compat.Guid)65 ArrayList (java.util.ArrayList)43 VDS (org.ovirt.engine.core.common.businessentities.VDS)29 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 Pair (org.ovirt.engine.core.common.utils.Pair)26 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)23 List (java.util.List)16 Test (org.junit.Test)15 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)15 VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)15 HashMap (java.util.HashMap)13 VDSError (org.ovirt.engine.core.common.errors.VDSError)13 Map (java.util.Map)11 Callable (java.util.concurrent.Callable)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)11 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)8