@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDeviceName() == null) ? 0 : getDeviceName().hashCode()); hashCode = prime * hashCode + ((getEbs() == null) ? 0 : getEbs().hashCode()); return hashCode; }
/** * <p> * The device name (for example, <code>/dev/sdh</code> or <code>xvdh</code>). * </p> * * @param deviceName * The device name (for example, <code>/dev/sdh</code> or <code>xvdh</code>). * @return Returns a reference to this object so that method calls can be chained together. */ public InstanceBlockDeviceMapping withDeviceName(String deviceName) { setDeviceName(deviceName); return this; }
/** * <p> * Parameters used to automatically set up EBS volumes when the instance is launched. * </p> * * @param ebs * Parameters used to automatically set up EBS volumes when the instance is launched. * @return Returns a reference to this object so that method calls can be chained together. */ public InstanceBlockDeviceMapping withEbs(EbsInstanceBlockDevice ebs) { setEbs(ebs); return this; }
public InstanceBlockDeviceMapping unmarshall(StaxUnmarshallerContext context) throws Exception { InstanceBlockDeviceMapping instanceBlockDeviceMapping = new InstanceBlockDeviceMapping(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return instanceBlockDeviceMapping; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("deviceName", targetDepth)) { instanceBlockDeviceMapping.setDeviceName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("ebs", targetDepth)) { instanceBlockDeviceMapping.setEbs(EbsInstanceBlockDeviceStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return instanceBlockDeviceMapping; } } } }
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; }
protected InstanceBlockDeviceMapping getRootVolumeMapping(Instance instance) { checkNotNull(instance, "instance"); String rootDeviceName = instance.getRootDeviceName(); List<InstanceBlockDeviceMapping> mappings = instance.getBlockDeviceMappings(); for (InstanceBlockDeviceMapping mapping : mappings) { if (rootDeviceName.equals(mapping.getDeviceName())) { return mapping; } } throw illegalState("Unable to locate the root volume mapping for [%s]", instance.getInstanceId()); }
public InstanceBlockDeviceMapping unmarshall(StaxUnmarshallerContext context) throws Exception { InstanceBlockDeviceMapping instanceBlockDeviceMapping = new InstanceBlockDeviceMapping(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return instanceBlockDeviceMapping; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("deviceName", targetDepth)) { instanceBlockDeviceMapping.setDeviceName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("ebs", targetDepth)) { instanceBlockDeviceMapping.setEbs(EbsInstanceBlockDeviceStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return instanceBlockDeviceMapping; } } } }
// 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 BlockDeviceMapping getRootVolumeMapping(Instance instance, String snapshotId, RootVolume rootVolume) { InstanceBlockDeviceMapping ibdm = getRootVolumeMapping(instance); EbsBlockDevice ebs = new EbsBlockDevice(); ebs.setDeleteOnTermination(rootVolume.getDeleteOnTermination().orNull()); ebs.setSnapshotId(snapshotId); ebs.setVolumeSize(rootVolume.getSizeInGigabytes().orNull()); BlockDeviceMapping bdm = new BlockDeviceMapping(); bdm.setDeviceName(ibdm.getDeviceName()); bdm.setEbs(ebs); return bdm; }
@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; }
public InstanceBlockDeviceMapping unmarshall(StaxUnmarshallerContext context) throws Exception { InstanceBlockDeviceMapping instanceBlockDeviceMapping = new InstanceBlockDeviceMapping(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return instanceBlockDeviceMapping; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("deviceName", targetDepth)) { instanceBlockDeviceMapping.setDeviceName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("ebs", targetDepth)) { instanceBlockDeviceMapping.setEbs(EbsInstanceBlockDeviceStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return instanceBlockDeviceMapping; } } } }
protected String getRootVolumeId(Instance instance) { checkNotNull(instance, "instance"); InstanceBlockDeviceMapping rootMapping = getRootVolumeMapping(instance); return rootMapping.getEbs().getVolumeId(); }
/** * <p> * Parameters used to automatically set up EBS volumes when the instance is launched. * </p> * * @param ebs * Parameters used to automatically set up EBS volumes when the instance is launched. * @return Returns a reference to this object so that method calls can be chained together. */ public InstanceBlockDeviceMapping withEbs(EbsInstanceBlockDevice ebs) { setEbs(ebs); return this; }
/** * <p> * The device name (for example, <code>/dev/sdh</code> or <code>xvdh</code>). * </p> * * @param deviceName * The device name (for example, <code>/dev/sdh</code> or <code>xvdh</code>). * @return Returns a reference to this object so that method calls can be chained together. */ public InstanceBlockDeviceMapping withDeviceName(String deviceName) { setDeviceName(deviceName); return this; }
/** * 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 int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDeviceName() == null) ? 0 : getDeviceName().hashCode()); hashCode = prime * hashCode + ((getEbs() == null) ? 0 : getEbs().hashCode()); return hashCode; }
/** * 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(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDeviceName() == null) ? 0 : getDeviceName().hashCode()); hashCode = prime * hashCode + ((getEbs() == null) ? 0 : getEbs().hashCode()); return hashCode; }
@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; }