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


Java DeviceType类代码示例

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


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

示例1: getAllEBSRootVolumes

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

示例2: createBlockDeviceMappings

import com.amazonaws.services.ec2.model.DeviceType; //导入依赖的package包/类
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;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:41,代码来源:AwsInstanceProcess.java

示例3: buildLocalResourceState

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


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