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);
}
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();
}
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);
});
}
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);
}
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);
}
Aggregations