Package org.jclouds.openstack.nova.v2_0.domain

Examples of org.jclouds.openstack.nova.v2_0.domain.Volume


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

      Set<Volume> expected = Sets.newLinkedHashSet();
      expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, "us-east-1a",
               Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"),
               "standard", 0, false, Sets.<Attachment> newLinkedHashSet()));
      expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a",
              "us-east-1a", Volume.Status.IN_USE, dateService
              .iso8601DateParse("2008-05-07T11:51:50.000Z"),
              "standard", 0, false,
              Sets.<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509",
                      "/dev/sdh", Attachment.Status.ATTACHED, dateService
View Full Code Here


         }

      });

      // create volume only to make a snapshot
      Volume volume = ebsClient.createVolumeInAvailabilityZone(zone.getId(), 4);
      // Sleep for 5 seconds to make sure the volume creation finishes.
      Thread.sleep(5000);

      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

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

      Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null,
              "us-east-1a", Volume.Status.CREATING, dateService
              .iso8601DateParse("2009-12-28T05:42:53.000Z"), "standard", 0, false,
              Sets.<Attachment> newLinkedHashSet());

      CreateVolumeResponseHandler handler = injector.getInstance(CreateVolumeResponseHandler.class);
      addDefaultRegionToHandler(handler);
      Volume result = factory.create(handler).parse(is);

      assertEquals(result, expected);
   }
View Full Code Here

      return overrides;
   }

   @Test
   void testCreateVolumeInAvailabilityZoneWithVolumeType() {
      Volume expected = client.createVolumeInAvailabilityZone(defaultZone,
              volumeType("gp2"), withSize(1));
      assertNotNull(expected);
      assertEquals(expected.getAvailabilityZone(), defaultZone);
      assertEquals(expected.getVolumeType(), "gp2");

      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());

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

   public void testListVolumes() {
      Set<? extends Volume> volumes = volumeApi.list().toSet();
      assertNotNull(volumes);
      boolean foundIt = false;
      for (Volume vol : volumes) {
         Volume details = volumeApi.get(vol.getId());
         assertNotNull(details);
         if (Objects.equal(details.getId(), testVolume.getId())) {
            foundIt = true;
         }
      }
      assertTrue(foundIt, "Failed to find the volume we created in list() response");
   }
View Full Code Here

   public void testListVolumesInDetail() {
      Set<? extends Volume> volumes = volumeApi.listInDetail().toSet();
      assertNotNull(volumes);
      boolean foundIt = false;
      for (Volume vol : volumes) {
         Volume details = volumeApi.get(vol.getId());
         assertNotNull(details);
         assertNotNull(details.getId());
         assertNotNull(details.getCreated());
         assertTrue(details.getSize() > -1);

         assertEquals(details.getId(), vol.getId());
         assertEquals(details.getSize(), vol.getSize());
         assertEquals(details.getName(), vol.getName());
         assertEquals(details.getDescription(), vol.getDescription());
         assertEquals(details.getCreated(), vol.getCreated());
         if (Objects.equal(details.getId(), testVolume.getId())) {
            foundIt = true;
         }
      }
      assertTrue(foundIt, "Failed to find the volume we previously created in listInDetail() response");
   }
View Full Code Here

      ).getVolumeApiForZone("RegionOne");

      CreateVolumeOptions options = CreateVolumeOptions.Builder
            .name("jclouds-test-volume")
            .description("description of test volume");
      Volume volume = api.create(1, options);
      assertEquals(volume, testVolumeCreate());
   }
View Full Code Here

            responseWithKeystoneAccess,
            authenticatedGET().endpoint(endpoint).build(),
            HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_get.json")).build()
      ).getVolumeApiForZone("RegionOne");

      Volume volume = api.get("60761c60-0f56-4499-b522-ff13e120af10");
      assertEquals(volume, testVolume());
      // double-check equals()
      assertEquals(volume.getName(), "test");
      assertEquals(volume.getZone(), "nova");
      assertEquals(volume.getStatus(), Volume.Status.IN_USE);
      assertEquals(volume.getDescription(), "This is a test volume");
      assertEquals(Iterables.getOnlyElement(volume.getAttachments()), testAttachment());
   }
View Full Code Here

        
         if (status.equals(volume.getStatus())) {
            return true;
         }
         else {
            Volume volumeUpdated = volumeApi.get(volume.getId());
            checkNotNull(volumeUpdated, "Volume %s not found.", volume.getId());
           
            return status.equals(volumeUpdated.getStatus());
         }
      }
View Full Code Here

        
         if (status.equals(volume.getStatus())) {
            return true;
         }
         else {
            Volume volumeUpdated = volumeApi.get(volume.getId());
            checkNotNull(volumeUpdated, "Volume %s not found.", volume.getId());
           
            return status.equals(volumeUpdated.getStatus());
         }
      }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.Volume

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.