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;
}
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);
}
}
Aggregations