Search in sources :

Example 1 with CinderVolumeType

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

the class BackendOpenStackVolumeTypeResourceTest method getEntity.

@Override
protected CinderVolumeType getEntity(int index) {
    CinderVolumeType cinderVolumeType = mock(CinderVolumeType.class);
    when(cinderVolumeType.getId()).thenReturn(GUIDS[index].toString());
    when(cinderVolumeType.getName()).thenReturn(NAMES[index]);
    return cinderVolumeType;
}
Also used : CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType)

Example 2 with CinderVolumeType

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

the class BackendOpenStackVolumeTypesResourceTest method getEntity.

@Override
protected CinderVolumeType getEntity(int index) {
    CinderVolumeType cinderVolumeType = mock(CinderVolumeType.class);
    when(cinderVolumeType.getId()).thenReturn(GUIDS[index].toString());
    when(cinderVolumeType.getName()).thenReturn(NAMES[index]);
    return cinderVolumeType;
}
Also used : CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType)

Example 3 with CinderVolumeType

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

the class BackendOpenStackVolumeTypeResource method get.

@Override
public OpenStackVolumeType get() {
    Guid storageDomainId = BackendOpenStackStorageProviderHelper.getStorageDomainId(this, providerId);
    IdQueryParameters parameters = new IdQueryParameters(storageDomainId);
    List<CinderVolumeType> volumeTypes = getBackendCollection(CinderVolumeType.class, QueryType.GetCinderVolumeTypesByStorageDomainId, parameters);
    return volumeTypes.stream().filter(v -> v.getId().equals(id)).findFirst().map(v -> addLinks(populate(map(v), v))).orElseGet(this::notFound);
}
Also used : AbstractBackendActionableResource(org.ovirt.engine.api.restapi.resource.AbstractBackendActionableResource) QueryType(org.ovirt.engine.core.common.queries.QueryType) List(java.util.List) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) OpenStackVolumeType(org.ovirt.engine.api.model.OpenStackVolumeType) Guid(org.ovirt.engine.core.compat.Guid) OpenStackVolumeProvider(org.ovirt.engine.api.model.OpenStackVolumeProvider) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) OpenstackVolumeTypeResource(org.ovirt.engine.api.resource.openstack.OpenstackVolumeTypeResource) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 4 with CinderVolumeType

use of org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType 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 5 with CinderVolumeType

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

the class OpenStackVolumeProviderProxy method getVolumeTypes.

public List<CinderVolumeType> getVolumeTypes() {
    ArrayList<CinderVolumeType> cinderVolumeTypes = new ArrayList<>();
    OpenStackRequest<VolumeTypes> listRequest = getClient(getTenantId()).volumeTypes().list();
    VolumeTypes volumeTypes = listRequest.execute();
    for (VolumeType volumeType : volumeTypes) {
        CinderVolumeType cinderVolumeType = new CinderVolumeType(volumeType.getId(), volumeType.getName(), volumeType.getExtraSpecs());
        cinderVolumeTypes.add(cinderVolumeType);
    }
    return cinderVolumeTypes;
}
Also used : CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) VolumeTypes(com.woorea.openstack.cinder.model.VolumeTypes) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) VolumeType(com.woorea.openstack.cinder.model.VolumeType) ArrayList(java.util.ArrayList)

Aggregations

CinderVolumeType (org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 QueryType (org.ovirt.engine.core.common.queries.QueryType)2 Guid (org.ovirt.engine.core.compat.Guid)2 VolumeType (com.woorea.openstack.cinder.model.VolumeType)1 VolumeTypes (com.woorea.openstack.cinder.model.VolumeTypes)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 OpenStackVolumeProvider (org.ovirt.engine.api.model.OpenStackVolumeProvider)1 OpenStackVolumeType (org.ovirt.engine.api.model.OpenStackVolumeType)1 OpenstackVolumeTypeResource (org.ovirt.engine.api.resource.openstack.OpenstackVolumeTypeResource)1 AbstractBackendActionableResource (org.ovirt.engine.api.restapi.resource.AbstractBackendActionableResource)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 OpenStackVolumeProviderProxy (org.ovirt.engine.core.bll.provider.storage.OpenStackVolumeProviderProxy)1