Search in sources :

Example 1 with AWSSupportedOS

use of com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedOS in project photon-model by vmware.

the class AWSComputeDiskDay2Service method getAvailableDeviceName.

private String getAvailableDeviceName(DiskContext context, String instanceId) {
    DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest().withInstanceIds(instanceId);
    DescribeInstancesResult instancesResult = context.amazonEC2Client.describeInstances(describeInstancesRequest);
    List<InstanceBlockDeviceMapping> blockDeviceMappings = null;
    AWSSupportedOS platform = null;
    AWSSupportedVirtualizationTypes virtualizationTypes = null;
    String instanceType = null;
    for (Reservation reservation : instancesResult.getReservations()) {
        for (Instance instance : reservation.getInstances()) {
            if (instance.getInstanceId().equals(instanceId)) {
                blockDeviceMappings = instance.getBlockDeviceMappings();
                platform = AWSSupportedOS.get(instance.getPlatform());
                virtualizationTypes = AWSSupportedVirtualizationTypes.get(instance.getVirtualizationType());
                instanceType = instance.getInstanceType();
                break;
            }
        }
    }
    String deviceName = null;
    if (blockDeviceMappings != null) {
        List<String> usedDeviceNames = getUsedDeviceNames(blockDeviceMappings);
        List<String> availableDiskNames = AWSBlockDeviceNameMapper.getAvailableNames(platform, virtualizationTypes, AWSStorageType.EBS, instanceType, usedDeviceNames);
        deviceName = availableDiskNames.get(0);
    }
    return deviceName;
}
Also used : DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Reservation(com.amazonaws.services.ec2.model.Reservation) Instance(com.amazonaws.services.ec2.model.Instance) AWSSupportedVirtualizationTypes(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedVirtualizationTypes) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) InstanceBlockDeviceMapping(com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping) AWSSupportedOS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedOS)

Example 2 with AWSSupportedOS

use of com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedOS in project photon-model by vmware.

the class AWSComputeDiskDay2ServiceTest method assertDeviceName.

protected void assertDeviceName(Instance awsInstance, DiskState diskState, List<String> existingNames) {
    if (!this.isMock) {
        AWSSupportedOS os = AWSSupportedOS.get(awsInstance.getPlatform());
        AWSSupportedVirtualizationTypes virtualizationType = AWSSupportedVirtualizationTypes.get(awsInstance.getVirtualizationType());
        AWSStorageType storageType = AWSStorageType.get(diskState.customProperties.get(DEVICE_TYPE));
        List<String> expectedNames = AWSBlockDeviceNameMapper.getAvailableNames(os, virtualizationType, storageType, awsInstance.getInstanceType(), existingNames);
        String expectedName = expectedNames.get(0);
        assertEquals(expectedName, diskState.customProperties.get(DEVICE_NAME));
        existingNames.add(expectedName);
    }
}
Also used : AWSSupportedVirtualizationTypes(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedVirtualizationTypes) AWSSupportedOS(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedOS) AWSStorageType(com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSStorageType)

Aggregations

AWSSupportedOS (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedOS)2 AWSSupportedVirtualizationTypes (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSSupportedVirtualizationTypes)2 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 Instance (com.amazonaws.services.ec2.model.Instance)1 InstanceBlockDeviceMapping (com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping)1 Reservation (com.amazonaws.services.ec2.model.Reservation)1 AWSStorageType (com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.AWSStorageType)1