use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient in project cloudbreak by hortonworks.
the class AwsNativeResourceConnector method upscale.
@Override
public List<CloudResourceStatus> upscale(AuthenticatedContext auth, CloudStack stack, List<CloudResource> resources, AdjustmentTypeWithThreshold adjustmentTypeWithThreshold) throws QuotaExceededException {
List<CloudResourceStatus> upscale = super.upscale(auth, stack, resources, adjustmentTypeWithThreshold);
LOGGER.info("Launching elastic load balancers");
CloudCredential cloudCredential = auth.getCloudCredential();
String region = auth.getCloudContext().getLocation().getRegion().value();
AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential);
AmazonElasticLoadBalancingClient elasticLoadBalancingClient = commonAwsClient.createElasticLoadBalancingClient(awsCredentialView, region);
loadBalancerLaunchService.launchLoadBalancerResources(auth, stack, persistenceNotifier, elasticLoadBalancingClient, true);
return upscale;
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient in project cloudbreak by hortonworks.
the class AwsNativeResourceConnector method launchLoadBalancers.
@Override
public List<CloudResourceStatus> launchLoadBalancers(AuthenticatedContext authenticatedContext, CloudStack stack, PersistenceNotifier persistenceNotifier) throws Exception {
LOGGER.info("Launching elastic load balancers");
CloudCredential cloudCredential = authenticatedContext.getCloudCredential();
String region = authenticatedContext.getCloudContext().getLocation().getRegion().value();
AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential);
AmazonElasticLoadBalancingClient elasticLoadBalancingClient = commonAwsClient.createElasticLoadBalancingClient(awsCredentialView, region);
return loadBalancerLaunchService.launchLoadBalancerResources(authenticatedContext, stack, persistenceNotifier, elasticLoadBalancingClient, true);
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient in project cloudbreak by hortonworks.
the class AwsClient method createAuthenticatedContext.
public AuthenticatedContext createAuthenticatedContext(CloudContext cloudContext, CloudCredential cloudCredential) {
AuthenticatedContext authenticatedContext = new AuthenticatedContext(cloudContext, cloudCredential);
try {
AuthenticatedContextView authenticatedContextView = new AuthenticatedContextView(authenticatedContext);
String region = authenticatedContextView.getRegion();
AwsCredentialView awsCredentialView = authenticatedContextView.getAwsCredentialView();
AmazonEc2Client amazonEC2Client = null;
if (region != null) {
amazonEC2Client = createEc2Client(awsCredentialView, region);
AmazonElasticLoadBalancingClient loadBalancingClient = createElasticLoadBalancingClient(awsCredentialView, region);
authenticatedContext.putParameter(AmazonElasticLoadBalancingClient.class, loadBalancingClient);
} else {
amazonEC2Client = createEc2Client(awsCredentialView);
}
authenticatedContext.putParameter(AmazonEc2Client.class, amazonEC2Client);
} catch (AmazonServiceException e) {
throw new CredentialVerificationException(e.getErrorMessage(), e);
}
return authenticatedContext;
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient in project cloudbreak by hortonworks.
the class AwsContextBuilder method contextInit.
@Override
public AwsContext contextInit(CloudContext context, AuthenticatedContext auth, Network network, List<CloudResource> resources, boolean build) {
Location location = context.getLocation();
AuthenticatedContextView authenticatedContextView = new AuthenticatedContextView(auth);
AmazonEc2Client amazonEC2Client = authenticatedContextView.getAmazonEC2Client();
AmazonElasticLoadBalancingClient elasticLoadBalancingClient = authenticatedContextView.getElasticLoadBalancingClient();
return new AwsContext(context.getName(), amazonEC2Client, location, PARALLEL_RESOURCE_REQUEST, build, elasticLoadBalancingClient);
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonElasticLoadBalancingClient in project cloudbreak by hortonworks.
the class LoadBalancerService method removeLoadBalancerTargets.
public void removeLoadBalancerTargets(AuthenticatedContext ac, List<String> targetGroupArns, List<CloudResource> resourcesToRemove) {
if (targetGroupArns.isEmpty()) {
LOGGER.info("Cannot find target group for the stack, skip the removing of the targets");
return;
}
for (String targetGroupArn : targetGroupArns) {
String region = ac.getCloudContext().getLocation().getRegion().value();
AmazonElasticLoadBalancingClient amazonElbClient = awsClient.createElasticLoadBalancingClient(new AwsCredentialView(ac.getCloudCredential()), region);
LOGGER.debug("Get a list of the instance ids to remove");
Set<String> instancesToRemove = getInstanceIdsForGroups(resourcesToRemove);
LOGGER.debug("Deregister any instances that no longer exist");
if (!instancesToRemove.isEmpty()) {
try {
List<TargetDescription> targetsToRemove = instancesToRemove.stream().map(instanceId -> new TargetDescription().withId(instanceId)).collect(Collectors.toList());
amazonElbClient.deregisterTargets(new DeregisterTargetsRequest().withTargetGroupArn(targetGroupArn).withTargets(targetsToRemove));
LOGGER.debug("Targets deregistered: {}", targetsToRemove);
} catch (InvalidTargetException ignored) {
LOGGER.debug("no-op - we tried to remove a target that wasn't in the target group, which is fine");
}
}
}
}
Aggregations