Example usage for com.amazonaws.services.ec2.model DeleteSnapshotRequest DeleteSnapshotRequest

List of usage examples for com.amazonaws.services.ec2.model DeleteSnapshotRequest DeleteSnapshotRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DeleteSnapshotRequest DeleteSnapshotRequest.

Prototype

public DeleteSnapshotRequest() 

Source Link

Document

Default constructor for DeleteSnapshotRequest object.

Usage

From source file:com.axemblr.yab.YaB.java

License:Apache License

/**
 * De-register AMI and delete related snapshot
 *///from   www  .  j a v  a2  s.c  om
public void deleteImageAndRelatedSnapshot(String imageId) {
    client.deregisterImage(new DeregisterImageRequest().withImageId(imageId));

    final String pattern = "for " + imageId + " from vol-";
    DescribeSnapshotsResult result = client.describeSnapshots(new DescribeSnapshotsRequest());

    for (Snapshot candidate : result.getSnapshots()) {
        if (candidate.getDescription().contains(pattern)) {
            client.deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(candidate.getSnapshotId()));
        }
    }
}

From source file:com.carrotgarden.maven.aws.ecc.CarrotElasticCompute.java

License:BSD License

/** 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);/*from  w w w.  j ava 2  s  . c o m*/

    amazonClient.deleteSnapshot(request);

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

}

From source file:com.netflix.simianarmy.client.aws.AWSClient.java

License:Apache License

/** {@inheritDoc} */
@Override// ww w  . j  ava2 s . c om
public void deleteSnapshot(String snapshotId) {
    Validate.notEmpty(snapshotId);
    LOGGER.info(String.format("Deleting snapshot %s in region %s.", snapshotId, region));
    AmazonEC2 ec2Client = ec2Client();
    DeleteSnapshotRequest request = new DeleteSnapshotRequest().withSnapshotId(snapshotId);
    ec2Client.deleteSnapshot(request);
}

From source file:com.netflix.spinnaker.clouddriver.aws.deploy.ops.DeleteAmazonSnapshotAtomicOperation.java

License:Apache License

@Override
public Void operate(List priorOutputs) {
    getTask().updateStatus(BASE_PHASE,//www . j a v a2s  . c  o  m
            String.format("Initializing Delete Snapshot operation for %s", description));
    try {
        amazonClientProvider.getAmazonEC2(description.getCredentials(), description.getRegion())
                .deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(description.getSnapshotId()));
    } catch (Exception e) {
        registry.counter(deleteSnapshotTaskId.withTag("success", false)).increment();
        log.error(String.format("Failed to delete snapshotId %s", description.getSnapshotId()), e);
        throw e;
    }
    registry.counter(deleteSnapshotTaskId.withTag("success", true)).increment();

    getTask().updateStatus(BASE_PHASE,
            String.format("Deleted Snapshot %s in %s", description.getSnapshotId(), description.getRegion()));
    return null;
}

From source file:com.pearson.eidetic.driver.threads.EideticSubThreadMethods.java

public void deleteSnapshot(AmazonEC2Client ec2Client, Snapshot snapshot, Integer numRetries,
        Integer maxApiRequestsPerSecond, String uniqueAwsAccountIdentifier) {
    String snapshotId = snapshot.getSnapshotId();
    DeleteSnapshotRequest deleteSnapshotRequest = new DeleteSnapshotRequest().withSnapshotId(snapshotId);
    EC2ClientMethods.deleteSnapshot(ec2Client, deleteSnapshotRequest, numRetries, maxApiRequestsPerSecond,
            uniqueAwsAccountIdentifier);
}

From source file:com.zotoh.cloudapi.aws.EBSSnapshot.java

License:Open Source License

@Override
public void remove(String snap) throws InternalException, CloudException {
    tstEStrArg("snapshot-id", snap);
    try {/*ww  w  . j ava  2 s  . com*/
        _svc.getCloud().getEC2().deleteSnapshot(new DeleteSnapshotRequest().withSnapshotId(snap));
    } catch (AmazonServiceException e) {
        if (!testSafeNonExistError(e, "InvalidSnapshot.NotFound")) {
            throw new CloudException(e);
        }
    }
}