Search in sources :

Example 76 with StorageDomainStatic

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

the class BlockStorageDomainHelper method fillMetadataDevicesInfo.

public void fillMetadataDevicesInfo(StorageDomainStatic storageDomainStatic, Guid vdsId) {
    try {
        @SuppressWarnings("unchecked") StorageDomainStatic domainFromIrs = ((Pair<StorageDomainStatic, Guid>) resourceManager.runVdsCommand(VDSCommandType.HSMGetStorageDomainInfo, new HSMGetStorageDomainInfoVDSCommandParameters(vdsId, storageDomainStatic.getId())).getReturnValue()).getFirst();
        storageDomainStatic.setFirstMetadataDevice(domainFromIrs.getFirstMetadataDevice());
        storageDomainStatic.setVgMetadataDevice(domainFromIrs.getVgMetadataDevice());
    } catch (Exception e) {
        storageDomainStatic.setFirstMetadataDevice(null);
        storageDomainStatic.setVgMetadataDevice(null);
        log.info("Failed to get the domain info");
    }
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) HSMGetStorageDomainInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 77 with StorageDomainStatic

use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic 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;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) VDSDomainsData(org.ovirt.engine.core.common.businessentities.VDSDomainsData) StoragePoolIsoMapId(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId) Guid(org.ovirt.engine.core.compat.Guid) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 78 with StorageDomainStatic

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

the class IrsProxy method processDomainRecovery.

private EventResult processDomainRecovery(final Guid domainId) {
    EventResult result = null;
    // build a list of all the hosts in status UP in
    // Pool.
    List<Guid> vdssInPool = new ArrayList<>();
    // Note - this method is used as it returns only hosts from VIRT supported clusters
    // (we use the domain monitoring results only from those clusters hosts).
    // every change to it should be inspected carefully.
    List<VDS> allVds = vdsDao.getAllForStoragePoolAndStatus(storagePoolId, null);
    Map<Guid, VDS> vdsMap = new HashMap<>();
    for (VDS tempVDS : allVds) {
        vdsMap.put(tempVDS.getId(), tempVDS);
        if (tempVDS.getStatus() == VDSStatus.Up) {
            vdssInPool.add(tempVDS.getId());
        }
    }
    // build a list of all the hosts that did not report
    // on this domain as in problem.
    // Mark the above list as hosts we suspect are in
    // problem.
    Set<Guid> hostsThatReportedDomainAsInProblem = domainsInProblem.get(domainId);
    List<Guid> vdssInProblem = new ArrayList<>();
    for (Guid tempVDSId : vdssInPool) {
        if (!hostsThatReportedDomainAsInProblem.contains(tempVDSId)) {
            vdssInProblem.add(tempVDSId);
        }
    }
    // If not All the hosts in status UP reported on
    // this domain as in problem. We assume the problem
    // is with the hosts
    // that did report on a problem with this domain.
    // (and not a problem with the domain itself).
    StorageDomainStatic storageDomain = storageDomainStaticDao.get(domainId);
    String domainIdTuple = getDomainIdTuple(domainId);
    List<Guid> nonOpVdss = new ArrayList<>();
    if (vdssInProblem.size() > 0) {
        if (storageDomain.getStorageDomainType() != StorageDomainType.ImportExport && storageDomain.getStorageDomainType() != StorageDomainType.ISO) {
            // operational.
            for (final Guid vdsId : domainsInProblem.get(domainId)) {
                VDS vds = vdsMap.get(vdsId);
                if (vds == null) {
                    log.warn("vds '{}' reported domain '{}' - as in problem but cannot find vds in db!!", vdsId, domainIdTuple);
                } else if (vds.getStatus() == VDSStatus.Up) {
                    log.warn("vds '{}' reported domain '{}' as in problem, attempting to move the vds to status NonOperational", vds.getName(), domainIdTuple);
                    final Map<String, String> customLogValues = Collections.singletonMap("StorageDomainNames", storageDomain.getName());
                    ThreadPoolUtil.execute(() -> resourceManager.getEventListener().vdsNonOperational(vdsId, NonOperationalReason.STORAGE_DOMAIN_UNREACHABLE, true, domainId, customLogValues));
                    nonOpVdss.add(vdsId);
                } else {
                    log.warn("vds '{}' reported domain '{}' as in problem, vds is in status '{}', no need to move to nonoperational", vds.getName(), domainIdTuple, vds.getStatus());
                }
            }
        } else {
            log.warn("Storage domain '{}' is not visible to one or more hosts. " + "Since the domain's type is '{}', hosts status will not be changed to non-operational", domainIdTuple, storageDomain.getStorageDomainType());
        }
        result = new EventResult(true, EventType.VDSSTORAGEPROBLEMS);
    } else {
        // Domain.
        if (storageDomain.getStorageDomainType() != StorageDomainType.Master) {
            log.error("Domain '{}' was reported by all hosts in status UP as problematic. Moving the domain to NonOperational.", domainIdTuple);
            result = getEventListener().storageDomainNotOperational(domainId, storagePoolId);
        } else {
            log.warn("Domain '{}' was reported by all hosts in status UP as problematic. Not moving the domain to NonOperational because it is being reconstructed now.", domainIdTuple);
            result = getEventListener().masterDomainNotOperational(domainId, storagePoolId, false, false);
        }
    }
    // clear from cache of domainsInProblem
    clearDomainFromCache(domainId, nonOpVdss);
    return result;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) VDS(org.ovirt.engine.core.common.businessentities.VDS) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)

