use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class TemplateDecoratorTest method testDecorator.
@Test
public void testDecorator() {
String vmType = "vmType";
String platform1 = "platform";
String volumeType = "volumeType";
String region = "region";
String availibilityZone = "availabilityZone";
String variant = "variant";
Credential cloudCredential = mock(Credential.class);
Template template = new Template();
template.setInstanceType(vmType);
template.setCloudPlatform(platform1);
template.setVolumeType(volumeType);
Platform platform = Platform.platform(platform1);
int minimumSize = 10;
int maximumSize = 100;
int minimumNumber = 1;
int maximumNumber = 5;
VolumeParameterConfig config = new VolumeParameterConfig(VolumeParameterType.MAGNETIC, minimumSize, maximumSize, minimumNumber, maximumNumber);
VmTypeMeta vmTypeMeta = new VmTypeMeta();
vmTypeMeta.setMagneticConfig(config);
Map<Platform, Map<String, VolumeParameterType>> diskMappings = newHashMap();
diskMappings.put(platform, singletonMap(volumeType, VolumeParameterType.MAGNETIC));
PlatformDisks platformDisk = new PlatformDisks(emptyMap(), emptyMap(), diskMappings, emptyMap());
CloudVmTypes cloudVmTypes = new CloudVmTypes();
Map<String, Set<VmType>> region1 = singletonMap(region, Collections.singleton(VmType.vmTypeWithMeta(vmType, vmTypeMeta, true)));
cloudVmTypes.setCloudVmResponses(region1);
when(cloudParameterService.getDiskTypes()).thenReturn(platformDisk);
when(cloudParameterService.getVmTypesV2(eq(cloudCredential), eq(region), eq(variant), anyMap())).thenReturn(cloudVmTypes);
when(locationService.location(region, availibilityZone)).thenReturn(region);
Template actual = underTest.decorate(cloudCredential, template, region, availibilityZone, variant);
Assert.assertEquals(maximumNumber, actual.getVolumeCount().longValue());
Assert.assertEquals(maximumSize, actual.getVolumeSize().longValue());
}
use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class AbstractInstanceConnector method stop.
@Override
public List<CloudVmInstanceStatus> stop(AuthenticatedContext ac, List<CloudResource> resources, List<CloudInstance> vms) {
CloudContext cloudContext = ac.getCloudContext();
Platform platform = cloudContext.getPlatform();
// context
ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, ac, null, resources, false);
// compute
return computeResourceService.stopInstances(context, ac, resources, vms);
}
use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.
the class AbstractResourceConnector method terminate.
@Override
public List<CloudResourceStatus> terminate(AuthenticatedContext auth, CloudStack stack, List<CloudResource> cloudResources) throws Exception {
CloudContext cloudContext = auth.getCloudContext();
Platform platform = cloudContext.getPlatform();
// context
ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), cloudResources, false);
// compute
List<CloudResourceStatus> cloudResourceStatuses = computeResourceService.deleteResources(context, auth, cloudResources, false);
// group
List<CloudResourceStatus> groupStatuses = groupResourceService.deleteResources(context, auth, cloudResources, stack.getNetwork(), false);
cloudResourceStatuses.addAll(groupStatuses);
// network
List<CloudResourceStatus> networkStatuses = networkResourceService.deleteResources(context, auth, cloudResources, stack.getNetwork(), false);
cloudResourceStatuses.addAll(networkStatuses);
return cloudResourceStatuses;
}
use of com.sequenceiq.cloudbreak.cloud.model.Platform 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.Platform 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);
}
Aggregations