Search in sources :

Example 1 with ConnectStoragePoolVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters 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 2 with ConnectStoragePoolVDSCommandParameters

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

the class RefreshStoragePoolAndDisconnectAsyncOperation method execute.

@Override
public void execute(int iterationId) {
    try {
        resourceManager.runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(getVdss().get(iterationId), getStoragePool(), masterStorageDomainId, storagePoolIsoMap, true));
        storageHelperDirector.getItem(getStorageDomain().getStorageType()).disconnectStorageFromDomainByVdsId(getStorageDomain(), getVdss().get(iterationId).getId());
    } catch (RuntimeException e) {
        log.error("Failed to connect/refresh storagePool. Host '{}' to storage pool '{}': {}", getVdss().get(iterationId).getName(), getStoragePool().getName(), e.getMessage());
        log.debug("Exception", e);
    }
}
Also used : ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)

Example 3 with ConnectStoragePoolVDSCommandParameters

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

the class InitVdsOnUpCommand method runConnectHostToPoolEvent.

private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) {
    EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL);
    StoragePool storagePool = storagePoolDao.get(storagePoolId);
    StorageDomain masterDomain = storageDomainDao.getStorageDomains(storagePoolId, StorageDomainType.Master).get(0);
    List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
    boolean masterDomainInactiveOrUnknown = masterDomain.getStatus() == StorageDomainStatus.Inactive || masterDomain.getStatus() == StorageDomainStatus.Unknown;
    VDSError error = null;
    try {
        VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, storagePool, masterDomain.getId(), storagePoolIsoMap));
        if (!vdsReturnValue.getSucceeded()) {
            error = vdsReturnValue.getVdsError();
        }
    } catch (EngineException e) {
        error = e.getVdsError();
    }
    if (error != null) {
        if (error.getCode() != EngineError.CannotConnectMultiplePools && masterDomainInactiveOrUnknown) {
            log.info("Could not connect host '{}' to pool '{}', as the master domain is in inactive/unknown" + " status - not failing the operation", vds.getName(), storagePool.getName());
        } else {
            log.error("Could not connect host '{}' to pool '{}': {}", vds.getName(), storagePool.getName(), error.getMessage());
            result.setSuccess(false);
        }
    }
    if (result.isSuccess()) {
        Pair<Boolean, List<StorageDomainStatic>> vdsStatsResults = proceedVdsStats(!masterDomainInactiveOrUnknown, storagePool);
        result.setSuccess(vdsStatsResults.getFirst());
        if (!result.isSuccess()) {
            result.setResultData(vdsStatsResults.getSecond());
            auditLogDirector.log(this, AuditLogType.VDS_STORAGE_VDS_STATS_FAILED);
        }
    }
    return result;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) VDSError(org.ovirt.engine.core.common.errors.VDSError) List(java.util.List) ArrayList(java.util.ArrayList) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)

Example 4 with ConnectStoragePoolVDSCommandParameters

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

the class IrsProxy method connectStoragePool.

private void connectStoragePool(VDS vds, StoragePool storagePool) {
    Guid masterDomainId = storageDomainDao.getMasterStorageDomainIdForPool(storagePoolId);
    List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
    VDSReturnValue connectResult = resourceManager.runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, storagePool, masterDomainId, storagePoolIsoMap));
    if (!connectResult.getSucceeded() && connectResult.getExceptionObject() instanceof IRSNoMasterDomainException) {
        throw connectResult.getExceptionObject();
    } else if (!connectResult.getSucceeded()) {
        // failover
        throw new IRSNonOperationalException("Could not connect host to Data Center(Storage issue)");
    }
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 5 with ConnectStoragePoolVDSCommandParameters

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

the class RefreshPoolSingleAsyncOperation method execute.

@Override
public void execute(int iterationId) {
    try {
        if (getStorageDomain() != null && getStorageDomain().getStorageDomainType() == StorageDomainType.Master) {
            try {
                resourceManager.runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(getVdss().get(iterationId), getStoragePool(), masterStorageDomainId, storagePoolIsoMap));
            } catch (Exception e) {
                log.error("Could not connect vds '{}' to pool '{}' - moving host to non-operational: {}", getVdss().get(iterationId).getName(), getStoragePool().getName(), e.getMessage());
                log.debug("Exception", e);
                synchronized (vdsIdsToSetNonOperational) {
                    vdsIdsToSetNonOperational.add(getVdss().get(iterationId).getId());
                }
            }
        } else {
            resourceManager.runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(getVdss().get(iterationId), getStoragePool(), masterStorageDomainId, storagePoolIsoMap, true));
            log.info("Refreshed vds '{}' in pool '{}'", getVdss().get(iterationId).getName(), getStoragePool().getName());
        }
    } catch (RuntimeException e) {
        log.error("Failed to connect/refresh storagePool. Host '{}' to storage pool '{}': {}", getVdss().get(iterationId).getName(), getStoragePool().getName(), e.getMessage());
        log.debug("Exception", e);
    }
}
Also used : ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)

Aggregations

ConnectStoragePoolVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)5 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 ArrayList (java.util.ArrayList)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VDSError (org.ovirt.engine.core.common.errors.VDSError)1 EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)1 Guid (org.ovirt.engine.core.compat.Guid)1