use of com.amazonaws.services.ec2.model.DescribeVolumesRequest in project photon-model by vmware.
the class AWSTaskStatusChecker method runSearch.
private void runSearch(T type) {
AmazonWebServiceRequest descRequest = buildRequest(type);
AsyncHandler describeHandler = buildHandler(type);
if (type instanceof Instance) {
this.amazonEC2Client.describeInstancesAsync((DescribeInstancesRequest) descRequest, describeHandler);
} else if (type instanceof NatGateway) {
this.amazonEC2Client.describeNatGatewaysAsync((DescribeNatGatewaysRequest) descRequest, describeHandler);
} else if (type instanceof Volume) {
this.amazonEC2Client.describeVolumesAsync((DescribeVolumesRequest) descRequest, describeHandler);
} else {
AWSTaskStatusChecker.this.taskManager.patchTaskToFailure(new IllegalArgumentException("Invalid type " + type));
}
}
use of com.amazonaws.services.ec2.model.DescribeVolumesRequest in project photon-model by vmware.
the class TestAWSSetupUtils method getAwsDisksByIds.
/**
* Method to get Disk details directly from Amazon
*/
public static List<Volume> getAwsDisksByIds(AmazonEC2AsyncClient client, VerificationHost host, List<String> diskIds) throws Throwable {
try {
host.log("Getting disks with ids " + diskIds + " from the AWS endpoint using the EC2 client.");
DescribeVolumesRequest describeVolumesRequest = new DescribeVolumesRequest().withVolumeIds(diskIds);
DescribeVolumesResult describeVolumesResult = client.describeVolumes(describeVolumesRequest);
return describeVolumesResult.getVolumes();
} catch (Exception e) {
if (e instanceof AmazonEC2Exception && ((AmazonEC2Exception) e).getErrorCode().equalsIgnoreCase(AWS_INVALID_VOLUME_ID_ERROR_CODE)) {
return null;
}
}
return new ArrayList<>();
}
use of com.amazonaws.services.ec2.model.DescribeVolumesRequest 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);
}
Aggregations