Search in sources :

Example 1 with InstanceTypeInfo

use of com.amazonaws.services.ec2.model.InstanceTypeInfo in project cloudbreak by hortonworks.

the class AwsPlatformResourcesTest method testEncryptionWhenEncryptionSupportedWithNotSupportedValuePresentedShouldReturnFalse.

@Test
public void testEncryptionWhenEncryptionSupportedWithNotSupportedValuePresentedShouldReturnFalse() {
    InstanceTypeInfo instanceTypeInfo = new InstanceTypeInfo();
    EbsInfo ebsInfo = new EbsInfo();
    ebsInfo.setEncryptionSupport("nonsupported");
    instanceTypeInfo.setEbsInfo(ebsInfo);
    boolean encryptionSupported = underTest.getEncryptionSupported(instanceTypeInfo);
    assertFalse(encryptionSupported);
}
Also used : EbsInfo(com.amazonaws.services.ec2.model.EbsInfo) InstanceTypeInfo(com.amazonaws.services.ec2.model.InstanceTypeInfo) Test(org.junit.jupiter.api.Test)

Example 2 with InstanceTypeInfo

use of com.amazonaws.services.ec2.model.InstanceTypeInfo in project cloudbreak by hortonworks.

the class AwsPlatformResourcesTest method testEncryptionWhenNoEbsInfoShouldReturnFalse.

@Test
public void testEncryptionWhenNoEbsInfoShouldReturnFalse() {
    InstanceTypeInfo instanceTypeInfo = new InstanceTypeInfo();
    boolean encryptionSupported = underTest.getEncryptionSupported(instanceTypeInfo);
    assertFalse(encryptionSupported);
}
Also used : InstanceTypeInfo(com.amazonaws.services.ec2.model.InstanceTypeInfo) Test(org.junit.jupiter.api.Test)

Example 3 with InstanceTypeInfo

use of com.amazonaws.services.ec2.model.InstanceTypeInfo in project cloudbreak by hortonworks.

the class AwsPlatformResources method getVmTypesWithAwsCall.

private void getVmTypesWithAwsCall(Set<VmType> awsInstances, DescribeInstanceTypesResult describeInstanceTypesResult) {
    for (InstanceTypeInfo instanceType : describeInstanceTypesResult.getInstanceTypes()) {
        if (!instanceType.isBareMetal()) {
            VmTypeMetaBuilder vmTypeMetaBuilder = VmTypeMetaBuilder.builder().withCpuAndMemory(instanceType.getVCpuInfo().getDefaultVCpus(), getMemory(instanceType)).withMagneticConfig(new VolumeParameterConfig(MAGNETIC, MINIMUM_MAGNETIC_SIZE, MAXIMUM_MAGNETIC_SIZE, ONE, TWENTY_FOUR)).withSsdConfig(new VolumeParameterConfig(SSD, MINIMUM_SSD_SIZE, MAXIMUM_SSD_SIZE, ONE, TWENTY_FOUR)).withSt1Config(new VolumeParameterConfig(ST1, MINIMUM_ST1_SIZE, MAXIMUM_ST1_SIZE, ONE, TWENTY_FOUR));
            if (instanceType.getInstanceStorageSupported()) {
                InstanceStorageInfo instanceStorageInfo = instanceType.getInstanceStorageInfo();
                DiskInfo diskInfo = instanceStorageInfo.getDisks().get(0);
                vmTypeMetaBuilder.withEphemeralConfig(new VolumeParameterConfig(EPHEMERAL, diskInfo.getSizeInGB().intValue(), diskInfo.getSizeInGB().intValue(), diskInfo.getCount(), diskInfo.getCount()));
            }
            if (getEncryptionSupported(instanceType)) {
                vmTypeMetaBuilder.withVolumeEncryptionSupport(true);
            }
            VmType vmType = vmTypeWithMeta(instanceType.getInstanceType(), vmTypeMetaBuilder.create(), true);
            awsInstances.add(vmType);
        }
    }
}
Also used : VmTypeMetaBuilder(com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder) DiskInfo(com.amazonaws.services.ec2.model.DiskInfo) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) InstanceStorageInfo(com.amazonaws.services.ec2.model.InstanceStorageInfo) InstanceTypeInfo(com.amazonaws.services.ec2.model.InstanceTypeInfo) VolumeParameterConfig(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig)

Example 4 with InstanceTypeInfo

use of com.amazonaws.services.ec2.model.InstanceTypeInfo in project photon-model by vmware.

the class AWSInstanceTypeService method getInstanceTypes.

/**
 * Return the instance types by loading them from AWS SDK {@link InstanceType}.
 */
