Search in sources :

Example 71 with StackV4Request

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

the class GatewayManifester method configureGatewayForSdxCluster.

public StackV4Request configureGatewayForSdxCluster(StackV4Request stackV4Request) {
    if (stackV4Request.getCluster().getGateway() == null) {
        GatewayV4Request gatewayV4Request = new GatewayV4Request();
        gatewayV4Request.setTopologies(List.of(getGatewayTopologyV4Request()));
        gatewayV4Request.setSsoType(defaultSsoType);
        stackV4Request.getCluster().setGateway(gatewayV4Request);
        LOGGER.info("Configured gateway for SDX {}", stackV4Request.getName());
    }
    return stackV4Request;
}
Also used : GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)

Example 72 with StackV4Request

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

the class StackV4RequestToStackConverter method setInstanceGroupNetworkIfApplicable.

private void setInstanceGroupNetworkIfApplicable(StackV4Request source, Stack stack, DetailedEnvironmentResponse environment) {
    String subnetId = getStackSubnetIdIfExists(stack);
    List<InstanceGroupV4Request> instanceGroups = source.getInstanceGroups();
    for (InstanceGroupV4Request instanceGroup : instanceGroups) {
        if (instanceGroup.getNetwork() == null) {
            InstanceGroupNetworkV4Request instanceGroupNetworkV4Request = new InstanceGroupNetworkV4Request();
            setNetworkByProvider(source, instanceGroup, instanceGroupNetworkV4Request, subnetId);
        }
        setupEndpointGatewayNetwork(instanceGroup.getNetwork(), stack, instanceGroup.getName(), environment);
    }
}
Also used : InstanceGroupNetworkV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.network.InstanceGroupNetworkV4Request) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

Example 73 with StackV4Request

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

the class ClusterTemplateToClusterTemplateV4ResponseConverter method convert.

public ClusterTemplateV4Response convert(ClusterTemplate source) {
    ClusterTemplateV4Response clusterTemplateV4Response = new ClusterTemplateV4Response();
    clusterTemplateV4Response.setName(source.getName());
    clusterTemplateV4Response.setDescription(source.getDescription());
    if (source.getStatus().isNonDefault()) {
        Optional<Stack> stack = stackTemplateService.getByIdWithLists(source.getStackTemplate().getId());
        if (stack.isPresent()) {
            StackV4Request stackV4Request;
            try {
                stackV4Request = stackToStackV4RequestConverter.convert(stack.get());
            } catch (Exception e) {
                stackV4Request = null;
            }
            clusterTemplateV4Response.setDistroXTemplate(getIfNotNull(stackV4Request, stackV4RequestConverter::convert));
            clusterTemplateV4Response.setNodeCount(stack.get().getFullNodeCount());
        }
    } else {
        try {
            DefaultClusterTemplateV4Request clusterTemplateV4Request = new Json(getTemplateString(source)).get(DefaultClusterTemplateV4Request.class);
            clusterTemplateV4Response.setDistroXTemplate(clusterTemplateV4Request.getDistroXTemplate());
            clusterTemplateV4Response.setNodeCount(getFullNodeCount(clusterTemplateV4Request.getDistroXTemplate()));
        } catch (IOException e) {
            LOGGER.info("There is no Data Hub template (stack entity missing) for cluster defintion {}", source.getName());
            clusterTemplateV4Response.setDistroXTemplate(null);
        }
    }
    clusterTemplateV4Response.setCloudPlatform(source.getCloudPlatform());
    clusterTemplateV4Response.setStatus(source.getStatus());
    clusterTemplateV4Response.setId(source.getId());
    clusterTemplateV4Response.setDatalakeRequired(source.getDatalakeRequired());
    clusterTemplateV4Response.setCrn(source.getResourceCrn());
    clusterTemplateV4Response.setStatus(source.getStatus());
    clusterTemplateV4Response.setType(source.getType());
    clusterTemplateV4Response.setFeatureState(source.getFeatureState());
    if (source.getStackTemplate() != null) {
        Stack stackTemplate = source.getStackTemplate();
        if (stackTemplate.getEnvironmentCrn() != null) {
            clusterTemplateV4Response.setEnvironmentCrn(stackTemplate.getEnvironmentCrn());
        }
        if (source.getStackTemplate().getCluster() != null && source.getStackTemplate().getCluster().getBlueprint() != null) {
            clusterTemplateV4Response.setStackType(source.getStackTemplate().getCluster().getBlueprint().getStackType());
            clusterTemplateV4Response.setStackVersion(source.getStackTemplate().getCluster().getBlueprint().getStackVersion());
        }
    } else {
        clusterTemplateV4Response.setStackType("CDH");
        clusterTemplateV4Response.setStackVersion(source.getClouderaRuntimeVersion());
    }
    clusterTemplateV4Response.setCreated(source.getCreated());
    return clusterTemplateV4Response;
}
Also used : ClusterTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateV4Response) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DefaultClusterTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.requests.DefaultClusterTemplateV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException) IOException(java.io.IOException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 74 with StackV4Request

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

the class ClusterTemplateToDefaultClusterTemplateV4Request method convert.

public DefaultClusterTemplateV4Request convert(ClusterTemplate source) {
    DefaultClusterTemplateV4Request ret = new DefaultClusterTemplateV4Request();
    ret.setCloudPlatform(source.getCloudPlatform());
    ret.setDatalakeRequired(source.getDatalakeRequired());
    ret.setDescription(source.getDescription());
    ret.setName(source.getName());
    ret.setType(source.getType());
    StackV4Request stackV4Request = stackToStackV4RequestConverter.convert(source.getStackTemplate());
    ret.setDistroXTemplate(stackV4RequestConverter.convert(stackV4Request));
    return ret;
}
Also used : DefaultClusterTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.requests.DefaultClusterTemplateV4Request) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)

Example 75 with StackV4Request

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

the class LoadBalancerConfigServiceTest method testCreateLoadBalancersForEndpointGatewayDatalake.

@Test
public void testCreateLoadBalancersForEndpointGatewayDatalake() {
    Stack stack = createAwsStack(StackType.DATALAKE, PRIVATE_ID_1);
    CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    DetailedEnvironmentResponse environment = createEnvironment(subnet, true, "AWS");
    StackV4Request request = new StackV4Request();
    request.setEnableLoadBalancer(false);
    when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
    when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
        assertEquals(2, loadBalancers.size());
        assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.PRIVATE.equals(l.getType()));
        assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.PUBLIC.equals(l.getType()));
    });
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.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