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();
}
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;
}
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;
}
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);
}
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);
}
Aggregations