Search in sources :

Example 6 with ResourceBuilderContext

use of com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext 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());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ResourceBuilderContext(com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)

Example 7 with ResourceBuilderContext

use of com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext in project cloudbreak by hortonworks.

the class AbstractResourceConnector method downscale.

@Override
public List<CloudResourceStatus> downscale(AuthenticatedContext auth, CloudStack stack, List<CloudResource> resources, List<CloudInstance> vms, List<CloudResource> resourcesToRemove) {
    CloudContext cloudContext = auth.getCloudContext();
    Platform platform = cloudContext.getPlatform();
    // context
    ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), resources, false);
    // compute
    return computeResourceService.deleteResources(context, auth, resourcesToRemove, true);
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ResourceBuilderContext(com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)

Aggregations

CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)7 ResourceBuilderContext (com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)7 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 Group (com.sequenceiq.cloudbreak.cloud.model.Group)1