Search in sources :

Example 1 with AzureTargetGroupResponse

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

the class LoadBalancerToLoadBalancerResponseConverter method convertAzureTargetGroup.

private AzureTargetGroupResponse convertAzureTargetGroup(AzureTargetGroupConfigDb azureConfig, Integer port) {
    if (azureConfig != null) {
        List<String> availabilitySets = azureConfig.getPortAvailabilitySetMapping().get(port);
        AzureTargetGroupResponse azureSettings = new AzureTargetGroupResponse();
        azureSettings.setAvailabilitySet(availabilitySets);
        return azureSettings;
    }
    return null;
}
Also used : AzureTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse)

Example 2 with AzureTargetGroupResponse

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

the class LoadBalancerToLoadBalancerResponseConverterTest method testConvertAzure.

@Test
public void testConvertAzure() {
    LoadBalancer source = getSource();
    // GIVEN
    getSource().setProviderConfig(createAzureLoadBalancerConfig());
    given(targetGroupService.findByLoadBalancerId(any())).willReturn(createAzureTargetGroups());
    // WHEN
    LoadBalancerResponse response = underTest.convert(source);
    // THEN
    assertAllFieldsNotNull(response, List.of("awsResourceId", "gcpResourceId"));
    assertEquals(AZURE_LB_NAME, response.getAzureResourceId().getName());
    assertEquals(1, response.getTargets().size());
    TargetGroupResponse targetGroupResponse = response.getTargets().get(0);
    assertEquals(PORT, targetGroupResponse.getPort());
    assertEquals(Set.of(INSTANCE_ID), targetGroupResponse.getTargetInstances());
    AzureTargetGroupResponse azureTargetGroupResponse = targetGroupResponse.getAzureResourceId();
    assertNotNull(azureTargetGroupResponse);
    assertEquals(List.of(AZURE_AS_NAME), azureTargetGroupResponse.getAvailabilitySet());
}
Also used : LoadBalancerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse) AzureTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse) 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

AzureTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse)2 AwsTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse)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 Test (org.junit.Test)1