本文整理汇总了Java中com.amazonaws.services.ec2.model.BlockDeviceMapping.getDeviceName方法的典型用法代码示例。如果您正苦于以下问题:Java BlockDeviceMapping.getDeviceName方法的具体用法?Java BlockDeviceMapping.getDeviceName怎么用?Java BlockDeviceMapping.getDeviceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.model.BlockDeviceMapping
的用法示例。
在下文中一共展示了BlockDeviceMapping.getDeviceName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMandatoryProperties
import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入方法依赖的package包/类
/**
* Add the disk information to disk state so that the disk state reflects the volume
* information
*/
private void addMandatoryProperties(DiskState diskState, BlockDeviceMapping deviceMapping,
InstanceType instanceType) {
if (diskState.customProperties == null) {
diskState.customProperties = new HashMap<>();
}
String deviceName = deviceMapping.getDeviceName();
diskState.customProperties.put(DEVICE_NAME, deviceName);
EbsBlockDevice ebs = deviceMapping.getEbs();
if (ebs != null) {
diskState.capacityMBytes = ebs.getVolumeSize() * 1024;
diskState.customProperties.put(DEVICE_TYPE, AWSStorageType.EBS.getName());
} else {
diskState.capacityMBytes = instanceType.dataDiskSizeInMB;
diskState.customProperties.put(DEVICE_TYPE, AWSStorageType.INSTANCE_STORE.getName());
}
}
示例2: buildLocalResourceState
import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入方法依赖的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);
}
示例3: selectRootDevice
import com.amazonaws.services.ec2.model.BlockDeviceMapping; //导入方法依赖的package包/类
/**
* Selects the root device from a list of block device mappings based on the
* root device name for the mappings' image.
*
* @param mappings list of block device mappings
* @param rootDeviceName image root device name
* @return root device mapping, or null if it could not be determined
*/
@VisibleForTesting
static BlockDeviceMapping selectRootDevice(List<BlockDeviceMapping> mappings,
String rootDeviceName) {
/*
* Heuristic to find the root device:
* - The best match is the EBS device that matches the root device name for the image, but
* this may not happen (/dev/sda1 vs. /dev/sda). See:
* http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html
* - If there isn't a best match, then a device whose name is a prefix for the image's root
* device name is selected.
* - If all else fails, it's the first EBS volume in the list.
*/
BlockDeviceMapping bestMatch = null;
BlockDeviceMapping firstEbs = null;
for (BlockDeviceMapping mapping : mappings) {
if (mapping.getEbs() == null) {
continue;
}
if (firstEbs == null) {
firstEbs = mapping;
}
if (mapping.getDeviceName() == null) {
continue;
}
if (rootDeviceName.equals(mapping.getDeviceName())) {
return mapping;
}
if (rootDeviceName.startsWith(mapping.getDeviceName())) {
bestMatch = mapping;
}
}
if (bestMatch != null) {
return bestMatch;
} else if (firstEbs != null) {
return firstEbs;
} else {
return null;
}
}