• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DescribeVolumesRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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: runSearch

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


示例3: onSuccess

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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


示例4: createVolume

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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


示例5: getAwsDisksByIds

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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


示例6: getVolume

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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


示例7: getVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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.DescribeVolumesRequest; //导入依赖的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.DescribeVolumesRequest; //导入依赖的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.DescribeVolumesRequest; //导入依赖的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.DescribeVolumesRequest; //导入依赖的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: getVolume

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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


示例13: volumeCreated

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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


示例14: getVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的package包/类
@Override
public VolumeCollection getVolumes(DescribeVolumesRequest request) {
    ResourceCollectionImpl result = resource.getCollection("Volumes",
            request);

    if (result == null) return null;
    return new VolumeCollectionImpl(result);
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:9,代码来源:InstanceImpl.java


示例15: getVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的package包/类
@Override
public VolumeCollection getVolumes(DescribeVolumesRequest request) {
    ResourceCollectionImpl result = service.getCollection("Volumes",
            request);

    if (result == null) return null;
    return new VolumeCollectionImpl(result);
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:9,代码来源:EC2Impl.java


示例16: doCall

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的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


示例17: getVolume

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的package包/类
/**
 * Describe Volume.
 *
 * @return Volume
 */
protected final Volume getVolume() {
    Volume volume = null;

    DescribeVolumesRequest req = new DescribeVolumesRequest();
    DescribeVolumesResult result = amazonEC2Client.describeVolumes(req);
    if (result != null && !result.getVolumes().isEmpty()) {
        volume = result.getVolumes().get(0);
    }

    return volume;
}
 
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:17,代码来源:BaseTest.java


示例18: describeVolumes

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的package包/类
@Override
public DescribeVolumesResult describeVolumes(DescribeVolumesRequest describeVolumesRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java


示例19: waitUntilVolumesAttached

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的package包/类
/**
 * Wait for the specified list of volumes to be attached within a timeout.
 *
 * @param volumeIds collection of volume ids to wait for
 * @return collection of volumes that were successfully attached
 * @throws InterruptedException if the operation is interrupted
 */
private Collection<String> waitUntilVolumesAttached(Collection<String> volumeIds) throws InterruptedException {
  checkNotNull(volumeIds);
  if (volumeIds.isEmpty()) {
    LOG.info("No volumes are being attached, skipping wait");
    return Collections.emptySet();
  }

  Set<String> unattachedVolumes = Sets.newHashSet(volumeIds);
  Set<String> attachedVolumes = Sets.newHashSet();

  LOG.info("Waiting for a maximum of {} seconds for volumes to be attached",
      attachTimeoutSeconds);

  Stopwatch watch = Stopwatch.createStarted();
  while (watch.elapsed(TimeUnit.SECONDS) < attachTimeoutSeconds) {
    DescribeVolumesRequest volumeRequest = new DescribeVolumesRequest().withVolumeIds(unattachedVolumes);
    List<Volume> volumes = client.describeVolumes(volumeRequest).getVolumes();

    for (Volume volume : volumes) {
      VolumeAttachment attachment = Iterables.getOnlyElement(volume.getAttachments());
      VolumeAttachmentState state = VolumeAttachmentState.fromValue(attachment.getState());

      if (state == VolumeAttachmentState.Attached) {
        unattachedVolumes.remove(volume.getVolumeId());
        attachedVolumes.add(volume.getVolumeId());
      }
    }

    if (unattachedVolumes.isEmpty()) {
      return attachedVolumes;
    }

    LOG.info("Waiting on {} out of {} volumes to be attached, next check in {} seconds",
        unattachedVolumes.size(), volumeIds.size(), WAIT_UNTIL_ATTACHED_INTERVAL_SECONDS);
    TimeUnit.SECONDS.sleep(WAIT_UNTIL_ATTACHED_INTERVAL_SECONDS);
  }

  LOG.error("Timed out while waiting for all volumes to be attached, {} out of {} volumes were attached",
      attachedVolumes.size(), volumeIds.size());
  return attachedVolumes;
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:49,代码来源:EBSAllocator.java


示例20: itShouldDeleteTheStorageArtifacts

import com.amazonaws.services.ec2.model.DescribeVolumesRequest; //导入依赖的package包/类
@Test
public void itShouldDeleteTheStorageArtifacts()
		throws ServiceInstanceBindingExistsException,
		ServiceBrokerException {

	when(ec2Client.describeSnapshots())
			.thenReturn(
					new DescribeSnapshotsResult().withSnapshots(Arrays.asList(
							new Snapshot()
									.withDescription("Created by CreateImage(source_instance) for ami-9687d2fe from vol-e7526fac"),
							new Snapshot()
									.withDescription(
											"Created by CreateImage(source_instance) for test_image from vol-e7526fac")
									.withSnapshotId("test_snapshot"),
							new Snapshot()
									.withDescription("Created by CreateImage(i-bf72d345) for ami-xx from vol-e7526fac"),
							new Snapshot())));

	Predicate<DescribeVolumesRequest> pred = new Predicate<DescribeVolumesRequest>() {
		@Override
		public boolean test(DescribeVolumesRequest r) {
			Filter filter = r.getFilters().stream().findFirst().get();
			return filter.getName().equals("snapshot-id")
					&& filter.getValues().stream().findFirst().get()
							.equals("test_snapshot");
		}
	};

	DescribeVolumesResult volumesResult = new DescribeVolumesResult()
			.withVolumes(Collections.singletonList(new Volume()
					.withVolumeId("test_volume")));

	when(ec2Client.describeVolumes(awsRqst(pred)))
			.thenReturn(volumesResult);

	aws.deleteStorageArtifacts("test_image");

	verify(ec2Client).deleteSnapshot(
			awsRqst(r -> r.getSnapshotId().equals("test_snapshot")));

	verify(ec2Client).deleteVolume(
			awsRqst(r -> r.getVolumeId().equals("test_volume")));

}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:45,代码来源:AWSHelperTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MethodBinding类代码示例发布时间:2022-05-22
下一篇:
Java DefaultMockMvcBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap