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

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


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

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

      Snapshot snapshot = getOnlyElement(apiWhenExist.getElasticBlockStoreApi().get().describeSnapshotsInRegionWithFilter("us-east-1",
              ImmutableMultimap.<String, String>builder()
                      .put("volume-id", "4d826724")
                      .build()));

      assertEquals(snapshot.getId(), "snap-78a54011");
   }
View Full Code Here


      assertEquals(volume.getId(), expected.getId());
   }

   @Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone")
   void testCreateSnapshotInRegion() {
      Snapshot snapshot = client.createSnapshotInRegion(defaultRegion, volumeId);
      Predicate<Snapshot> snapshotted = retry(new SnapshotCompleted(client), 600, 10, SECONDS);
      assert snapshotted.apply(snapshot);

      Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegion(snapshot.getRegion(),
            snapshotIds(snapshot.getId())));

      assertEquals(result.getProgress(), 100);
      this.snapshot = result;
   }
View Full Code Here

   void testDescribeSnapshots() {
      String region = defaultRegion;
      SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
      assertNotNull(allResults);
      if (!allResults.isEmpty()) {
         Snapshot snapshot = allResults.last();
         Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegion(region,
                 snapshotIds(snapshot.getId())));
         assertNotNull(result);
         assertEquals(result, snapshot);
      }
   }
View Full Code Here

   void testDescribeSnapshotsWithFilter() {
      String region = defaultRegion;
      SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
      assertNotNull(allResults);
      if (!allResults.isEmpty()) {
         Snapshot snapshot = allResults.last();
         Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegionWithFilter(region,
                 ImmutableMultimap.<String, String>builder()
                         .put("snapshot-id", snapshot.getId()).build()));
         assertNotNull(result);
         assertEquals(result, snapshot);
      }
View Full Code Here

   void testDescribeSnapshotsWithFilterInvalid() {
      String region = defaultRegion;
      SortedSet<Snapshot> allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region));
      assertNotNull(allResults);
      if (!allResults.isEmpty()) {
         Snapshot snapshot = allResults.last();
         Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegionWithFilter(region,
                 ImmutableMultimap.<String, String>builder()
                         .put("invalid-filter", snapshot.getId()).build()));
      }
   }
View Full Code Here

      assertEquals(filterResult.iterator().next().getId(), id1);
   }

   @Test
   public void testCreateAndListEBSBackedImage() throws Exception {
      Snapshot snapshot = createSnapshot();

      // List of images before...
      int sizeBefore = client.describeImagesInRegionWithFilter(regionId,
              ImmutableMultimap.<String, String>builder()
                      .put("name", ebsBackedImageName).build()).size();

      // Register a new image...
      ebsBackedImageId = client.registerUnixImageBackedByEbsInRegion(regionId, ebsBackedImageName, snapshot.getId(),
            addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian"));
      imagesToDeregister.add(ebsBackedImageId);
      final Image ebsBackedImage = getOnlyElement(client.describeImagesInRegion(regionId, imageIds(ebsBackedImageId)));
      assertEquals(ebsBackedImage.getName(), ebsBackedImageName);
      assertEquals(ebsBackedImage.getImageType(), ImageType.MACHINE);
      assertEquals(ebsBackedImage.getRootDeviceType(), RootDeviceType.EBS);
      assertEquals(ebsBackedImage.getRootDeviceName(), "/dev/sda1");
      assertEquals(ebsBackedImage.getDescription(), "adrian");
      assertEquals(
            ebsBackedImage.getEbsBlockDevices().entrySet(),
            ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), snapshot.getVolumeSize(), true),
                  "/dev/sda2", new Image.EbsBlockDevice(null, 1, false)).entrySet());

      // List of images after - should be one larger than before
      int after = client.describeImagesInRegionWithFilter(regionId,
              ImmutableMultimap.<String, String>builder()
View Full Code Here

         instance = getOnlyElement(concat(ec2Api.getInstanceApi().get().describeInstancesInRegion(regionId,
               instanceId)));
         BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1");
         assertNotNull(device, "device: /dev/sda1 not present on: " + instance);
         Snapshot snapshot = ec2Api.getElasticBlockStoreApi().get().createSnapshotInRegion(regionId,
               device.getVolumeId());
         snapshotsToDelete.add(snapshot.getId());
         return snapshot;
      } finally {
         if (instanceId != null)
            ec2Api.getInstanceApi().get().terminateInstancesInRegion(regionId, instanceId);
      }
