/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDeviceName() != null) sb.append("DeviceName: ").append(getDeviceName()).append(","); if (getEbs() != null) sb.append("Ebs: ").append(getEbs()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof InstanceBlockDeviceMapping == false) return false; InstanceBlockDeviceMapping other = (InstanceBlockDeviceMapping) obj; if (other.getDeviceName() == null ^ this.getDeviceName() == null) return false; if (other.getDeviceName() != null && other.getDeviceName().equals(this.getDeviceName()) == false) return false; if (other.getEbs() == null ^ this.getEbs() == null) return false; if (other.getEbs() != null && other.getEbs().equals(this.getEbs()) == false) return false; return true; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof InstanceBlockDeviceMapping == false) return false; InstanceBlockDeviceMapping other = (InstanceBlockDeviceMapping)obj; if (other.getDeviceName() == null ^ this.getDeviceName() == null) return false; if (other.getDeviceName() != null && other.getDeviceName().equals(this.getDeviceName()) == false) return false; if (other.getEbs() == null ^ this.getEbs() == null) return false; if (other.getEbs() != null && other.getEbs().equals(this.getEbs()) == false) return false; return true; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDeviceName() != null) sb.append("DeviceName: " + getDeviceName() + ","); if (getEbs() != null) sb.append("Ebs: " + getEbs() ); sb.append("}"); return sb.toString(); }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDeviceName() != null) sb.append("DeviceName: ").append(getDeviceName()).append(","); if (getEbs() != null) sb.append("Ebs: ").append(getEbs()); sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof InstanceBlockDeviceMapping == false) return false; InstanceBlockDeviceMapping other = (InstanceBlockDeviceMapping) obj; if (other.getDeviceName() == null ^ this.getDeviceName() == null) return false; if (other.getDeviceName() != null && other.getDeviceName().equals(this.getDeviceName()) == false) return false; if (other.getEbs() == null ^ this.getEbs() == null) return false; if (other.getEbs() != null && other.getEbs().equals(this.getEbs()) == false) return false; return true; }
private List<String> getResourcesToTag(Instance inst) { List<String> resources = new ArrayList<>(); resources.add(inst.getInstanceId()); for(InstanceBlockDeviceMapping blockDeviceMapping : inst.getBlockDeviceMappings()) { resources.add(blockDeviceMapping.getEbs().getVolumeId()); } return resources; }
// First get the EC2 instance from the id DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest().withInstanceIds(instanceId); DescribeInstancesResult describeInstancesResult = ec2.describeInstances(describeInstancesRequest); Instance instance = describeInstancesResult.getReservations().get(0).getInstances().get(0); // Then get the mappings List<InstanceBlockDeviceMapping> mappingList = instance.getBlockDeviceMappings(); for(InstanceBlockDeviceMapping mapping: mappingList) { System.out.println(mapping.getEbs().getVolumeId()); }
protected String getRootVolumeId(Instance instance) { checkNotNull(instance, "instance"); InstanceBlockDeviceMapping rootMapping = getRootVolumeMapping(instance); return rootMapping.getEbs().getVolumeId(); }
protected BlockDeviceMapping convert(InstanceBlockDeviceMapping mapping, String snapshotId, int sizeInGigabytes) { BlockDeviceMapping converted = new BlockDeviceMapping(); converted.setDeviceName(mapping.getDeviceName()); converted.setEbs(convert(mapping.getEbs(), snapshotId, sizeInGigabytes)); return converted; }