当前位置: 首页>>代码示例>>Java>>正文


Java DescribeVolumesResult类代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.DescribeVolumesResult的典型用法代码示例。如果您正苦于以下问题:Java DescribeVolumesResult类的具体用法?Java DescribeVolumesResult怎么用?Java DescribeVolumesResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DescribeVolumesResult类属于com.amazonaws.services.ec2.model包,在下文中一共展示了DescribeVolumesResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
/**
 * Describe All Volume.
 *
 * @return Collection Volume
 */
protected final List<Volume> getVolumes() {
    List<Volume> volumes = null;

    DescribeVolumesRequest req = new DescribeVolumesRequest();
    req.setMaxResults(20);
    DescribeVolumesResult result = amazonEC2Client.describeVolumes(req);
    if (result != null && !result.getVolumes().isEmpty()) {
        volumes = result.getVolumes();
        log.info("Page Size : " + volumes.size());
    }

    while(result.getNextToken() != null) { 
        req.setNextToken(result.getNextToken());
        result = amazonEC2Client.describeVolumes(req);
        if (result != null && !result.getVolumes().isEmpty()) {
             volumes = result.getVolumes();
             log.info("Page Size : " + volumes.size());
        }
    }
    
    return volumes;
}
 
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:28,代码来源:BaseTest.java

