Search in sources :

Example 26 with StoragePoolIsoMap

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;
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) List(java.util.List)

Example 27 with StoragePoolIsoMap

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);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ArrayList(java.util.ArrayList) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 28 with StoragePoolIsoMap

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();
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Example 29 with StoragePoolIsoMap

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());
}
Also used : StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)

Example 30 with StoragePoolIsoMap

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;
}
Also used : RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus)

Aggregations

StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)40 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15 Guid (org.ovirt.engine.core.compat.Guid)14 StoragePoolIsoMapId (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId)9 Test (org.junit.Test)8 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)8 ArrayList (java.util.ArrayList)6 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)6 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Pair (org.ovirt.engine.core.common.utils.Pair)4 HashMap (java.util.HashMap)3 List (java.util.List)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 StorageDomainDynamic (org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)3 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Event (org.ovirt.engine.core.common.eventqueue.Event)3 EventResult (org.ovirt.engine.core.common.eventqueue.EventResult)3 ConnectStoragePoolVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)3