Search in sources :

Example 11 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXServiceTest method testWithNotAvailableEnvironmentButFreeipaAvailableAndRunWithoutException.

@Test
void testWithNotAvailableEnvironmentButFreeipaAvailableAndRunWithoutException() throws IllegalAccessException {
    String envName = "someAwesomeEnvironment";
    DistroXV1Request request = new DistroXV1Request();
    request.setEnvironmentName(envName);
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setEnvironmentStatus(START_DATAHUB_STARTED);
    envResponse.setCrn("crn");
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    freeipa.setStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE);
    when(freeipaClientService.getByEnvironmentCrn("crn")).thenReturn(freeipa);
    when(environmentClientService.getByName(envName)).thenReturn(envResponse);
    when(platformAwareSdxConnector.listSdxCrns(any(), any())).thenReturn(Set.of(DATALAKE_CRN));
    underTest.post(request);
    verify(platformAwareSdxConnector).listSdxCrns(any(), any());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request 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)

Example 13 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class ClusterTemplateTestUtil method createDistroXV1Request.

private static DistroXV1Request createDistroXV1Request() {
    DistroXV1Request r = new DistroXV1Request();
    r.setEnvironmentName(TEST_ENVIRONMENT_NAME);
    return r;
}
Also used : DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)

Example 14 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class ClusterTemplateLoaderServiceTest method clusterTemplateRequest.

private DefaultClusterTemplateV4Request clusterTemplateRequest(String templateName) {
    DefaultClusterTemplateV4Request clusterTemplate = new DefaultClusterTemplateV4Request();
    clusterTemplate.setName(templateName);
    DistroXV1Request distrox = new DistroXV1Request();
    DistroXClusterV1Request cluster = new DistroXClusterV1Request();
    distrox.setCluster(cluster);
    InstanceGroupV1Request instanceGroup = new InstanceGroupV1Request();
    instanceGroup.setName("master");
    distrox.setInstanceGroups(singleton(instanceGroup));
    clusterTemplate.setDistroXTemplate(distrox);
    return clusterTemplate;
}
Also used : InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) DefaultClusterTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.requests.DefaultClusterTemplateV4Request) DistroXClusterV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXClusterV1Request) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)

Example 15 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverterTest method testWhenTagsProvidedTheyWillBePassedForStackConversion.

@Test
void testWhenTagsProvidedTheyWillBePassedForStackConversion() {
    when(databaseRequestConverter.convert(any(DatabaseRequest.class))).thenReturn(createDistroXDatabaseRequest());
    StackV4Request source = new StackV4Request();
    source.setName("stackname");
    DatabaseRequest databaseRequest = new DatabaseRequest();
    databaseRequest.setAvailabilityType(DatabaseAvailabilityType.HA);
    source.setExternalDatabase(databaseRequest);
    TagsV4Request tags = createTagsV4Request();
    source.setTags(tags);
    DistroXV1Request result = underTest.convert(source);
    assertThat(result.getExternalDatabase()).isNotNull();
    assertThat(result.getExternalDatabase().getAvailabilityType()).isEqualTo(DistroXDatabaseAvailabilityType.HA);
    checkTagsV4WithV1(tags, result.getTags());
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DatabaseRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseRequest) DistroXDatabaseRequest(com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseRequest) TagsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)21 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)12 Test (org.junit.jupiter.api.Test)12 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)8 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)4 DistroXDatabaseRequest (com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseRequest)4 InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)3 DisplayName (org.junit.jupiter.api.DisplayName)3 DatabaseRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseRequest)2 TagsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request)2 EnvironmentClientService (com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService)2 NullUtil.getIfNotNull (com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull)2 DistroXClusterV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXClusterV1Request)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Inject (javax.inject.Inject)2 DefaultClusterTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.requests.DefaultClusterTemplateV4Request)1 ClusterTemplateViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response)1