/** * Creates a snapshot and return the snapshot id. */ public static String createSnapshot(VerificationHost host, AmazonEC2Client client, String volumeId) { CreateSnapshotRequest req = new CreateSnapshotRequest() .withVolumeId(volumeId); CreateSnapshotResult res = client.createSnapshot(req); String snapshotId = res.getSnapshot().getSnapshotId(); Filter filter = new Filter().withName(SNAPSHOT_ID_ATTRIBUTE).withValues(snapshotId); DescribeSnapshotsRequest snapshotsRequest = new DescribeSnapshotsRequest() .withSnapshotIds(snapshotId) .withFilters(filter); host.waitFor("Timeout waiting for creating snapshot", () -> { DescribeSnapshotsResult snapshotsResult = client.describeSnapshots(snapshotsRequest); String state = snapshotsResult.getSnapshots().get(0).getState(); if (state.equalsIgnoreCase(SNAPSHOT_STATUS_COMPLETE)) { return true; } return false; }); return snapshotId; }
@Override public Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor) { ActionResult result = resource.performAction("CreateSnapshot", request, extractor); if (result == null) return null; return new SnapshotImpl(result.getResource()); }
@Override public Snapshot createSnapshot(String description, ResultCapture<CreateSnapshotResult> extractor) { CreateSnapshotRequest request = new CreateSnapshotRequest() .withDescription(description); return createSnapshot(request, extractor); }
@Override public Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor) { ActionResult result = service.performAction("CreateSnapshot", request, extractor); if (result == null) return null; return new SnapshotImpl(result.getResource()); }
@Override public Snapshot createSnapshot(String description, String volumeId, ResultCapture<CreateSnapshotResult> extractor) { CreateSnapshotRequest request = new CreateSnapshotRequest() .withDescription(description) .withVolumeId(volumeId); return createSnapshot(request, extractor); }
private Optional<String> prepareSnapshotForEncryptionBecauseThatDoesNotExist(AuthenticatedContext ac, Group group, AwsInstanceView instanceView, AmazonEC2Client client) { CreateVolumeResult volumeResult = client.createVolume(prepareCreateVolumeRequest(ac, instanceView, client)); checkEbsVolumeStatus(ac, group, client, volumeResult); CreateSnapshotResult snapshotResult = client.createSnapshot(prepareCreateSnapshotRequest(volumeResult)); checkSnapshotReadiness(ac, client, snapshotResult); client.createTags(prepareCreateTagsRequest(instanceView, snapshotResult)); return Optional.of(snapshotResult.getSnapshot().getSnapshotId()); }
private void checkSnapshotReadiness(AuthenticatedContext ac, AmazonEC2Client client, CreateSnapshotResult snapshotResult) { PollTask<Boolean> snapshotReadyChecker = awsPollTaskFactory .newCreateSnapshotReadyStatusCheckerTask(ac, snapshotResult.getSnapshot().getSnapshotId(), client); try { Boolean statePollerResult = snapshotReadyChecker.call(); if (!snapshotReadyChecker.completed(statePollerResult)) { syncPollingScheduler.schedule(snapshotReadyChecker); } } catch (Exception e) { throw new CloudConnectorException(e.getMessage(), e); } }
@Override public CreateSnapshotResult createSnapshot(CreateSnapshotRequest createSnapshotRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public Snapshot createSnapshot(String description) { return createSnapshot(description, (ResultCapture<CreateSnapshotResult>)null); }
@Override public Snapshot createSnapshot(String description, String volumeId) { return createSnapshot(description, volumeId, (ResultCapture<CreateSnapshotResult>)null); }
private CreateTagsRequest prepareCreateTagsRequest(AwsInstanceView awsInstanceView, CreateSnapshotResult snapshotResult) { return new CreateTagsRequest().withTags(prepareTagList(awsInstanceView)).withResources(snapshotResult.getSnapshot().getSnapshotId()); }
/** * Performs the <code>CreateSnapshot</code> action and use a ResultCapture * to retrieve the low-level client response. * * <p> * * @return The <code>Snapshot</code> resource object associated with the * result of this action. * @see CreateSnapshotRequest */ com.amazonaws.resources.ec2.Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor);
/** * The convenient method form for the <code>CreateSnapshot</code> action. * * @see #createSnapshot(CreateSnapshotRequest, ResultCapture) */ com.amazonaws.resources.ec2.Snapshot createSnapshot(String description, String volumeId, ResultCapture<CreateSnapshotResult> extractor);
/** * Performs the <code>CreateSnapshot</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>Volume</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>VolumeId</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @return The <code>Snapshot</code> resource object associated with the * result of this action. * @see CreateSnapshotRequest */ Snapshot createSnapshot(CreateSnapshotRequest request, ResultCapture<CreateSnapshotResult> extractor);
/** * The convenient method form for the <code>CreateSnapshot</code> action. * * @see #createSnapshot(CreateSnapshotRequest, ResultCapture) */ Snapshot createSnapshot(String description, ResultCapture<CreateSnapshotResult> extractor);