use of com.sequenceiq.cloudbreak.domain.view.ClusterTemplateStackApiView in project cloudbreak by hortonworks.
the class ClusterTemplateViewToClusterTemplateViewV4ResponseConverter method convert.
public ClusterTemplateViewV4Response convert(ClusterTemplateView source) {
ClusterTemplateViewV4Response clusterTemplateViewV4Response = new ClusterTemplateViewV4Response();
clusterTemplateViewV4Response.setName(source.getName());
clusterTemplateViewV4Response.setDescription(source.getDescription());
clusterTemplateViewV4Response.setCrn(source.getResourceCrn());
clusterTemplateViewV4Response.setCloudPlatform(source.getCloudPlatform());
clusterTemplateViewV4Response.setStatus(source.getStatus());
clusterTemplateViewV4Response.setId(source.getId());
clusterTemplateViewV4Response.setDatalakeRequired(source.getDatalakeRequired());
clusterTemplateViewV4Response.setStatus(source.getStatus());
clusterTemplateViewV4Response.setType(source.getType());
clusterTemplateViewV4Response.setFeatureState(source.getFeatureState());
if (source.getStackTemplate() != null) {
ClusterTemplateStackApiView stackTemplate = source.getStackTemplate();
clusterTemplateViewV4Response.setNodeCount(getFullNodeCount(stackTemplate));
if (stackTemplate.getCluster() != null) {
ClusterTemplateClusterApiView cluster = stackTemplate.getCluster();
clusterTemplateViewV4Response.setStackType(cluster.getBlueprint() != null ? cluster.getBlueprint().getStackType() : "");
clusterTemplateViewV4Response.setStackVersion(cluster.getBlueprint() != null ? cluster.getBlueprint().getStackVersion() : "");
}
if (stackTemplate.getEnvironmentCrn() != null) {
clusterTemplateViewV4Response.setEnvironmentCrn(stackTemplate.getEnvironmentCrn());
}
} else if (source.getStatus().isDefault()) {
try {
DistroXV1Request distroXV1Request = new Json(getTemplateString(source.getTemplateContent())).get(DefaultClusterTemplateV4Request.class).getDistroXTemplate();
clusterTemplateViewV4Response.setNodeCount(getFullNodeCount(distroXV1Request));
clusterTemplateViewV4Response.setStackType("CDH");
clusterTemplateViewV4Response.setStackVersion(source.getClouderaRuntimeVersion());
} catch (IOException e) {
LOGGER.error("CDP was not able to convert back {} template: {}", source.getName(), e.getMessage());
throw new CloudbreakServiceException("CDP was not able to give back your template: ", e);
}
}
clusterTemplateViewV4Response.setCreated(source.getCreated());
return clusterTemplateViewV4Response;
}
Aggregations