Search in sources :

Example 16 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class DistroXV1RequestToStackV4RequestConverter method convert.

public StackV4Request convert(DistroXV1Request source) {
    DetailedEnvironmentResponse environment = Optional.ofNullable(environmentClientService.getByName(source.getEnvironmentName())).orElseThrow(() -> new BadRequestException("No environment name provided hence unable to obtain some important data"));
    StackV4Request request = new StackV4Request();
    SdxClusterResponse sdxClusterResponse = getSdxClusterResponse(environment);
    request.setName(source.getName());
    request.setType(StackType.WORKLOAD);
    request.setCloudPlatform(getCloudPlatform(environment));
    request.setEnvironmentCrn(environment.getCrn());
    request.setAuthentication(getIfNotNull(environment.getAuthentication(), authenticationConverter::convert));
    request.setImage(getIfNotNull(source.getImage(), imageConverter::convert));
    request.setCluster(getIfNotNull(source, environment, clusterConverter::convert));
    NetworkV4Request network = getNetwork(source.getNetwork(), environment, source.getInstanceGroups());
    request.setNetwork(network);
    request.setInstanceGroups(getIfNotNull(source.getInstanceGroups(), igs -> instanceGroupConverter.convertTo(network, igs, environment)));
    request.setAws(getIfNotNull(source.getAws(), stackParameterConverter::convert));
    request.setAzure(getIfNotNull(source.getAzure(), stackParameterConverter::convert));
    request.setGcp(getIfNotNull(source.getGcp(), stackParameterConverter::convert));
    request.setYarn(getYarnProperties(source, environment));
    request.setInputs(source.getInputs());
    request.setTags(getIfNotNull(source.getTags(), this::getTags));
    request.setPlacement(preparePlacement(environment));
    request.setSharedService(sdxConverter.getSharedService(sdxClusterResponse));
    request.setCustomDomain(null);
    request.setTimeToLive(source.getTimeToLive());
    request.setTelemetry(getTelemetryRequest(environment, sdxClusterResponse));
    request.setGatewayPort(source.getGatewayPort());
    request.setExternalDatabase(getIfNotNull(source.getExternalDatabase(), databaseRequestConverter::convert));
    request.setEnableLoadBalancer(source.isEnableLoadBalancer());
    request.setVariant(source.getVariant());
    checkMultipleGatewayNodes(source);
    return request;
}
Also used : PlacementSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.environment.placement.PlacementSettingsV4Request) InstanceGroupNetworkV1Base(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Base) InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) NullUtil.getIfNotNull(com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) TelemetryConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.TelemetryConverter) LoggerFactory(org.slf4j.LoggerFactory) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TagsV1Request(com.sequenceiq.distrox.api.v1.distrox.model.tags.TagsV1Request) ArrayList(java.util.ArrayList) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) HashSet(java.util.HashSet) Inject(javax.inject.Inject) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) AwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.AwsNetworkV1Parameters) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) NetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) InstanceGroupV1Request(com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request) TagsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) Collection(java.util.Collection) Set(java.util.Set) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) YarnStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.YarnStackV4Parameters) Component(org.springframework.stereotype.Component) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) SdxClientService(com.sequenceiq.cloudbreak.service.datalake.SdxClientService) Optional(java.util.Optional) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) NetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)

Example 17 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestAction method action.

@Override
public StackTestDto action(TestContext testContext, StackTestDto testDto, CloudbreakClient client) throws Exception {
    Log.when(LOGGER, " Stack get cli skeleton:" + testDto.getName());
    StackV4Request request = client.getDefaultClient().stackV4Endpoint().getRequestfromName(client.getWorkspaceId(), testDto.getName(), testContext.getActingUserCrn().getAccountId());
    testDto.setRequest(request);
    Log.whenJson(LOGGER, " get cli skeleton was successfully:\n", testDto.getRequest());
    return testDto;
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)

Example 18 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackV4RequestToGatewayConverterTest method generateStackV4Request.

private StackV4Request generateStackV4Request(GatewayV4Request gateWayJson) {
    ClusterV4Request clusterRequest = new ClusterV4Request();
    clusterRequest.setGateway(gateWayJson);
    StackV4Request source = new StackV4Request();
    source.setName("funnyCluster");
    source.setCluster(clusterRequest);
    return source;
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)

Example 19 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackV4RequestToGatewayConverterTest method shouldCreateCorrectSsoUrlWhenClusterNameisProvided.

@Test
public void shouldCreateCorrectSsoUrlWhenClusterNameisProvided() {
    GatewayV4Request gatewayJson = new GatewayV4Request();
    gatewayJson.setPath("funnyPath");
    gatewayJson.setTopologies(Arrays.asList(getGatewayTopologyV4Request()));
    StackV4Request source = generateStackV4Request(gatewayJson);
    when(gatewayJsonValidator.validate(gatewayJson)).thenReturn(ValidationResult.builder().build());
    doAnswer(i -> {
        Gateway gw = i.getArgument(1);
        gw.setSsoProvider("SSOPROVIDER");
        gw.setPath(gatewayJson.getPath());
        gw.setTopologies(GATEWAY_TOPOLOGY);
        gw.setGatewayType(GatewayType.CENTRAL);
        return null;
    }).when(convertUtil).setBasicProperties(eq(gatewayJson), any(Gateway.class));
    Gateway result = underTest.convert(source);
    assertEquals("SSOPROVIDER", result.getSsoProvider());
    assertEquals("funnyPath", result.getPath());
    assertTrue(EqualsBuilder.reflectionEquals(GATEWAY_TOPOLOGY, result.getTopologies()));
    assertEquals(GatewayType.CENTRAL, result.getGatewayType());
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Test(org.junit.Test)

Example 20 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class DatalakeServiceTest method testPrepareDatalakeRequestWhenDatalakeCrnIsNull.

@Test
public void testPrepareDatalakeRequestWhenDatalakeCrnIsNull() {
    Stack source = new Stack();
    source.setDatalakeCrn(null);
    StackV4Request x = new StackV4Request();
    underTest.prepareDatalakeRequest(source, x);
    verify(stackService, never()).getByCrn("crn");
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)105 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)66 Test (org.junit.jupiter.api.Test)58 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)52 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)36 Test (org.junit.Test)36 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)34 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)33 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)32 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)31 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)17 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)14 Map (java.util.Map)13 Set (java.util.Set)13 Optional (java.util.Optional)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)11 HashMap (java.util.HashMap)11 List (java.util.List)11