use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class LoadBalancerConfigConverterTest method testConvertGcpLoadBalancer.
@Test
public void testConvertGcpLoadBalancer() {
CloudLoadBalancerMetadata cloudLoadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withParameters(creatGcpParams(0)).build();
LoadBalancerConfigDbWrapper cloudLoadBalancerConfigDbWrapper = underTest.convertLoadBalancer(GCP, cloudLoadBalancerMetadata);
assertNotNull(cloudLoadBalancerConfigDbWrapper.getGcpConfig());
GcpLoadBalancerConfigDb gcpLoadBalancerConfigDb = cloudLoadBalancerConfigDbWrapper.getGcpConfig();
assertEquals(LB_NAME, gcpLoadBalancerConfigDb.getName());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AwsMetadataCollector method collectLoadBalancer.
@Override
public List<CloudLoadBalancerMetadata> collectLoadBalancer(AuthenticatedContext ac, List<LoadBalancerType> loadBalancerTypes, List<CloudResource> resources) {
LOGGER.debug("Collect AWS load balancer metadata, for cluster {}", ac.getCloudContext().getName());
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = new ArrayList<>();
for (LoadBalancerType type : loadBalancerTypes) {
AwsLoadBalancerScheme scheme = loadBalancerTypeConverter.convert(type);
String loadBalancerName = AwsLoadBalancer.getLoadBalancerName(scheme);
LOGGER.debug("Attempting to collect metadata for load balancer {}, type {}", loadBalancerName, type);
try {
LoadBalancer loadBalancer = cloudFormationStackUtil.getLoadBalancerByLogicalId(ac, loadBalancerName);
LOGGER.debug("Parsing all listener and target group information for load balancer {}", loadBalancerName);
Map<String, Object> parameters = awsLoadBalancerMetadataCollector.getParameters(ac, loadBalancer, scheme);
CloudLoadBalancerMetadata loadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withType(type).withCloudDns(loadBalancer.getDNSName()).withHostedZoneId(loadBalancer.getCanonicalHostedZoneId()).withName(loadBalancerName).withParameters(parameters).build();
cloudLoadBalancerMetadata.add(loadBalancerMetadata);
LOGGER.debug("Saved metadata for load balancer {}: DNS {}, zone id {}", loadBalancerName, loadBalancer.getDNSName(), loadBalancer.getCanonicalHostedZoneId());
} catch (RuntimeException e) {
LOGGER.debug("Unable to find metadata for load balancer " + loadBalancerName, e);
}
}
return cloudLoadBalancerMetadata;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollector method describeLoadBalancer.
private Optional<CloudLoadBalancerMetadata> describeLoadBalancer(String loadBalancerArn, AmazonElasticLoadBalancingClient loadBalancingClient, List<CloudResource> resources) {
DescribeLoadBalancersRequest describeLoadBalancersRequest = new DescribeLoadBalancersRequest().withLoadBalancerArns(loadBalancerArn);
DescribeLoadBalancersResult describeLoadBalancersResult = loadBalancingClient.describeLoadBalancers(describeLoadBalancersRequest);
return describeLoadBalancersResult.getLoadBalancers().stream().findFirst().map(loadBalancer -> {
LoadBalancerType type = loadBalancerTypeConverter.convert(loadBalancer.getScheme());
Map<String, Object> parameters = awsNativeLbMetadataCollector.getParameters(loadBalancerArn, resources);
CloudLoadBalancerMetadata loadBalancerMetadata = new CloudLoadBalancerMetadata.Builder().withType(type).withCloudDns(loadBalancer.getDNSName()).withHostedZoneId(loadBalancer.getCanonicalHostedZoneId()).withName(loadBalancer.getLoadBalancerName()).withParameters(parameters).build();
LOGGER.info("Saved metadata for load balancer {}: DNS {}, zone ID {}", loadBalancer.getLoadBalancerName(), loadBalancer.getDNSName(), loadBalancer.getCanonicalHostedZoneId());
return loadBalancerMetadata;
});
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AzureMetadataCollectorTest method testCollectPrivateLoadBalancer.
@Test
public void testCollectPrivateLoadBalancer() {
List<CloudResource> resources = new ArrayList<>();
CloudResource cloudResource = createCloudResource();
when(authenticatedContext.getCloudContext()).thenReturn(mockCloudContext);
when(mockCloudContext.getName()).thenReturn(RESOURCE_GROUP_NAME);
when(azureUtils.getTemplateResource(resources)).thenReturn(cloudResource);
when(azureUtils.getStackName(any())).thenReturn(STACK_NAME);
final String privateLoadBalancerName = AzureLoadBalancer.getLoadBalancerName(LoadBalancerType.PRIVATE, STACK_NAME);
when(azureClient.getLoadBalancerIps(RESOURCE_GROUP_NAME, privateLoadBalancerName, LoadBalancerType.PRIVATE)).thenReturn(List.of(PRIVATE_IP));
when(authenticatedContext.getParameter(AzureClient.class)).thenReturn(azureClient);
when(azureLbMetadataCollector.getParameters(any(), anyString(), anyString())).thenReturn(Map.of());
List<CloudLoadBalancerMetadata> result = underTest.collectLoadBalancer(authenticatedContext, List.of(LoadBalancerType.PRIVATE), resources);
assertEquals(1, result.size());
assertEquals(LoadBalancerType.PRIVATE, result.get(0).getType());
assertEquals(PRIVATE_IP, result.get(0).getIp());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata in project cloudbreak by hortonworks.
the class AzureMetadataCollectorTest method testCollectPublicAndPrivateLoadBalancer.
@Test
public void testCollectPublicAndPrivateLoadBalancer() {
List<CloudResource> resources = new ArrayList<>();
CloudResource cloudResource = createCloudResource();
when(authenticatedContext.getCloudContext()).thenReturn(mockCloudContext);
when(mockCloudContext.getName()).thenReturn(RESOURCE_GROUP_NAME);
when(azureUtils.getTemplateResource(resources)).thenReturn(cloudResource);
when(azureUtils.getStackName(any())).thenReturn(STACK_NAME);
final String publicLoadBalancerName = AzureLoadBalancer.getLoadBalancerName(LoadBalancerType.PUBLIC, STACK_NAME);
when(azureClient.getLoadBalancerIps(RESOURCE_GROUP_NAME, publicLoadBalancerName, LoadBalancerType.PUBLIC)).thenReturn(List.of(PUBLIC_IP));
final String privateLoadBalancerName = AzureLoadBalancer.getLoadBalancerName(LoadBalancerType.PRIVATE, STACK_NAME);
when(azureClient.getLoadBalancerIps(RESOURCE_GROUP_NAME, privateLoadBalancerName, LoadBalancerType.PRIVATE)).thenReturn(List.of(PRIVATE_IP));
when(authenticatedContext.getParameter(AzureClient.class)).thenReturn(azureClient);
when(azureLbMetadataCollector.getParameters(any(), anyString(), anyString())).thenReturn(Map.of());
List<CloudLoadBalancerMetadata> result = underTest.collectLoadBalancer(authenticatedContext, List.of(LoadBalancerType.PUBLIC, LoadBalancerType.PRIVATE), resources);
assertEquals(2, result.size());
Optional<CloudLoadBalancerMetadata> publicLoadBalancerMetadata = result.stream().filter(metadata -> metadata.getType() == LoadBalancerType.PUBLIC).findAny();
assertTrue(publicLoadBalancerMetadata.isPresent());
assertEquals(PUBLIC_IP, publicLoadBalancerMetadata.get().getIp());
Optional<CloudLoadBalancerMetadata> privateLoadBalancerMetadata = result.stream().filter(metadata -> metadata.getType() == LoadBalancerType.PRIVATE).findAny();
assertTrue(privateLoadBalancerMetadata.isPresent());
assertEquals(PRIVATE_IP, privateLoadBalancerMetadata.get().getIp());
}
Aggregations