if (getState() != null) sb.append("State: ").append(getState()).append(","); if (getBlockDeviceMappings() != null) sb.append("BlockDeviceMappings: ").append(getBlockDeviceMappings()).append(","); if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getArchitecture() == null) ? 0 : getArchitecture().hashCode()); hashCode = prime * hashCode + ((getCreationDate() == null) ? 0 : getCreationDate().hashCode()); hashCode = prime * hashCode + ((getImageId() == null) ? 0 : getImageId().hashCode()); hashCode = prime * hashCode + ((getImageLocation() == null) ? 0 : getImageLocation().hashCode()); hashCode = prime * hashCode + ((getImageType() == null) ? 0 : getImageType().hashCode()); hashCode = prime * hashCode + ((getPublic() == null) ? 0 : getPublic().hashCode()); hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode()); hashCode = prime * hashCode + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode()); hashCode = prime * hashCode + ((getPlatform() == null) ? 0 : getPlatform().hashCode()); hashCode = prime * hashCode + ((getProductCodes() == null) ? 0 : getProductCodes().hashCode()); hashCode = prime * hashCode + ((getRamdiskId() == null) ? 0 : getRamdiskId().hashCode()); hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getBlockDeviceMappings() == null) ? 0 : getBlockDeviceMappings().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getEnaSupport() == null) ? 0 : getEnaSupport().hashCode()); hashCode = prime * hashCode + ((getHypervisor() == null) ? 0 : getHypervisor().hashCode()); hashCode = prime * hashCode + ((getImageOwnerAlias() == null) ? 0 : getImageOwnerAlias().hashCode()); hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getRootDeviceName() == null) ? 0 : getRootDeviceName().hashCode()); hashCode = prime * hashCode + ((getRootDeviceType() == null) ? 0 : getRootDeviceType().hashCode()); hashCode = prime * hashCode + ((getSriovNetSupport() == null) ? 0 : getSriovNetSupport().hashCode()); hashCode = prime * hashCode + ((getStateReason() == null) ? 0 : getStateReason().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getVirtualizationType() == null) ? 0 : getVirtualizationType().hashCode()); return hashCode; }
if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; if (other.getBlockDeviceMappings() == null ^ this.getBlockDeviceMappings() == null) return false; if (other.getBlockDeviceMappings() != null && other.getBlockDeviceMappings().equals(this.getBlockDeviceMappings()) == false) return false; if (other.getDescription() == null ^ this.getDescription() == null)
/** * Any block device mapping entries. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param blockDeviceMappings Any block device mapping entries. * * @return A reference to this updated object so that method calls can be chained * together. */ public Image withBlockDeviceMappings(BlockDeviceMapping... blockDeviceMappings) { if (getBlockDeviceMappings() == null) setBlockDeviceMappings(new java.util.ArrayList<BlockDeviceMapping>(blockDeviceMappings.length)); for (BlockDeviceMapping value : blockDeviceMappings) { getBlockDeviceMappings().add(value); } return this; }
hashCode = prime * hashCode + ((getRootDeviceType() == null) ? 0 : getRootDeviceType().hashCode()); hashCode = prime * hashCode + ((getRootDeviceName() == null) ? 0 : getRootDeviceName().hashCode()); hashCode = prime * hashCode + ((getBlockDeviceMappings() == null) ? 0 : getBlockDeviceMappings().hashCode()); hashCode = prime * hashCode + ((getVirtualizationType() == null) ? 0 : getVirtualizationType().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode());
if (getRootDeviceType() != null) sb.append("RootDeviceType: " + getRootDeviceType() + ","); if (getRootDeviceName() != null) sb.append("RootDeviceName: " + getRootDeviceName() + ","); if (getBlockDeviceMappings() != null) sb.append("BlockDeviceMappings: " + getBlockDeviceMappings() + ","); if (getVirtualizationType() != null) sb.append("VirtualizationType: " + getVirtualizationType() + ","); if (getTags() != null) sb.append("Tags: " + getTags() + ",");
if (other.getRootDeviceName() == null ^ this.getRootDeviceName() == null) return false; if (other.getRootDeviceName() != null && other.getRootDeviceName().equals(this.getRootDeviceName()) == false) return false; if (other.getBlockDeviceMappings() == null ^ this.getBlockDeviceMappings() == null) return false; if (other.getBlockDeviceMappings() != null && other.getBlockDeviceMappings().equals(this.getBlockDeviceMappings()) == false) return false; if (other.getVirtualizationType() == null ^ this.getVirtualizationType() == null) return false; if (other.getVirtualizationType() != null && other.getVirtualizationType().equals(this.getVirtualizationType()) == false) return false;
private List<BlockDeviceMapping> getAmiBlockDeviceMappings() { /* * AmazonEC2#describeImageAttribute does not work due to a bug * https://forums.aws.amazon.com/message.jspa?messageID=231972 */ return getImage().getBlockDeviceMappings(); }
protected BlockDeviceMapping getRootBlockDeviceMapping(Image image) { String rootDeviceName = image.getRootDeviceName(); List<BlockDeviceMapping> mappings = image.getBlockDeviceMappings(); for (BlockDeviceMapping mapping : mappings) { String deviceName = mapping.getDeviceName(); if (rootDeviceName.equals(deviceName)) { return mapping; } } throw illegalState("Could not locate the root block device mapping for AMI [%s]", image.getImageId()); }
@Override public void purgeAmi(String imageId) { Image image = getImage(imageId); List<String> snapshotIds = newArrayList(); List<BlockDeviceMapping> mappings = image.getBlockDeviceMappings(); for (BlockDeviceMapping mapping : mappings) { Optional<EbsBlockDevice> ebsBlockDevice = fromNullable(mapping.getEbs()); if (ebsBlockDevice.isPresent()) { snapshotIds.add(ebsBlockDevice.get().getSnapshotId()); } } DeregisterImageRequest request = new DeregisterImageRequest(); request.setImageId(imageId); client.deregisterImage(request); for (String snapshotId : snapshotIds) { deleteSnapshot(snapshotId); } }
private List<BlockDeviceMapping> getAmiBlockDeviceMappings() { /* * AmazonEC2#describeImageAttribute does not work due to a bug * https://forums.aws.amazon.com/message.jspa?messageID=231972 */ for (final Image image: getParent().connect().describeImages().getImages()) { if (ami.equals(image.getImageId())) { return image.getBlockDeviceMappings(); } } throw new AmazonClientException("Unable to get AMI device mapping for " + ami); }
if (getState() != null) sb.append("State: ").append(getState()).append(","); if (getBlockDeviceMappings() != null) sb.append("BlockDeviceMappings: ").append(getBlockDeviceMappings()).append(","); if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(",");
image.getBlockDeviceMappings().add(BlockDeviceMappingStaxUnmarshaller.getInstance().unmarshall(context)); continue;
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getArchitecture() == null) ? 0 : getArchitecture().hashCode()); hashCode = prime * hashCode + ((getCreationDate() == null) ? 0 : getCreationDate().hashCode()); hashCode = prime * hashCode + ((getImageId() == null) ? 0 : getImageId().hashCode()); hashCode = prime * hashCode + ((getImageLocation() == null) ? 0 : getImageLocation().hashCode()); hashCode = prime * hashCode + ((getImageType() == null) ? 0 : getImageType().hashCode()); hashCode = prime * hashCode + ((getPublic() == null) ? 0 : getPublic().hashCode()); hashCode = prime * hashCode + ((getKernelId() == null) ? 0 : getKernelId().hashCode()); hashCode = prime * hashCode + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode()); hashCode = prime * hashCode + ((getPlatform() == null) ? 0 : getPlatform().hashCode()); hashCode = prime * hashCode + ((getProductCodes() == null) ? 0 : getProductCodes().hashCode()); hashCode = prime * hashCode + ((getRamdiskId() == null) ? 0 : getRamdiskId().hashCode()); hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); hashCode = prime * hashCode + ((getBlockDeviceMappings() == null) ? 0 : getBlockDeviceMappings().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getEnaSupport() == null) ? 0 : getEnaSupport().hashCode()); hashCode = prime * hashCode + ((getHypervisor() == null) ? 0 : getHypervisor().hashCode()); hashCode = prime * hashCode + ((getImageOwnerAlias() == null) ? 0 : getImageOwnerAlias().hashCode()); hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getRootDeviceName() == null) ? 0 : getRootDeviceName().hashCode()); hashCode = prime * hashCode + ((getRootDeviceType() == null) ? 0 : getRootDeviceType().hashCode()); hashCode = prime * hashCode + ((getSriovNetSupport() == null) ? 0 : getSriovNetSupport().hashCode()); hashCode = prime * hashCode + ((getStateReason() == null) ? 0 : getStateReason().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); hashCode = prime * hashCode + ((getVirtualizationType() == null) ? 0 : getVirtualizationType().hashCode()); return hashCode; }
protected List<BlockDeviceMapping> getUpdatedBlockDeviceMappings(LaunchInstanceContext context) { // Get an Image object from Amazon for the AMI we are working with Image ami = getAmi(context.getAmi()); // Update the root volume as needed if (context.getRootVolume().isPresent()) { updateRootBlockDeviceMapping(ami, context.getRootVolume().get()); } // Store all of the existing block device mappings List<BlockDeviceMapping> mappings = newArrayList(ami.getBlockDeviceMappings()); // Cycle through the additional mappings, updating existing mappings with new mappings as we go for (BlockDeviceMapping additionalMapping : context.getAdditionalMappings()) { // Look for a match in the existing mappings Optional<BlockDeviceMapping> optional = findMatch(mappings, additionalMapping); // Check to see if we found a match if (optional.isPresent()) { // If so, override any existing block device settings with the new settings BlockDeviceMapping existing = optional.get(); existing.setDeviceName(additionalMapping.getDeviceName()); existing.setEbs(additionalMapping.getEbs()); existing.setNoDevice(additionalMapping.getNoDevice()); existing.setVirtualName(additionalMapping.getVirtualName()); } else { // Otherwise just add the new mapping mappings.add(additionalMapping); } } // Return the updated list return mappings; }
if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; if (other.getBlockDeviceMappings() == null ^ this.getBlockDeviceMappings() == null) return false; if (other.getBlockDeviceMappings() != null && other.getBlockDeviceMappings().equals(this.getBlockDeviceMappings()) == false) return false; if (other.getDescription() == null ^ this.getDescription() == null)