Java 类com.amazonaws.services.ec2.model.DeleteSnapshotRequest 实例源码

项目:cmn-project    文件:EC2.java   
public void deleteImage(Image image) {
    String imageId = image.getImageId();
    logger.info("delete image, imageId={}", imageId);
    ec2.deregisterImage(new DeregisterImageRequest(imageId));

    // our image always uses EBS as first and only drive
    List<BlockDeviceMapping> mappings = image.getBlockDeviceMappings();
    if (!mappings.isEmpty()) {
        EbsBlockDevice ebs = mappings.get(0).getEbs();
        if (ebs != null) {
            String snapshotId = ebs.getSnapshotId();
            logger.info("delete snapshot, snapshotId={}", snapshotId);
            ec2.deleteSnapshot(new DeleteSnapshotRequest(snapshotId));
        }
    }
}
项目:aws-auto-operations-using-lambda    文件:ImageStateCheckAndPargeFunction.java   
private void pargeImages(AmazonEC2 ec2, Image image) {
    String imageId = image.getImageId();
    ec2.deregisterImage(new DeregisterImageRequest(imageId));
    for (BlockDeviceMapping block : image.getBlockDeviceMappings()) {
        String snapshotId = block.getEbs().getSnapshotId();
        ec2.deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(snapshotId));
    }
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public void deleteSnapshot(DeleteSnapshotRequest deleteSnapshotRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:aws-auto-operations-using-lambda    文件:EBSSnapshotFunction.java   
void pargeSnapshot(AmazonEC2 ec2, String snapshotId) {
    DeleteSnapshotRequest request = new DeleteSnapshotRequest(snapshotId);
    ec2.deleteSnapshot(request);
}
项目:aws-auto-operations-using-lambda    文件:DeregisterImageFunction.java   
private void pargeSnapshot(AmazonEC2 ec2, String snapshotId, Context context) {

        DeleteSnapshotRequest request = new DeleteSnapshotRequest(snapshotId);
        ec2.deleteSnapshot(request);
        context.getLogger().log("Parge Snapshot. snapshotId[" + snapshotId + "]");
    }
项目:aws-auto-operations-using-lambda    文件:EBSCopySnapshotFunction.java   
void pargeSnapshot(AmazonEC2 ec2, String snapshotId) {
    DeleteSnapshotRequest request = new DeleteSnapshotRequest(snapshotId);
    ec2.deleteSnapshot(request);
}
项目:photon-model    文件:TestAWSSetupUtils.java   
/**
 * Delete a Snapshot
 */
public static void deleteSnapshot(AmazonEC2AsyncClient client, String snapshotId) {
    client.deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(snapshotId));
}
项目:data-lifecycle-service-broker    文件:AWSHelper.java   
/**
 * Find the snap & volumes associated with the AMI we used and delete it.
 * AWS doesn't help us out much and the only relationship (as of 2/14/2015)
 * we can leverage is the description field.
 * 
 * @param ami
 *            to find associated snaps for
 * @throws ServiceBrokerExceptions
 */
public void deleteStorageArtifacts(String ami)
        throws ServiceBrokerException {

    DescribeSnapshotsResult desc = ec2Client.describeSnapshots();
    if (null == desc.getSnapshots()) {
        return;
    }
    List<Snapshot> snapshots = desc.getSnapshots();

    // The only way I can find to track the snaps that get created (but not
    // cleaned up) as part of the ami creation is by the description. This
    // code is brittle and will probably fail in unexpected and glamorous
    // ways.
    String amiDesc = "Created by CreateImage(" + sourceInstanceId
            + ") for " + ami + " from vol";

    // Would be nice if the aws client return optionals...
    List<Snapshot> matching = snapshots.stream()
            .filter(s -> safeContains(s::getDescription, amiDesc))
            .collect(Collectors.toList());

    switch (matching.size()) {
    case 0:
        // Should this throw? Might have been manually cleaned up...but it
        // may orphan the volume. It's done this way to allow people to
        // create their own instances in AWS and not jack them up by
        // deleting the volume
        log.error("No snapshots found for AMI " + ami);
        break;
    case 1:
        String snap = matching.get(0).getSnapshotId();
        log.info("Deleting snapshot " + snap);
        ec2Client.deleteSnapshot(new DeleteSnapshotRequest()
                .withSnapshotId(snap));

        deleteVolumeForSnap(snap);
        break;
    default:
        throw new ServiceBrokerException(
                "Found too many snapshots for AMI " + ami);
    }
}
项目:aws-sdk-java-resources    文件:SnapshotImpl.java   
@Override
public void delete(DeleteSnapshotRequest request) {
    delete(request, null);
}
项目:aws-sdk-java-resources    文件:SnapshotImpl.java   
@Override
public void delete(DeleteSnapshotRequest request, ResultCapture<Void>
        extractor) {

    resource.performAction("Delete", request, extractor);
}
项目:aws-sdk-java-resources    文件:SnapshotImpl.java   
@Override
public void delete(ResultCapture<Void> extractor) {
    DeleteSnapshotRequest request = new DeleteSnapshotRequest();
    delete(request, extractor);
}
项目:jwrapper-maven-plugin    文件:CarrotElasticCompute.java   
/** unregister EBS snapshot; will fail if snapshot still in use */
public void snapshotDelete(final String snapshotId) throws Exception {

    final DeleteSnapshotRequest request = new DeleteSnapshotRequest();
    request.setSnapshotId(snapshotId);

    amazonClient.deleteSnapshot(request);

    logger.info("removed snapshotId = " + snapshotId);

}
项目:aws-sdk-java-resources    文件:Snapshot.java   
/**
 * Performs the <code>Delete</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Snapshot</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>SnapshotId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSnapshotRequest
 */
void delete(DeleteSnapshotRequest request);
项目:aws-sdk-java-resources    文件:Snapshot.java   
/**
 * Performs the <code>Delete</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Snapshot</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>SnapshotId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSnapshotRequest
 */
void delete(DeleteSnapshotRequest request, ResultCapture<Void> extractor);