Search in sources :

Example 11 with BlockDeviceMapping

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

the class TestAWSProvisionTask method getVolume.

protected Volume getVolume(AmazonEC2AsyncClient client, Instance awsInstance, String deviceName) {
    InstanceBlockDeviceMapping bootDiskMapping = awsInstance.getBlockDeviceMappings().stream().filter(blockDeviceMapping -> blockDeviceMapping.getDeviceName().equals(deviceName)).findAny().orElse(null);
    // The ami used in this test is an ebs-backed AMI
    assertNotNull("Device type should be ebs type", bootDiskMapping.getEbs());
    String bootVolumeId = bootDiskMapping.getEbs().getVolumeId();
    DescribeVolumesRequest describeVolumesRequest = new DescribeVolumesRequest().withVolumeIds(bootVolumeId);
    DescribeVolumesResult describeVolumesResult = client.describeVolumes(describeVolumesRequest);
    return describeVolumesResult.getVolumes().get(0);
}
Also used : InstanceBlockDeviceMapping(com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping) DescribeVolumesResult(com.amazonaws.services.ec2.model.DescribeVolumesResult) DescribeVolumesRequest(com.amazonaws.services.ec2.model.DescribeVolumesRequest)

Aggregations

EbsBlockDevice (com.amazonaws.services.ec2.model.EbsBlockDevice)7 BlockDeviceMapping (com.amazonaws.services.ec2.model.BlockDeviceMapping)6 InstanceBlockDeviceMapping (com.amazonaws.services.ec2.model.InstanceBlockDeviceMapping)4 DiskState (com.vmware.photon.controller.model.resources.DiskService.DiskState)4 ArrayList (java.util.ArrayList)4 Image (com.amazonaws.services.ec2.model.Image)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2 AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)2 DescribeImagesRequest (com.amazonaws.services.ec2.model.DescribeImagesRequest)2 DescribeImagesResult (com.amazonaws.services.ec2.model.DescribeImagesResult)2 RunInstancesRequest (com.amazonaws.services.ec2.model.RunInstancesRequest)2 RunInstancesResult (com.amazonaws.services.ec2.model.RunInstancesResult)2 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 DescribeVolumesRequest (com.amazonaws.services.ec2.model.DescribeVolumesRequest)1 DescribeVolumesResult (com.amazonaws.services.ec2.model.DescribeVolumesResult)1 Filter (com.amazonaws.services.ec2.model.Filter)1 Placement (com.amazonaws.services.ec2.model.Placement)1 Tag (com.amazonaws.services.ec2.model.Tag)1 TagSpecification (com.amazonaws.services.ec2.model.TagSpecification)1 AWSNicContext (com.vmware.photon.controller.model.adapters.awsadapter.AWSInstanceContext.AWSNicContext)1