use of com.amazonaws.services.ec2.model.DescribeVolumesRequest in project photon-model by vmware.
the class AWSEBSStorageEnumerationAdapterService method createAWSRequestAndAsyncHandler.
/**
* Initializes and saves a reference to the request object that is sent to AWS to get a page of
* volumes. Also saves an instance to the async handler that will be used to handle the
* responses received from AWS. It sets the nextToken value in the request object sent to AWS
* for getting the next page of results from AWS.
*/
private void createAWSRequestAndAsyncHandler(EBSStorageEnumerationContext aws) {
DescribeVolumesRequest request = new DescribeVolumesRequest();
request.setMaxResults(getQueryPageSize());
request.setNextToken(aws.nextToken);
aws.describeVolumesRequest = request;
AsyncHandler<DescribeVolumesRequest, DescribeVolumesResult> resultHandler = new AWSStorageEnumerationAsyncHandler(this, aws);
aws.resultHandler = resultHandler;
}
use of com.amazonaws.services.ec2.model.DescribeVolumesRequest in project photon-model by vmware.
the class TestAWSSetupUtils method createVolume.
/**
* Creates a volume and return the volume id.
*/
public static String createVolume(VerificationHost host, AmazonEC2Client client) {
CreateVolumeRequest req = new CreateVolumeRequest().withAvailabilityZone(zoneId + avalabilityZoneIdentifier).withSize(1);
CreateVolumeResult res = client.createVolume(req);
String volumeId = res.getVolume().getVolumeId();
Filter filter = new Filter().withName(VOLUME_ID_ATTRIBUTE).withValues(volumeId);
DescribeVolumesRequest volumesRequest = new DescribeVolumesRequest().withVolumeIds(volumeId).withFilters(filter);
host.waitFor("Timeout waiting for creating volume", () -> {
DescribeVolumesResult volumesResult = client.describeVolumes(volumesRequest);
String state = volumesResult.getVolumes().get(0).getState();
if (state.equalsIgnoreCase(VOLUME_STATUS_AVAILABLE)) {
return true;
}
return false;
});
tagResources(client, Arrays.asList(volumeId), TAG_KEY_FOR_TEST_RESOURCES, TAG_VALUE_FOR_TEST_RESOURCES + TAG_VOLUME);
return volumeId;
}
use of com.amazonaws.services.ec2.model.DescribeVolumesRequest in project cloudbreak by hortonworks.
the class EbsVolumeStatusCheckerTask method doCall.
@Override
protected Boolean doCall() {
LOGGER.info("Checking if AWS EBS volume '{}' is created.", volumeId);
DescribeVolumesResult describeVolumesResult = amazonEC2Client.describeVolumes(new DescribeVolumesRequest().withVolumeIds(volumeId));
Optional<Volume> volume = describeVolumesResult.getVolumes().stream().findFirst();
return volume.isPresent() && "available".equals(volume.get().getState());
}
use of com.amazonaws.services.ec2.model.DescribeVolumesRequest in project SimianArmy by Netflix.
the class AWSClient method describeVolumes.
/**
* Describe a set of specific EBS volumes.
*
* @param volumeIds the volume ids
* @return the volumes
*/
public List<Volume> describeVolumes(String... volumeIds) {
if (volumeIds == null || volumeIds.length == 0) {
LOGGER.info(String.format("Getting all EBS volumes in region %s.", region));
} else {
LOGGER.info(String.format("Getting EBS volumes for %d ids in region %s.", volumeIds.length, region));
}
AmazonEC2 ec2Client = ec2Client();
DescribeVolumesRequest request = new DescribeVolumesRequest();
if (volumeIds != null) {
request.setVolumeIds(Arrays.asList(volumeIds));
}
DescribeVolumesResult result = ec2Client.describeVolumes(request);
List<Volume> volumes = result.getVolumes();
LOGGER.info(String.format("Got %d EBS volumes in region %s.", volumes.size(), region));
return volumes;
}
use of com.amazonaws.services.ec2.model.DescribeVolumesRequest in project photon-model by vmware.
the class AWSTaskStatusChecker method buildRequest.
private AmazonWebServiceRequest buildRequest(T type) {
if (type instanceof Instance) {
DescribeInstancesRequest descRequest = new DescribeInstancesRequest();
List<String> instanceIdList = new ArrayList<>();
instanceIdList.add(this.instanceId);
descRequest.setInstanceIds(instanceIdList);
return descRequest;
} else if (type instanceof NatGateway) {
DescribeNatGatewaysRequest descRequest = new DescribeNatGatewaysRequest();
List<String> instanceIdList = new ArrayList<>();
instanceIdList.add(this.instanceId);
descRequest.setNatGatewayIds(instanceIdList);
return descRequest;
} else if (type instanceof Volume) {
DescribeVolumesRequest descRequest = new DescribeVolumesRequest();
List<String> volumeIdList = new ArrayList<>();
volumeIdList.add(this.instanceId);
descRequest.setVolumeIds(volumeIdList);
return descRequest;
} else {
AWSTaskStatusChecker.this.taskManager.patchTaskToFailure(new IllegalArgumentException("Invalid type " + type));
return null;
}
}
Aggregations