Example 79 with StorageDomainStatic

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

the class StorageDataCenterListModel method onAttach.

private void onAttach() {
    final ListModel<EntityModel<StoragePool>> model = (ListModel<EntityModel<StoragePool>>) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (getEntity() == null) {
        cancel();
        return;
    }
    ArrayList<StoragePool> items = new ArrayList<>();
    for (EntityModel<StoragePool> a : model.getItems()) {
        if (a.getIsSelected()) {
            items.add(a.getEntity());
        }
    }
    if (items.size() == 0) {
        cancel();
        return;
    }
    setSelectedDataCentersForAttach(items);
    model.startProgress();
    if (getEntity().getStorageDomainType() == StorageDomainType.Data) {
        StoragePool dataCenter = items.get(0);
        ArrayList<StorageDomain> storageDomains = new ArrayList<>();
        storageDomains.add(getEntity());
        AsyncDataProvider.getInstance().getStorageDomainsWithAttachedStoragePoolGuid(new AsyncQuery<>(attachedStorageDomains -> {
            if (!attachedStorageDomains.isEmpty()) {
                ConfirmationModel confirmationModel = new ConfirmationModel();
                setWindow(null);
                setWindow(confirmationModel);
                List<String> stoageDomainNames = new ArrayList<>();
                for (StorageDomainStatic domain : attachedStorageDomains) {
                    stoageDomainNames.add(domain.getStorageName());
                }
                confirmationModel.setItems(stoageDomainNames);
                confirmationModel.setTitle(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningTitle());
                confirmationModel.setMessage(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningMessage());
                confirmationModel.setHelpTag(HelpTag.attach_storage_domain_confirmation);
                // $NON-NLS-1$
                confirmationModel.setHashName("attach_storage_domain_confirmation");
                confirmationModel.getLatch().setIsAvailable(true);
                confirmationModel.getLatch().setIsChangeable(true);
                // $NON-NLS-1$
                UICommand onApprove = new UICommand("OnAttachApprove", StorageDataCenterListModel.this);
                onApprove.setTitle(ConstantsManager.getInstance().getConstants().ok());
                onApprove.setIsDefault(true);
                confirmationModel.getCommands().add(onApprove);
                // $NON-NLS-1$
                UICommand cancel = new UICommand("Cancel", StorageDataCenterListModel.this);
                cancel.setTitle(ConstantsManager.getInstance().getConstants().cancel());
                cancel.setIsCancel(true);
                confirmationModel.getCommands().add(cancel);
            } else {
                executeAttachStorageDomains(model);
            }
        }), dataCenter, storageDomains);
    } else {
        executeAttachStorageDomains(model);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) LexoNumericComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) StorageDomainPoolParametersBase(org.ovirt.engine.core.common.action.StorageDomainPoolParametersBase) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) RemoveStorageDomainParameters(org.ovirt.engine.core.common.action.RemoveStorageDomainParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) ActionUtils(org.ovirt.engine.core.common.ActionUtils) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) List(java.util.List) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Comparator(java.util.Comparator) Collections(java.util.Collections) DeactivateStorageDomainWithOvfUpdateParameters(org.ovirt.engine.core.common.action.DeactivateStorageDomainWithOvfUpdateParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) DetachStorageDomainFromPoolParameters(org.ovirt.engine.core.common.action.DetachStorageDomainFromPoolParameters) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) List(java.util.List) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 80 with StorageDomainStatic

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

the class AbstractOpenStackStorageProviderProxy method addStorageDomain.

protected Guid addStorageDomain(StorageType storageType, StorageDomainType storageDomainType) {
    // Storage domain static
    StorageDomainStatic domainStaticEntry = new StorageDomainStatic();
    domainStaticEntry.setId(Guid.newGuid());
    domainStaticEntry.setStorage(provider.getId().toString());
    domainStaticEntry.setStorageName(provider.getName());
    domainStaticEntry.setDescription(provider.getDescription());
    domainStaticEntry.setStorageFormat(StorageFormatType.V1);
    domainStaticEntry.setStorageType(storageType);
    domainStaticEntry.setStorageDomainType(storageDomainType);
    domainStaticEntry.setWipeAfterDelete(false);
    domainStaticEntry.setDiscardAfterDelete(false);
    getDbFacade().getStorageDomainStaticDao().save(domainStaticEntry);
    // Storage domain dynamic
    StorageDomainDynamic domainDynamicEntry = new StorageDomainDynamic();
    domainDynamicEntry.setId(domainStaticEntry.getId());
    getDbFacade().getStorageDomainDynamicDao().save(domainDynamicEntry);
    return domainStaticEntry.getId();
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)

Aggregations

StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)92 Guid (org.ovirt.engine.core.compat.Guid)39 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)35 ArrayList (java.util.ArrayList)33 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)31 Test (org.junit.Test)23 Pair (org.ovirt.engine.core.common.utils.Pair)19 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)18 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)15 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)14 List (java.util.List)13 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)13 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)13 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 HashSet (java.util.HashSet)11 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)11 ActionType (org.ovirt.engine.core.common.action.ActionType)11 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)10