use of com.sequenceiq.cloudbreak.cloud.model.CloudResource.PRIVATE_ID in project cloudbreak by hortonworks.
the class VolumeMatcher method addVolumeResourcesToContext.
public ResourceBuilderContext addVolumeResourcesToContext(List<CloudInstance> instances, List<CloudResource> groupInstances, List<CloudResource> groupVolumeSets, ResourceBuilderContext context) {
List<CloudResource> groupVolumeSetsWithFQDN = getGroupVolumeSetsWithFQDN(groupVolumeSets);
List<CloudResource> groupVolumeSetsWithoutFQDN = getGroupVolumeSetsWithoutFQDN(groupVolumeSets);
List<CloudResource> groupInstancesWithoutPrivateId = groupInstances.stream().filter(groupInstance -> groupInstance.getParameter(PRIVATE_ID, Long.class) == null).collect(Collectors.toList());
for (int i = 0; i < instances.size() && i < groupInstances.size(); i++) {
CloudInstance cloudInstance = instances.get(i);
LOGGER.info("Check volumes for instance: {}", cloudInstance);
CloudResource instanceResource = getCloudResource(groupInstances, groupInstancesWithoutPrivateId, cloudInstance);
LOGGER.info("Instance resource: {}", instanceResource);
Optional<CloudResource> volumeSetForFQDN = getVolumeSetForFQDN(groupVolumeSetsWithFQDN, cloudInstance);
volumeSetForFQDN.ifPresent(cloudResource -> LOGGER.info("Volume set for this fqdn: {}", cloudResource));
List<CloudResource> computeResource = volumeSetForFQDN.map(groupVolumeSet -> List.of(instanceResource, groupVolumeSet)).orElseGet(() -> getComputeResourceFromVolumesWithoutFQDN(groupVolumeSetsWithoutFQDN, instanceResource));
LOGGER.info("Add volume resources {} to instance with private id: {}", computeResource, cloudInstance.getTemplate().getPrivateId());
context.addComputeResources(cloudInstance.getTemplate().getPrivateId(), computeResource);
}
return context;
}
Aggregations