Search in sources :

Example 1 with AzureTargetGroupConfigDb

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverter method buildAzureConfig.

private TargetGroupConfigDbWrapper buildAzureConfig(AzureLoadBalancerMetadataView azureMetadata, TargetGroup targetGroup) {
    Set<Integer> trafficPorts = getTrafficPorts(targetGroup);
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
    AzureTargetGroupConfigDb azureTargetGroupConfigDb = new AzureTargetGroupConfigDb();
    for (Integer port : trafficPorts) {
        String availabilitySetName = azureMetadata.getAvailabilitySetByPort(port);
        List<String> availabilitySetNames = List.of(StringUtils.isEmpty(availabilitySetName) ? MISSING_CLOUD_RESOURCE : availabilitySetName);
        azureTargetGroupConfigDb.addPortAvailabilitySetMapping(port, availabilitySetNames);
    }
    targetGroupConfigDbWrapper.setAzureConfig(azureTargetGroupConfigDb);
    return targetGroupConfigDbWrapper;
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) AzureTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb)

Example 2 with AzureTargetGroupConfigDb

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverterTest method testConvertAzureTargetGroupMissingAvailabilitySetInMetadata.

@Test
public void testConvertAzureTargetGroupMissingAvailabilitySetInMetadata() {
    Map<String, Object> azureParams = createAzureParams(1);
    azureParams.put(AzureLoadBalancerMetadataView.getAvailabilitySetParam(PORT2), null);
    CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(azureParams).build();
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    TargetGroupPortPair portPair1 = new TargetGroupPortPair(PORT1, PORT2);
    TargetGroupPortPair portPair2 = new TargetGroupPortPair(PORT2, PORT2);
    TargetGroupPortPair portPair3 = new TargetGroupPortPair(PORT3, PORT3);
    when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair1, portPair2, portPair3));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AZURE, cloudLoadBalancerMetadata, targetGroup);
    assertNotNull(targetGroupConfigDbWrapper.getAzureConfig());
    AzureTargetGroupConfigDb azureTargetGroupConfigDb = targetGroupConfigDbWrapper.getAzureConfig();
    assertEquals(Set.of(PORT1, PORT2, PORT3), azureTargetGroupConfigDb.getPortAvailabilitySetMapping().keySet());
    List<String> availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT1);
    assertEquals(List.of(AVAILABILITY_SET_NAME), availabilitySets);
    availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT2);
    assertEquals(List.of(MISSING_CLOUD_RESOURCE), availabilitySets);
    availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT3);
    assertEquals(List.of(MISSING_CLOUD_RESOURCE), availabilitySets);
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AzureTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.Test)

Example 3 with AzureTargetGroupConfigDb

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.

the class LoadBalancerConfigConverterTest method testConvertAzureTargetGroup.

@Test
public void testConvertAzureTargetGroup() {
    CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(createAzureParams(1)).build();
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setType(TargetGroupType.KNOX);
    TargetGroupPortPair portPair = new TargetGroupPortPair(PORT1, PORT2);
    when(loadBalancerConfigService.getTargetGroupPortPairs(eq(targetGroup))).thenReturn(Set.of(portPair));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = underTest.convertTargetGroup(AZURE, cloudLoadBalancerMetadata, targetGroup);
    assertNotNull(targetGroupConfigDbWrapper.getAzureConfig());
    AzureTargetGroupConfigDb azureTargetGroupConfigDb = targetGroupConfigDbWrapper.getAzureConfig();
    assertEquals(1, azureTargetGroupConfigDb.getPortAvailabilitySetMapping().size());
    assertEquals(PORT1, azureTargetGroupConfigDb.getPortAvailabilitySetMapping().keySet().iterator().next());
    List<String> availabilitySets = azureTargetGroupConfigDb.getPortAvailabilitySetMapping().get(PORT1);
    assertEquals(1, availabilitySets.size());
    assertEquals(AVAILABILITY_SET_NAME, availabilitySets.get(0));
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AzureTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Test(org.junit.Test)

Example 4 with AzureTargetGroupConfigDb

use of com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb in project cloudbreak by hortonworks.

the class LoadBalancerToLoadBalancerResponseConverterTest method createAzureTargetGroups.

private Set<TargetGroup> createAzureTargetGroups() {
    AzureTargetGroupConfigDb azureTargetGroupConfigDb = new AzureTargetGroupConfigDb();
    azureTargetGroupConfigDb.setPortAvailabilitySetMapping(Map.of(PORT, List.of(AZURE_AS_NAME)));
    TargetGroupConfigDbWrapper targetGroupConfigDbWrapper = new TargetGroupConfigDbWrapper();
    targetGroupConfigDbWrapper.setAzureConfig(azureTargetGroupConfigDb);
    TargetGroup targetGroup = new TargetGroup();
    targetGroup.setProviderConfig(targetGroupConfigDbWrapper);
    return Set.of(targetGroup);
}
Also used : TargetGroupConfigDbWrapper(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AzureTargetGroupConfigDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb)

Aggregations

TargetGroupConfigDbWrapper (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroupConfigDbWrapper)4 AzureTargetGroupConfigDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.azure.AzureTargetGroupConfigDb)4 TargetGroup (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup)3 CloudLoadBalancerMetadata (com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata)2 TargetGroupPortPair (com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair)2 Test (org.junit.Test)2