Search in sources :

Example 1 with Volume

use of com.woorea.openstack.cinder.model.Volume in project ovirt-engine by oVirt.

the class GetUnregisteredCinderDisksByStorageDomainIdQueryTest method setUpDisks.

private void setUpDisks() {
    Volume existingVolume = volumes.get(1);
    List<Disk> existingDisks = new ArrayList<>(CinderBroker.volumesToCinderDisks(Collections.singletonList(existingVolume), getQueryParameters().getId()));
    when(diskDao.getAllFromDisksByDiskStorageType(DiskStorageType.CINDER, getUser().getId(), false)).thenReturn(existingDisks);
}
Also used : Volume(com.woorea.openstack.cinder.model.Volume) ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 2 with Volume

use of com.woorea.openstack.cinder.model.Volume in project ovirt-engine by oVirt.

the class GetUnregisteredCinderDisksByStorageDomainIdQueryTest method setUpVolumes.

private void setUpVolumes() {
    volumes = new ArrayList<>(3);
    for (int i = 0; i < 3; ++i) {
        Volume v = mock(Volume.class);
        when(v.getId()).thenReturn(Guid.newGuid().toString());
        when(v.getName()).thenReturn("volume" + i);
        when(v.getSize()).thenReturn(i);
        when(v.getCreatedAt()).thenReturn(new SimpleDateFormat(CinderBroker.DATE_FORMAT).format(new Date()));
        volumes.add(v);
    }
    when(provider.getVolumes()).thenReturn(volumes);
    doReturn(provider).when(getQuery()).getVolumeProviderProxy();
}
Also used : Volume(com.woorea.openstack.cinder.model.Volume) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 3 with Volume

use of com.woorea.openstack.cinder.model.Volume in project ovirt-engine by oVirt.

the class CinderBroker method getDiskStatus.

public ImageStatus getDiskStatus(final Guid id) {
    return execute(() -> {
        Volume volume = proxy.getVolumeById(id.toString());
        CinderVolumeStatus cinderVolumeStatus = CinderVolumeStatus.forValue(volume.getStatus());
        return mapCinderVolumeStatusToImageStatus(cinderVolumeStatus);
    });
}
Also used : Volume(com.woorea.openstack.cinder.model.Volume) CinderVolumeStatus(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeStatus)

Example 4 with Volume

use of com.woorea.openstack.cinder.model.Volume in project ovirt-engine by oVirt.

the class GetUnregisteredCinderDiskByIdAndStorageDomainIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    Disk diskFromDao = diskDao.get(getParameters().getEntityId());
    if (diskFromDao != null) {
        log.info("The disk already exist in the DB, hence, should not be fetched from Cinder. ID: '{}', Alias: '{}'", diskFromDao.getId(), diskFromDao.getDiskAlias());
        getQueryReturnValue().setReturnValue(null);
        return;
    }
    String volumeId = getParameters().getEntityId().toString();
    Volume volume = getVolumeProviderProxy().getVolumeById(volumeId);
    if (volume == null) {
        log.info("The volume doesn't exist in Cinder. ID: '{}'", volumeId);
        getQueryReturnValue().setReturnValue(null);
        return;
    }
    Guid storageDomainId = getParameters().getId();
    CinderDisk unregisteredDisk = CinderBroker.volumeToCinderDisk(volume, storageDomainId);
    getQueryReturnValue().setReturnValue(unregisteredDisk);
}
Also used : Volume(com.woorea.openstack.cinder.model.Volume) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 5 with Volume

use of com.woorea.openstack.cinder.model.Volume in project ovirt-engine by oVirt.

the class GetUnregisteredCinderDisksByStorageDomainIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    final List<Volume> allVolumes = getVolumeProviderProxy().getVolumes();
    final List<Disk> registeredDisks = diskDao.getAllFromDisksByDiskStorageType(DiskStorageType.CINDER, getUserID(), getParameters().isFiltered());
    Set<String> registeredIDs = registeredDisks.stream().map(d -> d.getId().toString()).collect(Collectors.toSet());
    List<Volume> unregisteredVolumes = allVolumes.stream().filter(v -> !registeredIDs.contains(v.getId())).collect(Collectors.toList());
    Guid storageDomainId = getParameters().getId();
    List<CinderDisk> unregisteredDisks = CinderBroker.volumesToCinderDisks(unregisteredVolumes, storageDomainId);
    getQueryReturnValue().setReturnValue(unregisteredDisks);
}
Also used : Inject(javax.inject.Inject) Volume(com.woorea.openstack.cinder.model.Volume) List(java.util.List) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskDao(org.ovirt.engine.core.dao.DiskDao) Guid(org.ovirt.engine.core.compat.Guid) Set(java.util.Set) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Collectors(java.util.stream.Collectors) EngineContext(org.ovirt.engine.core.bll.context.EngineContext) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Volume(com.woorea.openstack.cinder.model.Volume) Guid(org.ovirt.engine.core.compat.Guid) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Aggregations

Volume (com.woorea.openstack.cinder.model.Volume)5 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 Guid (org.ovirt.engine.core.compat.Guid)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 EngineContext (org.ovirt.engine.core.bll.context.EngineContext)1 CinderVolumeStatus (org.ovirt.engine.core.common.businessentities.storage.CinderVolumeStatus)1 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 DiskDao (org.ovirt.engine.core.dao.DiskDao)1