Search in sources :

Example 26 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class VdsNotRespondingTreatmentCommand method isConnectivityBrokenThresholdReached.

private boolean isConnectivityBrokenThresholdReached(VDS vds) {
    Cluster cluster = clusterDao.get(vds.getClusterId());
    int percents = 0;
    boolean result = false;
    if (cluster.getFencingPolicy().isSkipFencingIfConnectivityBroken()) {
        List<VDS> hosts = vdsDao.getAllForCluster(cluster.getId());
        double hostsNumber = hosts.size();
        double hostsWithBrokenConnectivityNumber = hosts.stream().filter(h -> h.getStatus() == VDSStatus.Connecting || h.getStatus() == VDSStatus.NonResponsive).count();
        percents = (int) ((hostsWithBrokenConnectivityNumber / hostsNumber) * 100);
        result = percents >= cluster.getFencingPolicy().getHostsWithBrokenConnectivityThreshold();
    }
    if (result) {
        logAlert(vds, percents);
    }
    return result;
}
Also used : ClusterDao(org.ovirt.engine.core.dao.ClusterDao) NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager) LockProperties(org.ovirt.engine.core.common.action.LockProperties) HashMap(java.util.HashMap) HostValidator(org.ovirt.engine.core.bll.validator.HostValidator) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) ThreadUtils(org.ovirt.engine.core.utils.ThreadUtils) VdsDao(org.ovirt.engine.core.dao.VdsDao) Map(java.util.Map) SetStoragePoolStatusParameters(org.ovirt.engine.core.common.action.SetStoragePoolStatusParameters) PreviousHostedEngineHost(org.ovirt.engine.core.bll.hostedengine.PreviousHostedEngineHost) FencingPolicy(org.ovirt.engine.core.common.businessentities.FencingPolicy) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) Pair(org.ovirt.engine.core.common.utils.Pair) Config(org.ovirt.engine.core.common.config.Config) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) MonitoringStrategyFactory(org.ovirt.engine.core.vdsbroker.monitoring.MonitoringStrategyFactory) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) Scope(org.ovirt.engine.core.common.action.LockProperties.Scope) VdsCommand(org.ovirt.engine.core.bll.VdsCommand) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) HostLocking(org.ovirt.engine.core.bll.HostLocking) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) VDS(org.ovirt.engine.core.common.businessentities.VDS) VDS(org.ovirt.engine.core.common.businessentities.VDS) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 27 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class RemoveStorageDomainCommand method validate.

@Override
protected boolean validate() {
    if (!super.validate()) {
        return false;
    }
    StorageDomain dom = getStorageDomain();
    if (dom == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST);
    }
    VDS vds = getVds();
    boolean localFs = isLocalFs(dom);
    if (vds == null) {
        if (localFs) {
            if (!initializeVds()) {
                return false;
            }
        } else {
            return failValidation(EngineMessage.CANNOT_REMOVE_STORAGE_DOMAIN_INVALID_HOST_ID);
        }
    } else if (vds.getStatus() != VDSStatus.Up) {
        return failValidation(EngineMessage.CANNOT_REMOVE_STORAGE_DOMAIN_HOST_NOT_UP, String.format("$%1$s %2$s", "hostName", vds.getName()));
    }
    StorageDomainToPoolRelationValidator domainPoolValidator = createDomainToPoolValidator(dom);
    if (!checkStorageDomain()) {
        return false;
    }
    if (!localFs && !validate(domainPoolValidator.isStorageDomainNotInAnyPool())) {
        return false;
    }
    if (localFs && isDomainAttached(dom) && !canDetachDomain(getParameters().getDestroyingPool())) {
        return false;
    }
    if (getParameters().getDoFormat() && !localFs && isStorageDomainAttached(dom)) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_FORMAT_STORAGE_DOMAIN_WITH_ATTACHED_DATA_DOMAIN);
    }
    if (dom.getStorageType().isOpenStackDomain()) {
        return failValidation(EngineMessage.ERROR_CANNOT_MANAGE_STORAGE_DOMAIN);
    }
    return true;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageDomainToPoolRelationValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainToPoolRelationValidator)

Example 28 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class AddStoragePoolWithStoragesCommand method executeCommand.

