Search in sources :

Example 1 with Volume

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

the class CreateSnapshot 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) {
    CreateSnapshot createSnapshot = new CreateSnapshot();
    try {
        createSnapshot.init(args);
        Volume volume = createSnapshot.getVolume();
        createSnapshot.createSnapshot(volume);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        createSnapshot.close();
    }
}
Also used : Volume(org.jclouds.openstack.cinder.v1.domain.Volume) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with Volume

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

the class CreateVolumeAndAttach method createVolume.

private Volume createVolume() throws TimeoutException {
    CreateVolumeOptions options = CreateVolumeOptions.Builder.name(Constants.NAME).metadata(ImmutableMap.<String, String>of("key1", "value1"));
    System.out.println("Create Volume");
    // 100 GB is the minimum volume size on the Rackspace Cloud
    Volume volume = volumeApi.create(100, options);
    // /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
    if (!VolumePredicates.awaitAvailable(volumeApi).apply(volume)) {
        throw new TimeoutException("Timeout on volume: " + volume);
    }
    System.out.println("  " + volume);
    return volume;
}
Also used : Volume(org.jclouds.openstack.cinder.v1.domain.Volume) CreateVolumeOptions(org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with Volume

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

the class DeleteVolume 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) {
    DeleteVolume deleteVolume = new DeleteVolume();
    try {
        deleteVolume.init(args);
        Volume volume = deleteVolume.getVolume();
        deleteVolume.deleteVolume(volume);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        deleteVolume.close();
    }
}
Also used : Volume(org.jclouds.openstack.cinder.v1.domain.Volume) TimeoutException(java.util.concurrent.TimeoutException)

Example 4 with Volume

use of org.jclouds.openstack.cinder.v1.domain.Volume 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)

Example 5 with Volume

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

the class CreateVolumeAndAttach 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) {
    CreateVolumeAndAttach createVolumeAndAttach = new CreateVolumeAndAttach();
    try {
        createVolumeAndAttach.init(args);
        NodeMetadata node = createVolumeAndAttach.createServer();
        Volume volume = createVolumeAndAttach.createVolume();
        createVolumeAndAttach.attachVolume(volume, node);
        createVolumeAndAttach.mountVolume(node);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        createVolumeAndAttach.close();
    }
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) Volume(org.jclouds.openstack.cinder.v1.domain.Volume) TimeoutException(java.util.concurrent.TimeoutException) RunNodesException(org.jclouds.compute.RunNodesException)

Aggregations

TimeoutException (java.util.concurrent.TimeoutException)5 Volume (org.jclouds.openstack.cinder.v1.domain.Volume)4 RunNodesException (org.jclouds.compute.RunNodesException)1 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)1 Snapshot (org.jclouds.openstack.cinder.v1.domain.Snapshot)1 CreateSnapshotOptions (org.jclouds.openstack.cinder.v1.options.CreateSnapshotOptions)1 CreateVolumeOptions (org.jclouds.openstack.cinder.v1.options.CreateVolumeOptions)1