List of usage examples for com.amazonaws.services.ec2.model Snapshot getState
public String getState()
The snapshot state.
From source file:virtualIT.java
License:Open Source License
private void createExtraSnapShot(int userId) throws Exception { /****************************************** * Creating Snap Shots before detaching volume *//*from w w w. j a v a 2 s .c o m*/ System.out.println("Creating Snap Shots before detaching volume\n"); String volumeId = mapUserExtraVolu.get(userId); CreateSnapshotResult snapRes = ec2 .createSnapshot(new CreateSnapshotRequest(volumeId, "Test snapshot" + userId)); Snapshot snap = snapRes.getSnapshot(); System.out.println("Snapshot request sent."); System.out.println("Waiting for snapshot to be created"); String snapState = snap.getState(); System.out.println("snapState is " + snapState); System.out.print("Waiting for snapshot to be created"); // Wait for the snapshot to be created while (snapState.equals("pending")) { Thread.sleep(500); System.out.print("."); DescribeSnapshotsResult describeSnapRes = ec2 .describeSnapshots(new DescribeSnapshotsRequest().withSnapshotIds(snap.getSnapshotId())); snapState = describeSnapRes.getSnapshots().get(0).getState(); } mapUserExtraSnap.put(userId, snap.getSnapshotId()); System.out.println("\nSnap shot Done."); return; }
From source file:virtualIT.java
License:Open Source License
private void createRootSnapShot(int userId) throws Exception { String volumeId = mapUserRootVol.get(userId); CreateSnapshotResult snapRes = ec2// ww w .j a va 2s . co m .createSnapshot(new CreateSnapshotRequest(volumeId, "Test snapshot" + userId)); Snapshot snap = snapRes.getSnapshot(); System.out.println("Snapshot request sent."); System.out.println("Waiting for snapshot to be created"); String snapState = snap.getState(); System.out.println("snapState is " + snapState); System.out.print("Waiting for snapshot to be created"); // Wait for the snapshot to be created while (snapState.equals("pending")) { Thread.sleep(500); System.out.print("."); DescribeSnapshotsResult describeSnapRes = ec2 .describeSnapshots(new DescribeSnapshotsRequest().withSnapshotIds(snap.getSnapshotId())); snapState = describeSnapRes.getSnapshots().get(0).getState(); } mapUserRootSnap.put(userId, snap.getSnapshotId()); System.out.println("\nSnap shot Done."); return; }
From source file:com.netflix.simianarmy.aws.janitor.crawler.EBSSnapshotJanitorCrawler.java
License:Apache License
private List<Resource> getSnapshotResources(String... snapshotIds) { refreshSnapshotToAMIs();//from ww w . j a va 2 s. com List<Resource> resources = new LinkedList<Resource>(); AWSClient awsClient = getAWSClient(); for (Snapshot snapshot : awsClient.describeSnapshots(snapshotIds)) { Resource snapshotResource = new AWSResource().withId(snapshot.getSnapshotId()) .withRegion(getAWSClient().region()).withResourceType(AWSResourceType.EBS_SNAPSHOT) .withLaunchTime(snapshot.getStartTime()).withDescription(snapshot.getDescription()); for (Tag tag : snapshot.getTags()) { LOGGER.debug(String.format("Adding tag %s = %s to resource %s", tag.getKey(), tag.getValue(), snapshotResource.getId())); snapshotResource.setTag(tag.getKey(), tag.getValue()); } snapshotResource.setOwnerEmail(getOwnerEmailForResource(snapshotResource)); ((AWSResource) snapshotResource).setAWSResourceState(snapshot.getState()); Collection<String> amis = snapshotToAMIs.get(snapshotResource.getId()); if (amis != null) { snapshotResource.setAdditionalField(SNAPSHOT_FIELD_AMIS, StringUtils.join(amis, ",")); } resources.add(snapshotResource); } return resources; }