Search in sources :

Example 1 with Snapshot

use of org.jclouds.openstack.cinder.v1.domain.Snapshot in project legacy-jclouds-examples by jclouds.

the class DeleteSnapshot method main.

/**
    * To get a username and API key see
    * http://www.jclouds.org/documentation/quickstart/rackspace/
    * 
    * The first argument (args[0]) must be your username The second argument
    * (args[1]) must be your API key
    */
public static void main(String[] args) {
    DeleteSnapshot deleteSnapshot = new DeleteSnapshot();
    try {
        deleteSnapshot.init(args);
        Snapshot snapshot = deleteSnapshot.getSnapshot();
        deleteSnapshot.deleteSnapshot(snapshot);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        deleteSnapshot.close();
    }
}
Also used : Snapshot(org.jclouds.openstack.cinder.v1.domain.Snapshot) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with Snapshot

use of org.jclouds.openstack.cinder.v1.domain.Snapshot in project legacy-jclouds-examples by jclouds.

the class CreateSnapshot method createSnapshot.

private void createSnapshot(Volume volume) throws TimeoutException {
    System.out.println("Create Snapshot");
    CreateSnapshotOptions options = CreateSnapshotOptions.Builder.name(Constants.NAME).description("Snapshot of " + volume.getId());
    Snapshot snapshot = snapshotApi.create(volume.getId(), options);
    // /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
    if (!SnapshotPredicates.awaitAvailable(snapshotApi).apply(snapshot)) {
        throw new TimeoutException("Timeout on volume: " + volume);
    }
    System.out.println("  " + snapshot);
}
Also used : Snapshot(org.jclouds.openstack.cinder.v1.domain.Snapshot) CreateSnapshotOptions(org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

TimeoutException (java.util.concurrent.TimeoutException)2 Snapshot (org.jclouds.openstack.cinder.v1.domain.Snapshot)2 CreateSnapshotOptions (org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions)1