Search in sources :

Example 1 with ClusterTemplateClusterApiView

use of com.sequenceiq.cloudbreak.domain.view.ClusterTemplateClusterApiView 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;
}
Also used : ClusterTemplateStackApiView(com.sequenceiq.cloudbreak.domain.view.ClusterTemplateStackApiView) ClusterTemplateClusterApiView(com.sequenceiq.cloudbreak.domain.view.ClusterTemplateClusterApiView) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ClusterTemplateViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)

Aggregations

ClusterTemplateViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 ClusterTemplateClusterApiView (com.sequenceiq.cloudbreak.domain.view.ClusterTemplateClusterApiView)1 ClusterTemplateStackApiView (com.sequenceiq.cloudbreak.domain.view.ClusterTemplateStackApiView)1 DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)1 IOException (java.io.IOException)1