use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class AwsResourceConnector method resumeAutoScaling.
private void resumeAutoScaling(AuthenticatedContext ac, CloudStack stack) {
AmazonAutoScalingClient amazonASClient = awsClient.createAutoScalingClient(new AwsCredentialView(ac.getCloudCredential()), ac.getCloudContext().getLocation().getRegion().value());
for (Group group : stack.getGroups()) {
String asGroupName = cfStackUtil.getAutoscalingGroupName(ac, group.getName(), ac.getCloudContext().getLocation().getRegion().value());
amazonASClient.resumeProcesses(new ResumeProcessesRequest().withAutoScalingGroupName(asGroupName).withScalingProcesses(SUSPENDED_PROCESSES));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class AwsResourceConnector method scheduleStatusChecks.
private void scheduleStatusChecks(CloudStack stack, AuthenticatedContext ac, AmazonCloudFormation cloudFormationClient) {
for (Group group : stack.getGroups()) {
String asGroupName = cfStackUtil.getAutoscalingGroupName(ac, cloudFormationClient, group.getName());
LOGGER.info("Polling Auto Scaling group until new instances are ready. [stack: {}, asGroup: {}]", ac.getCloudContext().getId(), asGroupName);
PollTask<Boolean> task = awsPollTaskFactory.newASGroupStatusCheckerTask(ac, asGroupName, group.getInstancesSize(), awsClient, cfStackUtil);
try {
Boolean statePollerResult = task.call();
if (!task.completed(statePollerResult)) {
syncPollingScheduler.schedule(task);
}
} catch (Exception e) {
throw new CloudConnectorException(e.getMessage(), e);
}
}
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class AwsResourceConnector method getCloudResources.
private List<CloudResource> getCloudResources(AuthenticatedContext ac, CloudStack stack, String cFStackName, AmazonCloudFormation client, AmazonEC2 amazonEC2Client, AmazonAutoScaling amazonASClient, boolean mapPublicIpOnLaunch) {
List<CloudResource> cloudResources = new ArrayList<>();
AmazonCloudFormationClient cloudFormationClient = awsClient.createCloudFormationClient(new AwsCredentialView(ac.getCloudCredential()), ac.getCloudContext().getLocation().getRegion().value());
scheduleStatusChecks(stack, ac, cloudFormationClient);
suspendAutoScaling(ac, stack);
if (mapPublicIpOnLaunch) {
Map<String, String> eipAllocationIds = getElasticIpAllocationIds(cFStackName, client);
List<Group> gateways = getGatewayGroups(stack.getGroups());
for (Group gateway : gateways) {
List<String> eips = getEipsForGatewayGroup(eipAllocationIds, gateway);
List<String> instanceIds = getInstancesForGroup(ac, amazonASClient, client, gateway);
associateElasticIpsToInstances(amazonEC2Client, eips, instanceIds);
}
}
return cloudResources;
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class AbstractResourceConnector method upscale.
@Override
public List<CloudResourceStatus> upscale(AuthenticatedContext auth, CloudStack stack, List<CloudResource> resources) {
CloudContext cloudContext = auth.getCloudContext();
Platform platform = cloudContext.getPlatform();
// context
ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), resources, true);
// network
context.addNetworkResources(networkResourceService.getNetworkResources(platform, resources));
Group scalingGroup = getScalingGroup(getGroup(stack.getGroups(), getGroupName(stack)));
// group
context.addGroupResources(scalingGroup.getName(), groupResourceService.getGroupResources(platform, resources));
// compute
return computeResourceService.buildResourcesForUpscale(context, auth, Collections.singletonList(scalingGroup), stack.getImage(), stack.getTags());
}
use of com.sequenceiq.cloudbreak.cloud.model.Group in project cloudbreak by hortonworks.
the class StackToCloudStackConverter method convert.
public CloudStack convert(Stack stack, Collection<String> deleteRequestedInstances) {
Image image = null;
List<Group> instanceGroups = buildInstanceGroups(stack.getInstanceGroupsAsList(), stack.getStackAuthentication(), deleteRequestedInstances);
try {
image = imageService.getImage(stack.getId());
} catch (CloudbreakImageNotFoundException e) {
LOGGER.info(e.getMessage());
}
Network network = buildNetwork(stack);
StackTemplate stackTemplate = componentConfigProvider.getStackTemplate(stack.getId());
InstanceAuthentication instanceAuthentication = buildInstanceAuthentication(stack.getStackAuthentication());
String template = null;
if (stackTemplate != null) {
template = stackTemplate.getTemplate();
}
return new CloudStack(instanceGroups, network, image, stack.getParameters(), getUserDefinedTags(stack), template, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
}
Aggregations