當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。