本文整理匯總了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();
}