Search in sources :

Example 1 with AwsTargetGroupResponse

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse in project cloudbreak by hortonworks.

the class LoadBalancerToLoadBalancerResponseConverter method convertAwsTargetGroup.

private AwsTargetGroupResponse convertAwsTargetGroup(AwsTargetGroupConfigDb awsConfig, Integer port) {
    if (awsConfig != null) {
        Optional<AwsTargetGroupArnsDb> arns = awsConfig.getPortArnMapping().entrySet().stream().filter(entry -> entry.getKey().equals(port)).map(Map.Entry::getValue).findFirst();
        if (arns.isPresent()) {
            AwsTargetGroupResponse awsSettings = new AwsTargetGroupResponse();
            awsSettings.setListenerArn(arns.get().getListenerArn());
            awsSettings.setTargetGroupArn(arns.get().getTargetGroupArn());
            return awsSettings;
        }
    }
    return null;
}
Also used : AwsTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse) AwsTargetGroupArnsDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupArnsDb) Map(java.util.Map)

Example 2 with AwsTargetGroupResponse

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse in project cloudbreak by hortonworks.

the class LoadBalancerToLoadBalancerResponseConverterTest method testConvertAws.

@Test
public void testConvertAws() {
    LoadBalancer source = getSource();
    // GIVEN
    getSource().setProviderConfig(createAwsLoadBalancerConfig());
    given(targetGroupService.findByLoadBalancerId(any())).willReturn(createAwsTargetGroups());
    // WHEN
    LoadBalancerResponse response = underTest.convert(source);
    // THEN
    assertAllFieldsNotNull(response, List.of("azureResourceId", "gcpResourceId"));
    assertEquals(LB_ARN, response.getAwsResourceId().getArn());
    assertEquals(1, response.getTargets().size());
    TargetGroupResponse targetGroupResponse = response.getTargets().get(0);
    assertEquals(PORT, targetGroupResponse.getPort());
    assertEquals(Set.of(INSTANCE_ID), targetGroupResponse.getTargetInstances());
    AwsTargetGroupResponse awsTargetGroupResponse = targetGroupResponse.getAwsResourceIds();
    assertNotNull(awsTargetGroupResponse);
    assertEquals(LISTENER_ARN, awsTargetGroupResponse.getListenerArn());
    assertEquals(TG_ARN, awsTargetGroupResponse.getTargetGroupArn());
}
Also used : LoadBalancerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse) AwsTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) AzureTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse) AwsTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse) GcpTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse) TargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.TargetGroupResponse) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Aggregations

AwsTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse)2 AzureTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse)1 GcpTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse)1 LoadBalancerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse)1 TargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.TargetGroupResponse)1 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)1 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)1 AwsTargetGroupArnsDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.aws.AwsTargetGroupArnsDb)1 Map (java.util.Map)1 Test (org.junit.Test)1