本文整理汇总了Java中com.amazonaws.services.ec2.model.Instance.getRootDeviceName方法的典型用法代码示例。如果您正苦于以下问题:Java Instance.getRootDeviceName方法的具体用法?Java Instance.getRootDeviceName怎么用?Java Instance.getRootDeviceName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.model.Instance
的用法示例。
在下文中一共展示了Instance.getRootDeviceName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllEBSRootVolumes
import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的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: getPropertyValue
import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
@Override
protected String getPropertyValue(Instance instance) {
return instance.getRootDeviceName();
}