Search in sources :

Example 31 with VDS

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

the class RemoveStoragePoolCommand method connectAllHostToPoolAndDomain.

/**
 * @param masterDomain
 *            Connect all hosts to the pool and to the domains
 */
protected void connectAllHostToPoolAndDomain(final StorageDomain masterDomain) {
    final List<VDS> vdsList = getAllRunningVdssInPool();
    final StoragePool storagePool = getStoragePool();
    SynchronizeNumberOfAsyncOperations sync = new SynchronizeNumberOfAsyncOperations(vdsList.size(), null, new ActivateDeactivateSingleAsyncOperationFactory() {

        @Override
        public ISingleAsyncOperation createSingleAsyncOperation() {
            return Injector.injectMembers(new ConnectVDSToPoolAndDomains(vdsList, masterDomain, storagePool));
        }

        @Override
        public void initialize(List parameters) {
        // no need to initilalize params
        }
    });
    sync.execute();
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) SynchronizeNumberOfAsyncOperations(org.ovirt.engine.core.utils.SynchronizeNumberOfAsyncOperations) ISingleAsyncOperation(org.ovirt.engine.core.utils.ISingleAsyncOperation) List(java.util.List)

Example 32 with VDS

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

the class RemoveStoragePoolCommand method regularRemoveStorageDomains.

private boolean regularRemoveStorageDomains(List<StorageDomain> storageDomains) {
    boolean retVal = true;
    final StorageDomain masterDomain = storageDomains.stream().filter(s -> s.getStorageDomainType() == StorageDomainType.Master).findFirst().orElse(null);
    lockStorageDomain(masterDomain);
    // destroying a pool is an SPM action. We need to connect all hosts
    // to the pool. Later on, during spm election, one of the hosts will
    // lock the pool
    // and the spm status will be FREE. Only then we can invoke the
    // destroy verb.
    connectAllHostToPoolAndDomain(masterDomain);
    List<VDS> vdss = getAllRunningVdssInPool();
    for (StorageDomain storageDomain : storageDomains) {
        if (storageDomain.getStorageDomainType() != StorageDomainType.Master) {
            if (!removeDomainFromPool(storageDomain, vdss.get(0))) {
                log.error("Unable to detach storage domain '{}' '{}'", storageDomain.getStorageName(), storageDomain.getId());
                retVal = false;
            }
        }
    }
    masterDomainDetachWithDestroyPool(masterDomain);
    runSynchronizeOperation(new DisconnectStoragePoolAsyncOperationFactory());
    setSucceeded(true);
    if (!getStoragePool().isLocal() || !masterDomain.isLocal()) {
        for (VDS vds : vdss) {
            storageHelperDirector.getItem(masterDomain.getStorageType()).disconnectStorageFromDomainByVdsId(masterDomain, vds.getId());
        }
    } else {
        try {
            runVdsCommand(VDSCommandType.FormatStorageDomain, new FormatStorageDomainVDSCommandParameters(vdss.get(0).getId(), masterDomain.getId()));
        } catch (EngineException e) {
        // Do nothing, exception already printed at logs
        }
        storageHelperDirector.getItem(masterDomain.getStorageType()).disconnectStorageFromDomainByVdsId(masterDomain, vdss.get(0).getId());
        removeDomainFromDb(masterDomain);
    }
    return retVal;
}
Also used : FormatStorageDomainVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.FormatStorageDomainVDSCommandParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 33 with VDS

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

the class RemoveStoragePoolCommand method validate.

@Override
protected boolean validate() {
    if (!super.validate()) {
        return false;
    }
    StoragePoolValidator validator = createStoragePoolValidator();
    if (!validate(validator.exists())) {
        return false;
    }
    if (!validator.isNotInStatus(StoragePoolStatus.Up).isValid()) {
        return failValidation(EngineMessage.ERROR_CANNOT_REMOVE_ACTIVE_STORAGE_POOL);
    }
    if (!validator.isInStatus(StoragePoolStatus.Uninitialized).isValid() && !getParameters().isForceDelete() && !initializeVds()) {
        return false;
    }
    final List<StorageDomain> poolDomains = storageDomainDao.getAllForStoragePool(getStoragePool().getId());
    if (!validateDomainsInMaintenance(poolDomains)) {
        return false;
    }
    if (!getParameters().isForceDelete()) {
        if (poolDomains.size() > 1) {
            return failValidation(EngineMessage.ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS);
        }
        if (!poolDomains.isEmpty() && !canDetachStorageDomainWithVmsAndDisks(poolDomains.get(0))) {
            return false;
        }
    } else {
        List<VDS> poolHosts = vdsDao.getAllForStoragePool(getParameters().getStoragePoolId());
        sharedLocks = new HashMap<>();
        for (VDS host : poolHosts) {
            sharedLocks.put(host.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.VDS, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
        }
        if (!poolHosts.isEmpty() && acquireLockInternal()) {
            for (VDS host : poolHosts) {
                if (host.getStatus() != VDSStatus.Maintenance) {
                    return failValidation(EngineMessage.ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE);
                }
            }
        }
    }
    return true;
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS)

Example 34 with VDS

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

the class SearchQueryTest method mockVdsDao.

/**
 * Mock Vds Dao so that when getAllWithQuery will be called with the appropriate query string, a unique list will be
 * returned. <BR/>
 * This returned list will indicate, if the correct string has been passed as an argument to the getAllWithQuery
 * API.
 * @param diskImageDao
 *            - The dao to be used
 */
@Before
public void mockVdsDao() {
    SearchObjectAutoCompleter search = new SearchObjectAutoCompleter();
    when(vdsDao.getAllWithQuery(matches(getVdsRegexString(search)))).thenReturn(vdsResultList);
    VDS vds = new VDS();
    vds.setCpuFlags("flag");
    vds.setClusterCompatibilityVersion(Version.getLast());
    vdsResultList.add(vds);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) SearchObjectAutoCompleter(org.ovirt.engine.core.searchbackend.SearchObjectAutoCompleter) Before(org.junit.Before)

Example 35 with VDS

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

the class AutoRecoveryManagerTest method setup.

@Before
public void setup() {
    final VDS vds = new VDS();
    vdss.add(vds);
    when(vdsDaoMock.listFailedAutorecoverables()).thenReturn(vdss);
    StorageDomain domain = new StorageDomain();
    domain.setStoragePoolId(Guid.newGuid());
    storageDomains.add(domain);
    when(storageDomainDaoMock.listFailedAutorecoverables()).thenReturn(storageDomains);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS) Before(org.junit.Before)

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