private DeferredResult<Context> getInstanceTypes(Context context) {
    AssertUtil.assertNotNull(context.endpointState, "Endpoint state was not retrieved.");
    context.instanceTypes = new InstanceTypeList();
    // Set tenant links as specified in the endpoint.
    context.instanceTypes.tenantLinks = context.endpointState.tenantLinks;
    context.instanceTypes.instanceTypes = // Use AWS SDK InstanceType enum as primary source of instance type data.
    Arrays.stream(InstanceType.values()).map(instanceType -> {
        InstanceTypeList.InstanceType result = new InstanceTypeList.InstanceType(instanceType.toString(), instanceType.toString());
        InstanceTypeList.InstanceType instanceTypeInfo = this.instanceTypeInfo.get(instanceType.toString());
        if (instanceTypeInfo != null) {
            // We have additional information -> populate additional fields.
            result.cpuCount = instanceTypeInfo.cpuCount;
            result.memoryInMB = instanceTypeInfo.memoryInMB;
            result.networkType = instanceTypeInfo.networkType;
            result.storageType = instanceTypeInfo.storageType;
            result.dataDiskMaxCount = instanceTypeInfo.dataDiskMaxCount;
            result.dataDiskSizeInMB = instanceTypeInfo.dataDiskSizeInMB;
        }
        return result;
    }).filter(instanceType -> !Integer.valueOf(-1).equals(instanceType.cpuCount)).collect(Collectors.toList());
    return DeferredResult.completed(context);
}
Also used : Arrays(java.util.Arrays) StatelessService(com.vmware.xenon.common.StatelessService) Operation(com.vmware.xenon.common.Operation) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) File(java.io.File) URI_PARAM_ENDPOINT(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.URI_PARAM_ENDPOINT) IOUtils(org.apache.commons.io.IOUtils) FileUtils(com.vmware.xenon.common.FileUtils) Utils(com.vmware.xenon.common.Utils) URI_PARAM_INSTANCE_TYPE(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.URI_PARAM_INSTANCE_TYPE) Map(java.util.Map) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList) InstanceType(com.amazonaws.services.ec2.model.InstanceType) AssertUtil(com.vmware.photon.controller.model.util.AssertUtil) InputStream(java.io.InputStream) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) InstanceType(com.amazonaws.services.ec2.model.InstanceType) InstanceTypeList(com.vmware.photon.controller.model.support.InstanceTypeList)

Example 5 with InstanceTypeInfo

use of com.amazonaws.services.ec2.model.InstanceTypeInfo in project cloudbreak by hortonworks.

the class AwsPlatformResourcesTest method testEncryptionWhenEncryptionSupportedWithSupportedValuePresentedShouldReturnTrue.

@Test
public void testEncryptionWhenEncryptionSupportedWithSupportedValuePresentedShouldReturnTrue() {
    InstanceTypeInfo instanceTypeInfo = new InstanceTypeInfo();
    EbsInfo ebsInfo = new EbsInfo();
    ebsInfo.setEncryptionSupport("supported");
    instanceTypeInfo.setEbsInfo(ebsInfo);
    boolean encryptionSupported = underTest.getEncryptionSupported(instanceTypeInfo);
    assertTrue(encryptionSupported);
}
Also used : EbsInfo(com.amazonaws.services.ec2.model.EbsInfo) InstanceTypeInfo(com.amazonaws.services.ec2.model.InstanceTypeInfo) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceTypeInfo (com.amazonaws.services.ec2.model.InstanceTypeInfo)5 Test (org.junit.jupiter.api.Test)4 EbsInfo (com.amazonaws.services.ec2.model.EbsInfo)3 DiskInfo (com.amazonaws.services.ec2.model.DiskInfo)1 InstanceStorageInfo (com.amazonaws.services.ec2.model.InstanceStorageInfo)1 InstanceType (com.amazonaws.services.ec2.model.InstanceType)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 VmTypeMetaBuilder (com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder)1 VolumeParameterConfig (com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig)1 URI_PARAM_ENDPOINT (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.URI_PARAM_ENDPOINT)1 URI_PARAM_INSTANCE_TYPE (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.URI_PARAM_INSTANCE_TYPE)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 InstanceTypeList (com.vmware.photon.controller.model.support.InstanceTypeList)1 AssertUtil (com.vmware.photon.controller.model.util.AssertUtil)1 DeferredResult (com.vmware.xenon.common.DeferredResult)1 FileUtils (com.vmware.xenon.common.FileUtils)1 Operation (com.vmware.xenon.common.Operation)1 StatelessService (com.vmware.xenon.common.StatelessService)1 UriUtils (com.vmware.xenon.common.UriUtils)1 Utils (com.vmware.xenon.common.Utils)1