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


Java Volume类代码示例

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


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

示例1: getVolumes

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

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
public void createSnapshotFromTagName(TagNameRequest tagNameRequest, Context context) {

		LambdaLogger logger = context.getLogger();
		logger.log("create ebs snapshot from tag name Start. backup target[" + tagNameRequest + "]");

		String regionName = System.getenv("AWS_DEFAULT_REGION");
		AmazonEC2Async client = RegionUtils.getRegion(regionName).createClient(AmazonEC2AsyncClient.class,
				new DefaultAWSCredentialsProviderChain(), cc);

		try {
			List<Volume> volumes = describeBackupVolumes(client, tagNameRequest);

			for (Volume volume : volumes) {
				createSnapshot(volume.getVolumeId(), tagNameRequest.getGenerationCount(), context);
			}
		} finally {
			client.shutdown();
		}
	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:20,代码来源:EBSSnapshotFunction.java

示例3: start

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
public void start(T type) {
    if (this.expirationTimeMicros > 0 && Utils.getNowMicrosUtc() > this.expirationTimeMicros) {
        String resource = "Compute";
        if (type instanceof Volume) {
            resource = "Volume";
        }

        String msg = String
                .format("%s with instance id %s did not reach desired %s state in the required time interval.",
                        resource, this.instanceId, this.desiredState);
        this.service.logSevere(() -> msg);
        this.taskManager.patchTaskToFailure(new RuntimeException(msg));
        return;
    }

    runSearch(type);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:18,代码来源:AWSTaskStatusChecker.java

示例4: runSearch

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

示例5: mapCustomProperties

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
/**
 * Method for mapping additionl properties in the EBS volume to the local diskstate. For e.g. snapshotID, iops,
 * encrypted etc.
 */
private void mapCustomProperties(DiskState diskState, Volume volume) {
    diskState.customProperties = new HashMap<>();
    if (volume.getSnapshotId() != null) {
        diskState.customProperties.put(SNAPSHOT_ID, volume.getSnapshotId());
    }
    if (volume.getIops() != null) {
        diskState.customProperties.put(DISK_IOPS, volume.getIops().toString());
    }
    if (volume.getEncrypted() != null) {
        diskState.customProperties.put(DISK_ENCRYPTED_FLAG,
                volume.getEncrypted().toString());
    }
    diskState.customProperties.put(VOLUME_TYPE,
            volume.getVolumeType());
    diskState.customProperties.put(SOURCE_TASK_LINK,
            ResourceEnumerationTaskService.FACTORY_LINK);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:22,代码来源:AWSEBSStorageEnumerationAdapterService.java

示例6: getAwsDisksByIds

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

示例7: assertBootDiskConfiguration

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
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);

    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);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:21,代码来源:TestAWSProvisionTask.java

示例8: getVolume

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

示例9: getAllEBSVolumes

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

示例10: getAllEncryptedEBSVolumes

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
/**
 * This method returns all encrypted EBS volumes.
 * @param allVolumes
 * @return returns list of all encrypted EBS volumes.
 */

public List<Volume> getAllEncryptedEBSVolumes(List<Volume> allEBSVolumes) {
    
    List<Volume> allEncryptedEBSVolumes = new ArrayList<Volume>();
    
    if ( allEBSVolumes != null || allEBSVolumes.size() > 0 ) {
        
        for(Volume volume : allEBSVolumes) {
            if( volume.isEncrypted()) {
                allEncryptedEBSVolumes.add(volume);
            }
        }

        List<String> allEncryptedVolumesIds = allEncryptedEBSVolumes.stream().map(e -> e.getVolumeId()).collect(Collectors.toList());
        System.out.println("INFO : All Encrypted EBS volumes : " + allEncryptedVolumesIds);
    }
    
    return allEncryptedEBSVolumes;
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:25,代码来源:EC2UtilsImpl.java

示例11: getAllEBSNonRootVolumes

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
/**
 * This method returns all EBS non root volumes.
 * @return 
 */
public List<Volume> getAllEBSNonRootVolumes(List<Volume> allEBSVolumes, List<Volume> allEBSRootVolumes) {
   
   List<Volume> allEBSNonRootVolumes = new ArrayList<>();
   
   if ( allEBSVolumes != null || allEBSVolumes.size() > 0 ) { 
   
        if (allEBSRootVolumes == null ) {
            allEBSRootVolumes = new ArrayList<>();
        }
        
        allEBSVolumes.removeAll(allEBSRootVolumes);
        allEBSNonRootVolumes = allEBSVolumes;
        List<String> allEBSNonRootVolumeIds = allEBSNonRootVolumes.stream().map(e -> e.getVolumeId()).collect(Collectors.toList());
        System.out.println("INFO : Number of EBS Non Root Volumes IDs : " + allEBSNonRootVolumeIds.size());
        System.out.println("INFO : EBS Non Root Volumes IDs : " + allEBSNonRootVolumeIds);
        
   }
   
   return allEBSNonRootVolumes;
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:25,代码来源:EC2UtilsImpl.java

示例12: getEBSVolumesAvailable

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
/**
 * This method returns list of EBS volumes which are available.
 * @return returns list of EBS volumes which are available.
 */
public List<Volume> getEBSVolumesAvailable(List<Volume> allEBSVolumes) {
    
    List<Volume> ebsVolumesAvailable = new ArrayList<>();
    
    for(Volume volume: allEBSVolumes) {
        if(volume.getState().equalsIgnoreCase(VolumeState.Available.toString())) {
            ebsVolumesAvailable.add(volume);
        }
    }
    
    System.out.println("INFO : Number of EBS volumes not in use : " + ebsVolumesAvailable.size());
    List<String> volumeIds = ebsVolumesAvailable.stream().map(e -> e.getVolumeId()).collect(Collectors.toList());
    System.out.println("INFO: EBS volumes not in use : " + volumeIds);
    
    return ebsVolumesAvailable;
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:21,代码来源:EC2UtilsImpl.java

示例13: createEvaluations

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
/**
 * This method returns list of Evaluation objects.
 * @param ebsVolumesAvailable
 * @return List<Evaluation> returns list of Evaluation objects.
 */
private List<Evaluation> createEvaluations(List<Volume> ebsVolumesAvailable) {
    
    List<Evaluation> evaluations = new ArrayList<>();
    
    if ( ebsVolumesAvailable == null || ebsVolumesAvailable.size() > 0 ) {
        
        for(Volume volume: ebsVolumesAvailable) {
            
            String volumeId = volume.getVolumeId();
            Evaluation evaluation = new Evaluation();
            evaluation.setComplianceResourceId(volumeId);
            evaluation.setComplianceResourceType(COMPLIANCE_RESOURCE_TYPE);
            evaluation.setComplianceType(ComplianceType.NON_COMPLIANT);
            evaluation.setOrderingTimestamp(new Date());
            evaluations.add(evaluation);
        }
    }
    
    System.out.println("INFO : Number of evaluations : " + evaluations.size());
    return evaluations;
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:27,代码来源:EBSVolumesAvailable.java

示例14: createEvaluations

import com.amazonaws.services.ec2.model.Volume; //导入依赖的package包/类
/**
 * This method returns list of Evaluation objects.
 * @param allNonEncryptedVolumes
 * @return List<Evaluation> returns list of Evaluation objects.
 */
private List<Evaluation> createEvaluations(List<Volume> allNonEncryptedEBSVolumes) {
    
    List<Evaluation> evaluations = new ArrayList<>();
    
    if ( allNonEncryptedEBSVolumes == null || allNonEncryptedEBSVolumes.size() > 0 ) {
        
        for(Volume volume: allNonEncryptedEBSVolumes) {
            
            String volumeId = volume.getVolumeId();
            Evaluation evaluation = new Evaluation();
            evaluation.setComplianceResourceId(volumeId);
            evaluation.setComplianceResourceType(COMPLIANCE_RESOURCE_TYPE);
            evaluation.setComplianceType(ComplianceType.NON_COMPLIANT);
            evaluation.setOrderingTimestamp(new Date());
            evaluations.add(evaluation);
        }
    }
    
    System.out.println("INFO : Number of evaluations : " + evaluations.size());
    return evaluations;
}
 
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:27,代码来源:NonEncryptedEBSVolumes.java

示例15: getVolumes

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


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