@Override
protected void executeCommand() {
    if (updateStorageDomainsInDb()) {
        // setting storage pool status to maintenance
        StoragePool storagePool = getStoragePool();
        getCompensationContext().snapshotEntity(storagePool);
        TransactionSupport.executeInNewTransaction(() -> {
            getStoragePool().setStatus(StoragePoolStatus.Maintenance);
            getStoragePool().setStoragePoolFormatType(masterStorageDomain.getStorageFormat());
            storagePoolDao.update(getStoragePool());
            getCompensationContext().stateChanged();
            StoragePoolStatusHandler.poolStatusChanged(getStoragePool().getId(), getStoragePool().getStatus());
            return null;
        });
        // Following code performs only read operations, therefore no need for new transaction
        boolean result = false;
        // Once we create a storage pool with multiple hosts, the engine should connect all
        // the hosts in the storage pool,
        // since the engine picks a random host to fetch all the unregistered disks.
        boolean isStoragePoolCreated = false;
        retVal = null;
        for (VDS vds : getAllRunningVdssInPool()) {
            setVds(vds);
            for (Guid storageDomainId : getParameters().getStorages()) {
                // now the domain should have the mapping
                // with the pool in db
                StorageDomain storageDomain = storageDomainDao.getForStoragePool(storageDomainId, getStoragePool().getId());
                storageHelperDirector.getItem(storageDomain.getStorageType()).connectStorageToDomainByVdsId(storageDomain, getVds().getId());
            }
            if (!isStoragePoolCreated) {
                // but didn't throw exception
                if (!cleanDirtyMetaDataIfNeeded()) {
                    result = false;
                } else {
                    retVal = addStoragePoolInIrs();
                    if (!retVal.getSucceeded() && retVal.getVdsError().getCode() == EngineError.StorageDomainAccessError) {
                        log.warn("Error creating storage pool on vds '{}' - continuing", vds.getName());
                        continue;
                    }
                    result = retVal.getSucceeded();
                }
                isStoragePoolCreated = true;
            }
        }
        setSucceeded(result);
        if (!result) {
            if (retVal != null && retVal.getVdsError().getCode() != null) {
                throw new EngineException(retVal.getVdsError().getCode(), retVal.getVdsError().getMessage());
            } else {
                // command
                throw new EngineException(EngineError.ENGINE_ERROR_CREATING_STORAGE_POOL);
            }
        }
        registerOvfStoreDisks();
    }
    // Create pool phase completed, no rollback is needed here, so compensation information needs to be cleared!
    TransactionSupport.executeInNewTransaction(() -> {
        getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand();
        return null;
    });
    freeLock();
    // if create succeeded activate
    if (getSucceeded()) {
        activateStorageDomains();
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid)

Example 29 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class RefreshLunsSizeCommand method getDeviceListAllVds.

/**
 *        This  method calls GetDeviceList with the specified luns on all hosts.
 *        In VDSM , this call will resize the devices if needed.
 *        It returns a map of LUN ID to a list of Pair(VDS,LUNs)
 *        This map will help to check if all hosts are seeing the same size of the LUNs.
 */
private Map<String, List<Pair<VDS, LUNs>>> getDeviceListAllVds(Set<String> lunsToResize) {
    Map<String, List<Pair<VDS, LUNs>>> lunToVds = new HashMap<>();
    for (VDS vds : getAllRunningVdssInPool()) {
        GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(vds.getId(), getStorageDomain().getStorageType(), false, lunsToResize);
        List<LUNs> luns = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
        for (LUNs lun : luns) {
            lunToVds.computeIfAbsent(lun.getLUNId(), k -> new ArrayList<>()).add(new Pair<>(vds, lun));
        }
    }
    return lunToVds;
}
Also used : NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) StorageDomainDynamicDao(org.ovirt.engine.core.dao.StorageDomainDynamicDao) Guid(org.ovirt.engine.core.compat.Guid) EngineException(org.ovirt.engine.core.common.errors.EngineException) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HashMap(java.util.HashMap) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) TransactionSupport(org.ovirt.engine.core.utils.transaction.TransactionSupport) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ExtendSANStorageDomainParameters(org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters) Map(java.util.Map) Pair(org.ovirt.engine.core.common.utils.Pair) GetStorageDomainStatsVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetStorageDomainStatsVDSCommandParameters) StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Set(java.util.Set) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters) Collectors(java.util.stream.Collectors) EngineError(org.ovirt.engine.core.common.errors.EngineError) LunDao(org.ovirt.engine.core.dao.LunDao) List(java.util.List) ResizeStorageDomainPVVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ResizeStorageDomainPVVDSCommandParameters) Optional(java.util.Optional) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext) VDS(org.ovirt.engine.core.common.businessentities.VDS) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)

Example 30 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS 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)

Aggregations

VDS (org.ovirt.engine.core.common.businessentities.VDS)578 ArrayList (java.util.ArrayList)160 Test (org.junit.Test)138 Guid (org.ovirt.engine.core.compat.Guid)132 List (java.util.List)78 VM (org.ovirt.engine.core.common.businessentities.VM)65 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)55 HashMap (java.util.HashMap)53 HashSet (java.util.HashSet)48 Map (java.util.Map)45 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)42 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)42 Set (java.util.Set)40 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)39 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)39 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)38 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)38 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)37 Frontend (org.ovirt.engine.ui.frontend.Frontend)35