Search in sources :

Example 41 with AmazonEC2AsyncClient

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

the class TestAWSProvisionTask method assertBootDiskConfiguration.

protected void assertBootDiskConfiguration(AmazonEC2AsyncClient client, Instance awsInstance, String diskLink) {
    DiskState diskState = getDiskState(diskLink);
    Volume bootVolume = getVolume(client, awsInstance, awsInstance.getRootDeviceName());
    assertEquals("Boot Disk capacity in diskstate is not matching the boot disk size of the " + "vm launched in aws", diskState.capacityMBytes, bootVolume.getSize() * 1024);
    assertNotNull("Boot disk creation time cannot be empty", diskState.creationTimeMicros);
    assertEquals("Boot disk type in diskstate is not same as the type of the volume attached to the VM", diskState.customProperties.get("volumeType"), bootVolume.getVolumeType());
    assertEquals("Boot disk iops in diskstate is the same as the iops of the volume attached to the VM", Integer.parseInt(diskState.customProperties.get("iops")), bootVolume.getIops().intValue());
    assertEquals("Boot disk attach status is not matching", DiskService.DiskStatus.ATTACHED, diskState.status);
}
Also used : Volume(com.amazonaws.services.ec2.model.Volume) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState)

Example 42 with AmazonEC2AsyncClient

use of com.amazonaws.services.ec2.AmazonEC2AsyncClient 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

AmazonEC2AsyncClient (com.amazonaws.services.ec2.AmazonEC2AsyncClient)18 Operation (com.vmware.xenon.common.Operation)13 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)11 Filter (com.amazonaws.services.ec2.model.Filter)11 StatelessService (com.vmware.xenon.common.StatelessService)11 AWSClientManager (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManager)10 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)9 StopInstancesRequest (com.amazonaws.services.ec2.model.StopInstancesRequest)9 StopInstancesResult (com.amazonaws.services.ec2.model.StopInstancesResult)9 ArrayList (java.util.ArrayList)9 AsyncHandler (com.amazonaws.handlers.AsyncHandler)8 AWSClientManagerFactory (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSClientManagerFactory)8 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)8 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)8 HashMap (java.util.HashMap)8 List (java.util.List)8 TimeUnit (java.util.concurrent.TimeUnit)8 AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)7 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)7 AWSSecurityGroupClient (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSSecurityGroupClient)7