use of com.amazonaws.services.elasticloadbalancing.model.CreateLoadBalancerResult in project photon-model by vmware.
the class TestAWSSetupUtils method provisionAWSLoadBalancerWithEC2Client.
public static String provisionAWSLoadBalancerWithEC2Client(VerificationHost host, AmazonElasticLoadBalancingAsyncClient client, String name, String subnetId, String securityGroupId, List<String> instanceIds) {
if (name == null) {
name = LOAD_BALANCER_NAME_PREFIX + System.currentTimeMillis();
}
Listener defaultListener = new Listener().withInstancePort(80).withInstanceProtocol("HTTP").withLoadBalancerPort(80).withProtocol("HTTP");
CreateLoadBalancerRequest request = new CreateLoadBalancerRequest().withLoadBalancerName(name).withSubnets(Collections.singletonList(subnetId)).withSecurityGroups(Collections.singleton(securityGroupId)).withListeners(Collections.singleton(defaultListener));
CreateLoadBalancerResult result = null;
try {
result = client.createLoadBalancer(request);
} catch (Exception e) {
host.log(Level.SEVERE, "Error encountered in provisioning load balancer on AWS: %s", Utils.toString(e));
}
assertNotNull(result);
assertNotNull(result.getDNSName());
if (instanceIds != null) {
registerAWSInstancesToLoadBalancer(host, client, name, instanceIds);
}
return name;
}
use of com.amazonaws.services.elasticloadbalancing.model.CreateLoadBalancerResult in project photon-model by vmware.
the class AWSLoadBalancerService method createLoadBalancer.
private DeferredResult<AWSLoadBalancerContext> createLoadBalancer(AWSLoadBalancerContext context) {
CreateLoadBalancerRequest request = buildCreationRequest(context);
String message = "Create a new AWS Load Balancer with name [" + context.loadBalancerStateExpanded.name + "].";
AWSDeferredResultAsyncHandler<CreateLoadBalancerRequest, CreateLoadBalancerResult> handler = new AWSDeferredResultAsyncHandler<>(this, message);
context.client.createLoadBalancerAsync(request, handler);
return handler.toDeferredResult().thenApply(result -> {
context.loadBalancerStateExpanded.address = result.getDNSName();
return context;
});
}
Aggregations