List of usage examples for com.amazonaws.services.ec2.model Volume Volume
Volume
From source file:com.vb.aws.services.compute.ec2.EC2UtilsImpl.java
/** * This method returns all EBS root volumes. * @return /*from w ww .ja v a 2 s .c om*/ */ 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; }
From source file:jp.primecloud.auto.aws.typica.converter.VolumeConverter.java
License:Open Source License
@Override protected Volume convertObject(VolumeInfo from) { Volume to = new Volume(); to.setVolumeId(from.getVolumeId());/* www.ja v a 2 s. c om*/ Integer size = null; if (from.getSize() != null && from.getSize().length() != 0) { size = Integer.valueOf(from.getSize()); } to.setSize(size); to.setSnapshotId(from.getSnapshotId()); to.setAvailabilityZone(from.getZone()); to.setState(from.getStatus()); to.setCreateTime(from.getCreateTime().getTime()); to.setAttachments(new VolumeAttachmentConverter().convert(from.getAttachmentInfo())); // to.setTags(null); return to; }