本文整理汇总了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;
}
示例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;
}
示例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);
}