Java 类com.amazonaws.services.ec2.model.DeviceType 实例源码

项目:AWSConfig    文件:EC2UtilsImpl.java   
/**
 * This method returns all EBS root volumes.
 * @return 
 */
public List<Volume> getAllEBSRootVolumes() {

    List<Instance> allInstances =  getAllInstances();
    List<Volume> allEBSRootVolumes = new ArrayList<>();

    for(Instance instance: allInstances) {

        //We need volumes of type only EBS.
        if ( instance.getRootDeviceType().equalsIgnoreCase(DeviceType.Ebs.toString())) {
            String rootDeviceName = instance.getRootDeviceName();
            List<InstanceBlockDeviceMapping> instanceBlockDeviceMappings = instance.getBlockDeviceMappings();
            for(InstanceBlockDeviceMapping instanceBlockDeviceMapping: instanceBlockDeviceMappings) {
                if(instanceBlockDeviceMapping.getDeviceName().equalsIgnoreCase(rootDeviceName)) {
                    String volumeId = instanceBlockDeviceMapping.getEbs().getVolumeId();
                    Volume volume = new Volume().withVolumeId(volumeId);
                    allEBSRootVolumes.add(volume);
                }
            }
        }
    }

    System.out.println("INFO: Number of EBS Root Volumes : " + allEBSRootVolumes.size());
    List<String> volumeIds = allEBSRootVolumes.stream().map(e -> e.getVolumeId()).collect(Collectors.toList());
    System.out.println("INFO: EBS Root Volumes : " + volumeIds);

    return allEBSRootVolumes;
}
项目:primecloud-controller    文件:AwsInstanceProcess.java   
protected List<BlockDeviceMapping> createBlockDeviceMappings(AwsProcessClient awsProcessClient, ImageAws imageAws,
        AwsInstance awsInstance) {
    // イメージの取得
    com.amazonaws.services.ec2.model.Image image = awsCommonProcess.describeImage(awsProcessClient,
            imageAws.getImageId());

    if (image == null) {
        return null;
    }

    // EBSイメージでなければBlockDeviceMappingsを設定しない
    if (!image.getRootDeviceType().equals(DeviceType.Ebs.toString())) {
        return null;
    }

    List<BlockDeviceMapping> mappings = new ArrayList<BlockDeviceMapping>();

    // イメージのBlockDeviceMappingの設定
    List<BlockDeviceMapping> imageMappings = createImageBlockDeviceMappings(awsProcessClient, imageAws,
            awsInstance, image);
    if (imageMappings != null) {
        mappings.addAll(imageMappings);
    }

    // インスタンスストアのBlockDeviceMappingの設定
    List<BlockDeviceMapping> instanceStoreMappings = createInstanceStoreBlockDeviceMappings(awsProcessClient,
            imageAws, awsInstance, image);
    if (instanceStoreMappings != null) {
        mappings.addAll(instanceStoreMappings);
    }

    // 追加のBlockDeviceMappingの設定
    List<BlockDeviceMapping> additionalMappings = createAdditionalBlockDeviceMappings(awsProcessClient, imageAws,
            awsInstance, image);
    if (additionalMappings != null) {
        mappings.addAll(additionalMappings);
    }

    return mappings;
}
项目:photon-model    文件:AWSImageEnumerationAdapterService.java   
@Override
protected DeferredResult<LocalStateHolder> buildLocalResourceState(
        Image remoteImage, ImageState existingImageState) {

    LocalStateHolder holder = new LocalStateHolder();

    holder.localState = new ImageState();

    if (existingImageState == null) {
        // Create flow
        if (this.request.requestType == ImageEnumerateRequestType.PUBLIC) {
            holder.localState.endpointType = this.endpointState.endpointType;
        }
    } else {
        // Update flow: do nothing
    }

    // Both flows - populate from remote Image
    holder.localState.name = remoteImage.getName();
    holder.localState.description = remoteImage.getDescription();
    holder.localState.osFamily = remoteImage.getPlatform();

    holder.localState.diskConfigs = new ArrayList<>();
    if (DeviceType.Ebs == DeviceType.fromValue(remoteImage.getRootDeviceType())) {
        for (BlockDeviceMapping blockDeviceMapping : remoteImage.getBlockDeviceMappings()) {
            // blockDeviceMapping can be with noDevice
            EbsBlockDevice ebs = blockDeviceMapping.getEbs();
            if (ebs != null) {
                DiskConfiguration diskConfig = new DiskConfiguration();
                diskConfig.id = blockDeviceMapping.getDeviceName();
                diskConfig.encrypted = ebs.getEncrypted();
                diskConfig.persistent = true;
                if (ebs.getVolumeSize() != null) {
                    diskConfig.capacityMBytes = ebs.getVolumeSize() * 1024;
                }
                diskConfig.properties = Collections.singletonMap(
                        VOLUME_TYPE, ebs.getVolumeType());

                holder.localState.diskConfigs.add(diskConfig);
            }
        }
    }

    for (Tag remoteImageTag : remoteImage.getTags()) {
        holder.remoteTags.put(remoteImageTag.getKey(), remoteImageTag.getValue());
    }

    return DeferredResult.completed(holder);
}