use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommand method isConnectionEditable.
protected boolean isConnectionEditable(StorageServerConnections connection) {
if (connection.getStorageType().isFileDomain()) {
boolean isConnectionEditable = isFileDomainInEditState(domains.get(0)) || getParameters().isForce();
if (!isConnectionEditable) {
addValidationMessageVariable("domainNames", domains.get(0).getStorageName());
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
}
return isConnectionEditable;
}
if (!getLuns().isEmpty()) {
List<String> problematicVMNames = new ArrayList<>();
List<String> problematicDomainNames = new ArrayList<>();
for (LUNs lun : getLuns()) {
Guid diskId = lun.getDiskId();
if (diskId != null) {
Map<Boolean, List<VM>> vmsMap = vmDao.getForDisk(diskId, true);
List<VM> pluggedVms = vmsMap.get(Boolean.TRUE);
if (pluggedVms != null && !pluggedVms.isEmpty()) {
for (VM vm : pluggedVms) {
if (!vm.getStatus().equals(VMStatus.Down)) {
problematicVMNames.add(vm.getName());
}
}
}
}
Guid storageDomainId = lun.getStorageDomainId();
if (storageDomainId != null) {
StorageDomain domain = storageDomainDao.get(storageDomainId);
if (!domain.getStorageDomainSharedStatus().equals(StorageDomainSharedStatus.Unattached) && !getParameters().isForce()) {
for (StoragePoolIsoMap map : getStoragePoolIsoMap(domain)) {
if (!map.getStatus().equals(StorageDomainStatus.Maintenance)) {
String domainName = domain.getStorageName();
problematicDomainNames.add(domainName);
} else {
domains.add(domain);
}
}
} else {
// unattached domain, edit allowed
domains.add(domain);
}
}
}
if (!problematicVMNames.isEmpty()) {
if (problematicDomainNames.isEmpty()) {
addValidationMessageVariable("vmNames", prepareEntityNamesForMessage(problematicVMNames));
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS);
} else {
addValidationMessageVariable("vmNames", prepareEntityNamesForMessage(problematicVMNames));
addValidationMessageVariable("domainNames", prepareEntityNamesForMessage(problematicDomainNames));
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_STATUS);
}
return false;
}
if (!problematicDomainNames.isEmpty()) {
addValidationMessageVariable("domainNames", prepareEntityNamesForMessage(problematicDomainNames));
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
return false;
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommand method executeCommand.
@Override
protected void executeCommand() {
boolean isDomainUpdateRequired = !Guid.isNullOrEmpty(getVdsId()) && doDomainsUseConnection(getConnection());
List<StorageDomain> updatedDomains = new ArrayList<>();
boolean hasConnectStorageSucceeded = false;
if (isDomainUpdateRequired) {
hasConnectStorageSucceeded = connectToStorage();
VDSReturnValue returnValueUpdatedStorageDomain = null;
if (hasConnectStorageSucceeded) {
changeStorageDomainStatusInTransaction(StorageDomainStatus.Locked);
for (StorageDomain domain : domains) {
// update info such as free space - because we switched to a different server
returnValueUpdatedStorageDomain = getStatsForDomain(domain);
if (returnValueUpdatedStorageDomain.getSucceeded()) {
StorageDomain updatedStorageDomain = (StorageDomain) returnValueUpdatedStorageDomain.getReturnValue();
updatedDomains.add(updatedStorageDomain);
}
}
if (!updatedDomains.isEmpty()) {
updateStorageDomain(updatedDomains);
}
}
}
storageServerConnectionDao.update(getParameters().getStorageServerConnection());
if (isDomainUpdateRequired) {
for (StorageDomain domain : domains) {
for (StoragePoolIsoMap map : getStoragePoolIsoMap(domain)) {
restoreStateAfterUpdate(map);
}
}
if (hasConnectStorageSucceeded) {
disconnectFromStorage();
}
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class ReconstructMasterDomainCommandTest method initializeStorageDomains.
private void initializeStorageDomains() {
masterDomainIsoMap = new StoragePoolIsoMap(masterStorageDomainId, storagePoolId, StorageDomainStatus.Active);
regularDomainIsoMap = new StoragePoolIsoMap(regularStorageDomainId, storagePoolId, StorageDomainStatus.Active);
masterStorageDomain = new StorageDomain();
masterStorageDomain.setStoragePoolIsoMapData(masterDomainIsoMap);
doReturn(masterStorageDomain).when(cmd).getStorageDomain();
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class CINDERStorageHelper method updateCinderDomainStatus.
private void updateCinderDomainStatus(final Guid storageDomainId, final Guid storagePoolId, final StorageDomainStatus storageDomainStatus) {
StoragePoolIsoMap map = storagePoolIsoMapDao.get(new StoragePoolIsoMapId(storageDomainId, storagePoolId));
map.setStatus(storageDomainStatus);
storagePoolIsoMapDao.updateStatus(map.getId(), map.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap in project ovirt-engine by oVirt.
the class IsoDomainListSynchronizer method refreshIsoDomain.
/**
* The procedure Try to refresh the repository files of the storage domain id, By iterate over the storage pools of
* this domain, and try to choose a valid storage pool, to fetch the repository files from the VDSM, and refresh the
* cached table. <BR/>
* If succeeded, will return True. Otherwise return false with updated list of problematic repository files with the
* storage pool, storage domain, and file type, that could not complete the cache update transaction.
*
* @param storageDomainId
* - The Repository domain Id, we want to refresh.
* @param problematicRepoFileList
* - List of business entities, each one indicating the problematic entity.
* @param imageType
* - The imageType we want to fetch the files from the cache.
* @return Boolean value indicating if the refresh succeeded or not.
*/
private boolean refreshIsoDomain(Guid storageDomainId, List<RepoImage> problematicRepoFileList, ImageFileType imageType) {
List<StoragePoolIsoMap> isoMapList = fetchAllStoragePoolsForIsoDomain(storageDomainId, imageType);
for (StoragePoolIsoMap storagePoolIsoMap : isoMapList) {
Guid storagePoolId = storagePoolIsoMap.getStoragePoolId();
StorageDomainStatus status = storagePoolIsoMap.getStatus();
if (StorageDomainStatus.Active != status) {
handleInactiveStorageDomain(storageDomainId, imageType, status);
} else {
// Try to refresh the domain of the storage pool id because its status is active.
boolean refreshOk = refreshIsoDomainFileForStoragePool(storageDomainId, storagePoolId, imageType);
if (!refreshOk) {
log.debug("Failed refreshing Storage domain id '{}', for '{}' file type in storage pool id '{}'.", storageDomainId, imageType, storagePoolId);
// Add the repository file to the list of problematic Iso domains.
RepoImage repoImage = createMockRepositoryFileMetaData(storageDomainId, imageType, storagePoolId);
problematicRepoFileList.add(repoImage);
return false;
}
}
}
return true;
}
Aggregations