Package org.jclouds.openstack.cinder.v1.domain

Examples of org.jclouds.openstack.cinder.v1.domain.Volume$ConcreteBuilder


      this.client = client;
   }

   public boolean apply(Attachment attachment) {
      logger.trace("looking for volume %s", attachment.getVolumeId());
      Volume volume = Iterables.getOnlyElement(client.describeVolumesInRegion(attachment
              .getRegion(), attachment.getVolumeId()));

      /*If attachment size is 0 volume is detached for sure.*/
      if (volume.getAttachments().isEmpty()) {
         return true;
      }

      /* But if attachment size is > 0, then the attachment could be in any state.
         * So we need to check if the status is DETACHED (return true) or not (return false).
         */
      Attachment lastAttachment = getLast(volume.getAttachments());
      logger.trace("%s: looking for status %s: currently: %s", lastAttachment,
              Attachment.Status.DETACHED, lastAttachment.getStatus());
      return lastAttachment.getStatus() == Attachment.Status.DETACHED;
   }
View Full Code Here


   void testDescribeVolumes() {
      String region = defaultRegion;
      SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
      assertNotNull(allResults);
      assertFalse(allResults.isEmpty());
      Volume volume = allResults.last();
      SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegion(region, volume.getId()));
      assertNotNull(result);
      Volume compare = result.last();
      assertEquals(compare, volume);
   }
View Full Code Here

   void testDescribeVolumesWithFilter() {
      String region = defaultRegion;
      SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
      assertNotNull(allResults);
      assertFalse(allResults.isEmpty());
      Volume volume = allResults.last();
      SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegionWithFilter(region,
              ImmutableMultimap.<String, String>builder()
                      .put("volume-id", volume.getId()).build()));
      assertNotNull(result);
      Volume compare = result.last();
      assertEquals(compare, volume);
   }
View Full Code Here

   void testDescribeVolumesWithInvalidFilter() {
      String region = defaultRegion;
      SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
      assertNotNull(allResults);
      assertFalse(allResults.isEmpty());
      Volume volume = allResults.last();
      SortedSet<Volume> result = Sets.newTreeSet(client.describeVolumesInRegionWithFilter(region,
              ImmutableMultimap.<String, String>builder()
                      .put("invalid-filter", volume.getId()).build()));
   }
View Full Code Here

                      .put("invalid-filter", volume.getId()).build()));
   }

   @Test
   void testCreateVolumeInAvailabilityZone() {
      Volume expected = client.createVolumeInAvailabilityZone(defaultZone,
              withSize(1));
      assertNotNull(expected);
      assertEquals(expected.getAvailabilityZone(), defaultZone);
      this.volumeId = expected.getId();

      Set<Volume> result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, expected.getId()));
      assertNotNull(result);
      assertEquals(result.size(), 1);
      Volume volume = result.iterator().next();
      assertEquals(volume.getId(), expected.getId());
      assertEquals(volume.getVolumeType(), expected.getVolumeType());
   }
View Full Code Here

      this.snapshot = result;
   }

   @Test(dependsOnMethods = "testCreateSnapshotInRegion")
   void testCreateVolumeFromSnapshotInAvailabilityZone() {
      Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, snapshot.getId());
      assertNotNull(volume);

      Predicate<Volume> availabile = retry(new VolumeAvailable(client), 600, 10, SECONDS);
      assert availabile.apply(volume);

      Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
      assertEquals(volume.getId(), result.getId());
      assertEquals(volume.getSnapshotId(), snapshot.getId());
      assertEquals(volume.getAvailabilityZone(), defaultZone);
      assertEquals(result.getStatus(), Volume.Status.AVAILABLE);

      client.deleteVolumeInRegion(snapshot.getRegion(), result.getId());
   }
View Full Code Here

      client.deleteVolumeInRegion(snapshot.getRegion(), result.getId());
   }

   @Test(dependsOnMethods = "testCreateVolumeFromSnapshotInAvailabilityZone")
   void testCreateVolumeFromSnapshotInAvailabilityZoneWithOptions() {
      Volume volume = client.createVolumeInAvailabilityZone(defaultZone,
              fromSnapshotId(snapshot.getId()));
      assertNotNull(volume);

      Predicate<Volume> availabile = retry(new VolumeAvailable(client), 600, 10, SECONDS);
      assert availabile.apply(volume);

      Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
      assertEquals(volume.getId(), result.getId());
      assertEquals(volume.getSnapshotId(), snapshot.getId());
      assertEquals(volume.getAvailabilityZone(), defaultZone);
      assertEquals(result.getStatus(), Volume.Status.AVAILABLE);

      client.deleteVolumeInRegion(snapshot.getRegion(), result.getId());
   }
View Full Code Here

      client.deleteVolumeInRegion(snapshot.getRegion(), result.getId());
   }

   @Test(dependsOnMethods = "testCreateVolumeFromSnapshotInAvailabilityZoneWithOptions")
   void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() {
      Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, 2, snapshot.getId());
      assertNotNull(volume);

      Predicate<Volume> availabile = retry(new VolumeAvailable(client), 600, 10, SECONDS);
      assert availabile.apply(volume);

      Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId()));
      assertEquals(volume.getId(), result.getId());
      assertEquals(volume.getSnapshotId(), snapshot.getId());
      assertEquals(volume.getAvailabilityZone(), defaultZone);
      assertEquals(volume.getSize(), 2);
      assertEquals(result.getStatus(), Volume.Status.AVAILABLE);

      client.deleteVolumeInRegion(snapshot.getRegion(), result.getId());
   }
View Full Code Here

      }
      currentText.setLength(0);
   }

   private Volume newVolume() {
      Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime,
              volumeType, iops, encrypted, attachments);
      id = null;
      size = 0;
      snapshotId = null;
      availabilityZone = null;
View Full Code Here

      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
              .payload(payloadFromResourceWithContentType("/describe_volumes_single.xml", "text/xml")).build();

      EC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, describeRegionsResponse, filterVolumes, filterResponse);

      Volume volume = getOnlyElement(apiWhenExist.getElasticBlockStoreApi().get().describeVolumesInRegionWithFilter("us-east-1",
              ImmutableMultimap.<String, String>builder()
                      .put("snapshot-id", "snap-536d1b3a")
                      .build()));

      assertEquals(volume.getId(), "vol-4282672b");
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.cinder.v1.domain.Volume$ConcreteBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.