use of com.sequenceiq.cloudbreak.cloud.model.CloudResource.ATTRIBUTES in project cloudbreak by hortonworks.
the class InstanceMetaDataService method getAzFromDiskOrNullIfRepair.
@VisibleForTesting
String getAzFromDiskOrNullIfRepair(Stack stack, boolean repair, String instanceGroup, String hostname) {
String availabilityZone = null;
if (repair) {
ResourceType resourceType = getSupportedReattachableDiskType(stack);
if (resourceType != null) {
List<CloudResource> reattachableDiskResources = resourceRetriever.findAllByStatusAndTypeAndStackAndInstanceGroup(CommonStatus.DETACHED, resourceType, stack.getId(), instanceGroup);
Optional<CloudResource> reattachableDiskResource = reattachableDiskResources.stream().filter(d -> d.getParameter(ATTRIBUTES, VolumeSetAttributes.class).getDiscoveryFQDN().equals(hostname)).findFirst();
if (reattachableDiskResource.isPresent()) {
VolumeSetAttributes volumeSetAttributes = reattachableDiskResource.get().getParameter(ATTRIBUTES, VolumeSetAttributes.class);
availabilityZone = volumeSetAttributes.getAvailabilityZone();
LOGGER.debug("Found AZ for the {}: {}", resourceType, availabilityZone);
} else {
LOGGER.debug("Cannot find {} for {} in instanceGroup of {}", resourceType, hostname, instanceGroup);
}
}
}
return availabilityZone;
}
Aggregations