Search in sources :

Example 1 with OpenStackVolumeProviderProxy

use of org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy in project ovirt-engine by oVirt.

the class CinderDisksValidator method initializeVolumeProviderProxyMap.

private Map<Guid, OpenStackVolumeProviderProxy> initializeVolumeProviderProxyMap() {
    if (diskProxyMap == null) {
        diskProxyMap = new HashMap<>();
        for (CinderDisk cinderDisk : cinderDisks) {
            OpenStackVolumeProviderProxy volumeProviderProxy = getVolumeProviderProxy(cinderDisk);
            diskProxyMap.put(cinderDisk.getId(), volumeProviderProxy);
        }
    }
    return diskProxyMap;
}
Also used : CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) OpenStackVolumeProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy)

Example 2 with OpenStackVolumeProviderProxy

use of org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy in project ovirt-engine by oVirt.

the class CINDERStorageHelper method activateCinderDomain.

public void activateCinderDomain(Guid storageDomainId, Guid storagePoolId) {
    OpenStackVolumeProviderProxy proxy = OpenStackVolumeProviderProxy.getFromStorageDomainId(storageDomainId, providerProxyFactory);
    if (proxy == null) {
        log.error("Couldn't create an OpenStackVolumeProviderProxy for storage domain ID: {}", storageDomainId);
        return;
    }
    try {
        proxy.testConnection();
        updateCinderDomainStatus(storageDomainId, storagePoolId, StorageDomainStatus.Active);
    } catch (EngineException e) {
        AuditLogable loggable = new AuditLogableImpl();
        loggable.addCustomValue("CinderException", e.getCause().getCause() != null ? e.getCause().getCause().getMessage() : e.getCause().getMessage());
        auditLogDirector.log(loggable, AuditLogType.CINDER_PROVIDER_ERROR);
        throw e;
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) EngineException(org.ovirt.engine.core.common.errors.EngineException) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) OpenStackVolumeProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy)

Example 3 with OpenStackVolumeProviderProxy

use of org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy in project ovirt-engine by oVirt.

the class CinderDisksValidator method validateCinderVolumeTypesExist.

/**
 * Validates that the disk's volume type exists in Cinder
 * (note that this method validates only against a single disk).
 */
public ValidationResult validateCinderVolumeTypesExist() {
    return validate(() -> {
        final CinderDisk disk = cinderDisks.iterator().next();
        OpenStackVolumeProviderProxy proxy = diskProxyMap.get(disk.getId());
        List<CinderVolumeType> volumeTypes = proxy.getVolumeTypes();
        boolean volumeTypeExists = volumeTypes.stream().anyMatch(v -> v.getName().equals(disk.getCinderVolumeType()));
        if (!volumeTypeExists) {
            return new ValidationResult(EngineMessage.CINDER_VOLUME_TYPE_NOT_EXISTS, String.format("$cinderVolumeType %s", disk.getCinderVolumeType()));
        }
        return ValidationResult.VALID;
    });
}
Also used : CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) OpenStackVolumeProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy)

Example 4 with OpenStackVolumeProviderProxy

use of org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy in project ovirt-engine by oVirt.

the class CinderDisksValidator method getRelatedCinderDisksToStorageDomainMap.

private Map<Guid, CinderStorageRelatedDisksAndProxy> getRelatedCinderDisksToStorageDomainMap() {
    if (cinderStorageToRelatedDisks == null) {
        cinderStorageToRelatedDisks = new HashMap<>();
        for (CinderDisk cinderDisk : cinderDisks) {
            Guid storageDomainId = cinderDisk.getStorageIds().get(0);
            CinderStorageRelatedDisksAndProxy cinderRelatedDisksAndProxy = cinderStorageToRelatedDisks.get(storageDomainId);
            if (cinderRelatedDisksAndProxy == null) {
                List<CinderDisk> cinderDisks = new ArrayList<>();
                cinderDisks.add(cinderDisk);
                OpenStackVolumeProviderProxy proxy = diskProxyMap.get(cinderDisk.getId());
                CinderStorageRelatedDisksAndProxy newCinderRelatedDisksAndProxy = new CinderStorageRelatedDisksAndProxy(storageDomainId, cinderDisks, proxy);
                cinderStorageToRelatedDisks.put(storageDomainId, newCinderRelatedDisksAndProxy);
            } else {
                cinderRelatedDisksAndProxy.getCinderDisks().add(cinderDisk);
            }
        }
    }
    return cinderStorageToRelatedDisks;
}
Also used : ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) OpenStackVolumeProviderProxy(org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy)

Aggregations

OpenStackVolumeProviderProxy (org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy)4 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)3 ArrayList (java.util.ArrayList)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 CinderVolumeType (org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 Guid (org.ovirt.engine.core.compat.Guid)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)1