View Full Code Here

   public Snapshot getResult() {
      String region = AWSUtils.findRegionInArgsOrNull(getRequest());
      if (region == null)
         region = defaultRegion.get();
      Snapshot snapshot = new Snapshot(region, id, volumeId, volumeSize, status, startTime,
               progress, ownerId, description, ownerAlias);
      this.id = null;
      this.volumeId = null;
      this.volumeSize = 0;
      this.status = null;
View Full Code Here

public class SnapshotHandlerTest extends BaseEC2HandlerTest {
   public void testApplyInputStream() {
      DateService dateService = injector.getInstance(DateService.class);
      InputStream is = getClass().getResourceAsStream("/created_snapshot.xml");

      Snapshot expected = new Snapshot(defaultRegion, "snap-78a54011", "vol-4d826724", 10,
               Snapshot.Status.PENDING, dateService.iso8601DateParse("2008-05-07T12:51:50.000Z"),
               60, "213457642086", "Daily Backup", null);

      SnapshotHandler handler = injector.getInstance(SnapshotHandler.class);
      addDefaultRegionToHandler(handler);
      Snapshot result = factory.create(handler).parse(is);
      assertEquals(result, expected);
   }
View Full Code Here

      });

      // create volume only to make a snapshot
      Volume volume = ebsClient.createVolumeInAvailabilityZone(zone.getId(), 4);
      Snapshot snapshot = ebsClient.createSnapshotInRegion(volume.getRegion(), volume.getId());
      ebsClient.deleteVolumeInRegion(volume.getRegion(), volume.getId());

      template.getOptions().as(EC2TemplateOptions.class)//
               // .unmapDeviceNamed("/dev/foo)
               .mapEphemeralDeviceToDeviceName("/dev/sdm", "ephemeral0")//
               .mapNewVolumeToDeviceName("/dev/sdn", volumeSize, true)//
               .mapEBSSnapshotToDeviceName("/dev/sdo", snapshot.getId(), volumeSize, true);

      try {
         NodeMetadata node = Iterables.getOnlyElement(client.createNodesInGroup(group, 1, template));

         // TODO figure out how to validate the ephemeral drive. perhaps with df -k?

         Map<String, BlockDevice> devices = instanceClient.getBlockDeviceMappingForInstanceInRegion(node.getLocation()
                  .getParent().getId(), node.getProviderId());

         BlockDevice device = devices.get("/dev/sdn");
         // check delete on termination
         assertTrue(device.isDeleteOnTermination());

         volume = Iterables.getOnlyElement(ebsClient.describeVolumesInRegion(node.getLocation().getParent().getId(),
                  device.getVolumeId()));
         // check volume size
         assertEquals(volumeSize, volume.getSize());

         device = devices.get("/dev/sdo");
         // check delete on termination
         assertTrue(device.isDeleteOnTermination());

         volume = Iterables.getOnlyElement(ebsClient.describeVolumesInRegion(node.getLocation().getParent().getId(),
                  device.getVolumeId()));
         // check volume size
         assertEquals(volumeSize, volume.getSize());
         // check volume's snapshot id
         assertEquals(snapshot.getId(), volume.getSnapshotId());

      } finally {
         client.destroyNodesMatching(NodePredicates.inGroup(group));
         ebsClient.deleteSnapshotInRegion(snapshot.getRegion(), snapshot.getId());
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.cinder.v1.domain.Snapshot$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.