use of com.sequenceiq.cloudbreak.cloud.openstack.view.CinderVolumeView in project cloudbreak by hortonworks.
the class OpenStackAttachedDiskResourceBuilder method build.
@Override
public List<CloudResource> build(OpenStackContext context, long privateId, AuthenticatedContext auth, Group group, Image image, List<CloudResource> buildableResource, Map<String, String> tags) throws Exception {
List<CloudResource> resources = new ArrayList<>();
List<CloudResource> syncedResources = Collections.synchronizedList(resources);
Collection<Future<Void>> futures = new ArrayList<>();
for (CloudResource cloudResource : buildableResource) {
Future<Void> submit = intermediateBuilderExecutor.submit(() -> {
CinderVolumeView volumeView = cloudResource.getParameter(VOLUME_VIEW, CinderVolumeView.class);
Volume osVolume = Builders.volume().name(cloudResource.getName()).size(volumeView.getSize()).build();
try {
OSClient<?> osClient = createOSClient(auth);
osVolume = osClient.blockStorage().volumes().create(osVolume);
CloudResource newRes = createPersistedResource(cloudResource, group.getName(), osVolume.getId());
newRes.putParameter(OpenStackConstants.VOLUME_MOUNT_POINT, volumeView.getDevice());
syncedResources.add(newRes);
} catch (OS4JException ex) {
throw new OpenStackResourceException("Volume creation failed", resourceType(), cloudResource.getName(), ex);
}
return null;
});
futures.add(submit);
}
for (Future<Void> future : futures) {
future.get();
}
return resources;
}
Aggregations