use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class DeactivateStorageDomainCommand method proceedStorageDomainTreatmentByDomainType.
/**
* In case of master domain this method decide if to move master to other domain or move pool to maintenance (since
* there is no master domain)
*
* @param newMaster The selected new master domain
* @param lockNewMaster If true the new master domain will be locked
* @return true if newMaster is the last master
*/
protected boolean proceedStorageDomainTreatmentByDomainType(final StorageDomain newMaster, final boolean lockNewMaster) {
if (newMaster == null) {
return true;
}
newMaster.getStorageStaticData().setLastTimeUsedAsMaster(System.currentTimeMillis());
if (newMaster.getStorageDomainType() != StorageDomainType.Master) {
executeInNewTransaction(() -> {
StoragePoolIsoMap newMasterMap = newMaster.getStoragePoolIsoMapData();
getCompensationContext().snapshotEntityUpdated(newMaster.getStorageStaticData());
newMaster.setStorageDomainType(StorageDomainType.Master);
if (lockNewMaster) {
newMasterMap.setStatus(StorageDomainStatus.Unknown);
getCompensationContext().snapshotEntityStatus(newMasterMap);
newMaster.setStatus(StorageDomainStatus.Locked);
storagePoolIsoMapDao.updateStatus(newMasterMap.getId(), newMasterMap.getStatus());
}
updateStorageDomainStaticData(newMaster.getStorageStaticData());
getCompensationContext().snapshotEntityUpdated(getStorageDomain().getStorageStaticData());
getStorageDomain().setStorageDomainType(StorageDomainType.Data);
updateStorageDomainStaticData(getStorageDomain().getStorageStaticData());
getCompensationContext().stateChanged();
return null;
});
} else {
updateStorageDomainStaticData(newMaster.getStorageStaticData());
}
updateStoragePoolMasterDomainVersionInDiffTransaction();
return false;
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class StorageDomainToPoolRelationValidatorTest method testAttachFailDomainAlreadyInPool.
@Test
public void testAttachFailDomainAlreadyInPool() {
when(storagePoolIsoMapDao.getAllForStorage(storageDomain.getId())).thenReturn(Collections.singletonList(new StoragePoolIsoMap()));
ValidationResult attachedDomainInsertionResult = validator.validateDomainCanBeAttachedToPool();
assertThat(attachedDomainInsertionResult, failsWith(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL));
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class IrsProxy method handleMonitoredDomainsForHost.
/**
* Provides handling for the domains that are monitored by the given host.
* @return map between the domain id and the reason for domains that
* the host reporting is problematic for.
*/
private Map<Guid, DomainMonitoringResult> handleMonitoredDomainsForHost(final Guid vdsId, final String vdsName, final ArrayList<VDSDomainsData> data, Collection<Guid> monitoredDomains) {
Map<Guid, DomainMonitoringResult> domainsProblematicReportInfo = new HashMap<>();
// build a list of all domains in pool
// which are in status Active or Unknown
Set<Guid> activeDomainsInPool = new HashSet<>(storageDomainStaticDao.getAllIds(storagePoolId, StorageDomainStatus.Active));
Set<Guid> unknownDomainsInPool = new HashSet<>(storageDomainStaticDao.getAllIds(storagePoolId, StorageDomainStatus.Unknown));
Set<Guid> inActiveDomainsInPool = new HashSet<>(storageDomainStaticDao.getAllIds(storagePoolId, StorageDomainStatus.Inactive));
// visible by the host.
for (Guid tempDomainId : activeDomainsInPool) {
if (!monitoredDomains.contains(tempDomainId)) {
domainsProblematicReportInfo.put(tempDomainId, DomainMonitoringResult.NOT_REPORTED);
}
}
for (Guid tempDomainId : unknownDomainsInPool) {
if (!monitoredDomains.contains(tempDomainId)) {
domainsProblematicReportInfo.put(tempDomainId, DomainMonitoringResult.NOT_REPORTED);
}
}
Collection<Guid> storageDomainsToSync = new LinkedList<>();
// Unknown domains in pool
for (VDSDomainsData tempData : data) {
StorageDomainStatic storageDomain = storageDomainStaticDao.get(tempData.getDomainId());
if (activeDomainsInPool.contains(tempData.getDomainId()) || unknownDomainsInPool.contains(tempData.getDomainId())) {
DomainMonitoringResult domainMonitoringResult = analyzeDomainReport(tempData, false);
if (domainMonitoringResult.invalidAndActual()) {
domainsProblematicReportInfo.put(tempData.getDomainId(), domainMonitoringResult);
} else if (domainMonitoringResult.actual() && tempData.getDelay() > Config.<Double>getValue(ConfigValues.MaxStorageVdsDelayCheckSec)) {
logDelayedDomain(vdsName, storageDomain.getName(), tempData.getDelay());
}
} else if (inActiveDomainsInPool.contains(tempData.getDomainId()) && analyzeDomainReport(tempData, false).validAndActual()) {
log.warn("Storage Domain '{}' was reported by Host '{}' as Active in Pool '{}', moving to active status", getDomainIdTuple(tempData.getDomainId()), vdsName, storagePoolId);
StoragePoolIsoMap map = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(tempData.getDomainId(), storagePoolId));
map.setStatus(StorageDomainStatus.Active);
storagePoolIsoMapDao.update(map);
if (storageDomain.getStorageType().isBlockDomain()) {
storageDomainsToSync.add(storageDomain.getId());
}
}
}
// For block domains, synchronize LUN details comprising the storage domain with the DB
if (!storageDomainsToSync.isEmpty()) {
getEventListener().syncStorageDomainsLuns(vdsId, storageDomainsToSync);
}
return domainsProblematicReportInfo;
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap 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)");
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class StorageDomainCommandBase method setStorageDomainStatus.
protected void setStorageDomainStatus(StorageDomainStatus status, CompensationContext context) {
if (getStorageDomain() != null && getStorageDomain().getStoragePoolId() != null) {
StoragePoolIsoMap map = getStorageDomain().getStoragePoolIsoMapData();
if (context != null) {
context.snapshotEntityStatus(map);
}
getStorageDomain().setStatus(status);
storagePoolIsoMapDao.updateStatus(map.getId(), status);
}
}
Aggregations