List of usage examples for com.amazonaws.services.ec2.model EbsBlockDevice getSnapshotId
public String getSnapshotId()
The ID of the snapshot.
From source file:com.carrotgarden.maven.aws.ecc.CarrotElasticCompute.java
License:BSD License
/** delete AMI image and related EBS snapshots */ public void imageDelete(final String imageId) throws Exception { final Image image = findImage(imageId); if (image == null) { logger.info("missing imageId = " + imageId); return;// w w w .ja v a 2s .co m } else { logger.info("present imageId = " + imageId); } imageUnregister(imageId); for (final BlockDeviceMapping blockDevice : image.getBlockDeviceMappings()) { final EbsBlockDevice elasticDevice = blockDevice.getEbs(); if (elasticDevice == null) { continue; } final String snapshotId = elasticDevice.getSnapshotId(); if (snapshotId == null) { continue; } snapshotDelete(snapshotId); } logger.info("removed imageId = " + imageId); }
From source file:com.carrotgarden.maven.aws.ecc.ElastiCompImageCreate.java
License:BSD License
@Override public void execute() throws MojoFailureException { try {// w ww . j a va 2 s.co m getLog().info("image create init [" + imageName() + "]"); final CarrotElasticCompute compute = newElasticCompute(); final Image image = compute.imageCreate( // imageInstanceId(), // imageName(), // imageDescription // ); final ImageState state = ImageState.fromValue(image.getState()); switch (state) { case AVAILABLE: break; default: throw new IllegalStateException("image create failed : \n" + image); } final String imageId = image.getImageId(); /** publish result */ project().getProperties().put(imageResultProperty, image); project().getProperties().put(imageIdResultProperty, imageId); /** tag image */ compute.tagCreate(imageId, amazonTagName(), imageName()); /** tag image devices */ for (final BlockDeviceMapping blockDevice : image.getBlockDeviceMappings()) { final EbsBlockDevice elasticDevice = blockDevice.getEbs(); if (elasticDevice == null) { continue; } final String snapshotId = elasticDevice.getSnapshotId(); if (snapshotId == null) { continue; } compute.tagCreate(snapshotId, amazonTagName(), imageName()); } getLog().info("image create image=\n" + image); getLog().info("image create done [" + imageName() + "]"); } catch (final Exception e) { throw new MojoFailureException("bada-boom", e); } }
From source file:com.netflix.simianarmy.aws.janitor.crawler.EBSSnapshotJanitorCrawler.java
License:Apache License
private void refreshSnapshotToAMIs() { snapshotToAMIs.clear();//from w w w .j ava2 s .c o m for (Image image : getAWSClient().describeImages()) { for (BlockDeviceMapping bdm : image.getBlockDeviceMappings()) { EbsBlockDevice ebd = bdm.getEbs(); if (ebd != null && ebd.getSnapshotId() != null) { LOGGER.debug(String.format("Snapshot %s is used to generate AMI %s", ebd.getSnapshotId(), image.getImageId())); Collection<String> amis = snapshotToAMIs.get(ebd.getSnapshotId()); if (amis == null) { amis = new ArrayList<String>(); snapshotToAMIs.put(ebd.getSnapshotId(), amis); } amis.add(image.getImageId()); } } } }
From source file:org.xmlsh.aws.util.AWSEC2Command.java
License:BSD License
private void writeBlockDeviceMapping(BlockDeviceMapping device) throws XMLStreamException { startElement("device"); attribute("name", device.getDeviceName()); EbsBlockDevice ebs = device.getEbs(); if (ebs != null) { attribute("shapshot-id", ebs.getSnapshotId()); attribute("delete-on-termination", ebs.getDeleteOnTermination()); attribute("volume-size", ebs.getVolumeSize()); attribute("volume-type", ebs.getVolumeType()); attribute("encrypted", ebs.getEncrypted()); attribute("iops", ebs.getIops()); }// www.j a v a 2s .c om endElement(); }