示例2: onSuccess

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
@Override
public void onSuccess(DescribeVolumesRequest request,
        DescribeVolumesResult result) {
    OperationContext.restoreOperationContext(this.opContext);
    result.getVolumes()
            .forEach(volume -> {
                this.context.remoteAWSVolumes.put(volume.getVolumeId(), volume);
                this.context.remoteAWSVolumeIds.add(volume.getVolumeId());
            });

    this.service.logFine(() -> String.format("Successfully enumerated %d volumes on the AWS"
            + " host", result.getVolumes().size()));
    // Save the reference to the next token that will be used to retrieve the next page of
    // results from AWS.
    this.context.nextToken = result.getNextToken();
    if (this.context.remoteAWSVolumes.size() == 0) {
        if (this.context.nextToken != null) {
            this.context.subStage = EBSVolumesEnumerationSubStage.GET_NEXT_PAGE;
        } else {
            this.context.subStage = EBSVolumesEnumerationSubStage.DELETE_DISKS;
        }
    }
    handleReceivedEnumerationData();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:25,代码来源:AWSEBSStorageEnumerationAdapterService.java

示例3: createVolume

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
/**
 * 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;
    });
    return volumeId;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:TestAWSSetupUtils.java

示例4: getAwsDisksByIds

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
/**
 * 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<>();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:27,代码来源:TestProvisionAWSDisk.java

示例5: getVolume

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
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);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:18,代码来源:TestAWSProvisionTask.java

示例6: getAllEBSVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
/**
 * This method returns all the volumes.
 * @return returns list of EBS volumes.
 */
public List<Volume> getAllEBSVolumes() throws AmazonClientException {
    
    List<Volume> allEBSVolumes;
    try {
        DescribeVolumesResult describeVolumesResult = this.amazonEc2.describeVolumes();
        allEBSVolumes = describeVolumesResult.getVolumes();
        
    } catch(AmazonClientException e) {
        System.out.println("ERROR : fetching volumes.");
        e.printStackTrace();
        throw e;
    }
    
    List<String> allVolumesIds = allEBSVolumes.stream().map(e -> e.getVolumeId()).collect(Collectors.toList());
    System.out.println("INFO : All Volumes Ids : " + allVolumesIds);
    return allEBSVolumes;
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:22,代码来源:EC2UtilsImpl.java

示例7: getVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
/**
 * Get EBS volumes attached to the specified virtual instance id.
 *
 * @return list of ebs volumes
 */
@VisibleForTesting
List<Volume> getVolumes(String virtualInstanceId) {
  String ec2InstanceId = getOnlyElement(
      getEC2InstanceIdsByVirtualInstanceId(
          Collections.singletonList(virtualInstanceId)
      ).values()
  );

  InstanceAttribute instanceAttribute =
      describeInstanceAttribute(ec2InstanceId, InstanceAttributeName.BlockDeviceMapping);
  List<InstanceBlockDeviceMapping> blockDeviceMappings =
      instanceAttribute.getBlockDeviceMappings();

  List<String> volumeIds = Lists.newArrayList();
  for (InstanceBlockDeviceMapping mapping : blockDeviceMappings) {
    volumeIds.add(mapping.getEbs().getVolumeId());
  }

  DescribeVolumesResult volumeResults = client.describeVolumes(
      new DescribeVolumesRequest().withVolumeIds(volumeIds)
  );

  return volumeResults.getVolumes();
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:30,代码来源:EC2Provider.java

示例8: describeVolume

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
public Volume describeVolume(AwsProcessClient awsProcessClient, String volumeId) {
    // 単一ボリュームの参照
    DescribeVolumesRequest request = new DescribeVolumesRequest();
    request.withVolumeIds(volumeId);
    DescribeVolumesResult result = awsProcessClient.getEc2Client().describeVolumes(request);
    List<Volume> volumes = result.getVolumes();

    // API実行結果チェック
    if (volumes.size() == 0) {
        // ボリュームが存在しない場合
        throw new AutoException("EPROCESS-000110", volumeId);

    } else if (volumes.size() > 1) {
        // ボリュームを複数参照できた場合
        AutoException exception = new AutoException("EPROCESS-000111", volumeId);
        exception.addDetailInfo("result=" + volumes);
        throw exception;
    }

    return volumes.get(0);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:22,代码来源:AwsCommonProcess.java

示例9: describeVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
@Override
public List<AbstractResource<?>> describeVolumes(Account account, Region region, DateTime dt, Ec2Filter... filters) {
    AmazonEC2 ec2 = findClient(account, region);

    DescribeVolumesRequest req = new DescribeVolumesRequest();
    for (Ec2Filter filter : filters) {
        Filter f = new Filter().withName(filter.getName()).withValues(filter.getValues());
        req.withFilters(f);
    }
    log.debug("start describing volumes for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
    DescribeVolumesResult res = ec2.describeVolumes(req);

    List<Boolean> autoEnableIOs = new ArrayList<>();
    List<List<ProductCode>> productCodes = new ArrayList<>();
    for (Volume volume : res.getVolumes()) {
        autoEnableIOs.add(findAutoEnableIO(account, region, volume.getVolumeId()));
        productCodes.add(findProductCodes(account, region, volume.getVolumeId()));
    }

    return converter.toEc2Volumes(res.getVolumes(), autoEnableIOs, productCodes, account.getId(), region, dt);
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:22,代码来源:Ec2WrapperImpl.java

示例10: describeBackupVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
List<Volume> describeBackupVolumes(AmazonEC2Async client, TagNameRequest target) {

		Filter tagKey = new Filter().withName("tag-key").withValues("Backup");
		Filter tagValue = new Filter().withName("tag-value").withValues(target.getTagName());
		DescribeVolumesRequest req = new DescribeVolumesRequest().withFilters(tagKey, tagValue);
		DescribeVolumesResult result = client.describeVolumes(req);

		return result.getVolumes();
	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:10,代码来源:EBSSnapshotFunction.java

示例11: createAWSRequestAndAsyncHandler

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:16,代码来源:AWSEBSStorageEnumerationAdapterService.java

示例12: testGetAllEBSVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
@Test
public void testGetAllEBSVolumes() {
    Volume volume1 = new Volume();
    Volume volume2 = new Volume();
    DescribeVolumesResult describeVolumesResult = new DescribeVolumesResult();
    describeVolumesResult.setVolumes(Arrays.asList(volume1,volume2));
    AmazonEC2 amazonEc2 = mock(AmazonEC2Client.class);
    when(amazonEc2.describeVolumes()).thenReturn(describeVolumesResult);
    assertEquals(2,describeVolumesResult.getVolumes().size());
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:11,代码来源:EC2UtilsImplTest.java

示例13: getVolume

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
private Volume getVolume(String snap) {
	DescribeVolumesResult volumes = ec2Client
			.describeVolumes(new DescribeVolumesRequest()
					.withFilters(new Filter().withName("snapshot-id")
							.withValues(snap)));

	return volumes.getVolumes().stream().findFirst().get();
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:9,代码来源:AWSHelper.java

示例14: volumeCreated

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
/**
 * Checks whether volume is created.
 * @param volumeId the EBS volume ID
 * @return true if volume created, false otherwise
 */
private boolean volumeCreated(String volumeId) {
	DescribeVolumesRequest dvs = new DescribeVolumesRequest();
	ArrayList<String> volumeIds = new ArrayList<String>();
	volumeIds.add(volumeId);
	dvs.setVolumeIds(volumeIds);
	DescribeVolumesResult dvsresult = null;
	try {
		dvsresult = this.ec2Api.describeVolumes(dvs);
	} catch(Exception e) {
		dvsresult = null;
	}

	return dvsresult != null && "available".equals(dvsresult.getVolumes().get(0).getState());
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:20,代码来源:Ec2MachineConfigurator.java

示例15: doCall

import com.amazonaws.services.ec2.model.DescribeVolumesResult; //导入依赖的package包/类
@Override
protected Boolean doCall() throws Exception {
    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()) : false;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:8,代码来源:EbsVolumeStatusCheckerTask.java


注:本文中的com.amazonaws.services.ec2.model.DescribeVolumesResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。