Package org.jclouds.elasticstack.domain

Examples of org.jclouds.elasticstack.domain.DriveInfo


   @Override
   public NodeAndInitialCredentials<ServerInfo> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
      long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);

      logger.debug(">> creating boot drive bytes(%d)", bootSize);
      DriveInfo drive = client
            .createDrive(new Drive.Builder().name(template.getImage().getId()).size(bootSize).build());
      logger.debug("<< drive (%s)", drive);

      boolean success = driveNotClaimed.apply(drive);
      if (!success) {
         client.destroyDrive(drive.getUuid());
         throw new IllegalStateException(String.format("could not create drive %s in time!", drive));
      }

      logger.debug(">> imaging boot drive source(%s)", template.getImage().getId());
      client.imageDrive(template.getImage().getId(), drive.getUuid(), ImageConversionType.GUNZIP);
      boolean ready = driveNotClaimed.apply(drive);
      if (!ready) {
         client.destroyDrive(drive.getUuid());
         throw new IllegalStateException(String.format("could not image drive %s in time!", drive));
      }
      logger.debug("<< imaged (%s)", drive);

      template.getOptions().userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, tag);

      Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam())
               .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed()))
               .tags(template.getOptions().getTags()).userMetadata(template.getOptions().getUserMetadata()).build();

      ServerInfo from = client.createServer(toCreate);

View Full Code Here


   @Override
   public NodeAndInitialCredentials<ServerInfo> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
      long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);

      logger.debug(">> creating boot drive bytes(%d)", bootSize);
      DriveInfo drive = client
            .createDrive(new Drive.Builder().name(template.getImage().getId()).size(bootSize).build());
      logger.debug("<< drive (%s)", drive);

      boolean success = driveNotClaimed.apply(drive);
      if (!success) {
         client.destroyDrive(drive.getUuid());
         throw new IllegalStateException(String.format("could not create drive %s in time!", drive));
      }

      logger.debug(">> imaging boot drive source(%s)", template.getImage().getId());
      try {
         client.imageDrive(template.getImage().getId(), drive.getUuid(), ImageConversionType.GUNZIP);
      } catch (IllegalStateException ex) {
         logger.debug(">> could not image drive(%s). Cleaning up resources. [%s]", drive.getUuid(), ex.getMessage());
         client.destroyDrive(drive.getUuid());
         throw ex;
      }

      boolean ready = driveNotClaimed.apply(drive);
      if (!ready) {
         client.destroyDrive(drive.getUuid());
         throw new IllegalStateException(String.format("could not image drive %s in time!", drive));
      }
      logger.debug("<< imaged (%s)", drive);

      template.getOptions().userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, tag);

      Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam())
               .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed()))
               .tags(template.getOptions().getTags()).userMetadata(template.getOptions().getUserMetadata()).build();

      ServerInfo from = client.createServer(toCreate);

View Full Code Here

               }
            });

      ElasticStackApi api = EasyMock.createMock(ElasticStackApi.class);
      Predicate<DriveInfo> driveNotClaimed = Predicates.alwaysTrue();
      DriveInfo mockDrive = new DriveInfo.Builder().uuid(UUID.randomUUID().toString()).name("mock")
            .metrics(new DriveMetrics.Builder().build()).build();

      expect(api.createDrive(anyObject(DriveInfo.class))).andReturn(mockDrive);
      api.imageDrive(image.getId(), mockDrive.getUuid(), ImageConversionType.GUNZIP);
      // Set a custom exception message to make sure the exception is thrown at the right point
      expectLastCall().andThrow(new IllegalStateException("imageDrive call failed"));
      api.destroyDrive(mockDrive.getUuid());
      expectLastCall();

      replay(api);

      ElasticStackComputeServiceAdapter adapter = new ElasticStackComputeServiceAdapter(api, driveNotClaimed,
View Full Code Here

      @Override
      public Volume apply(Device input) {
         VolumeBuilder builder = new VolumeBuilder();
         builder.id(input.getId());
         try {
            DriveInfo drive = cache.getUnchecked(input.getDriveUuid());
            builder.size(drive.getSize() / (float) (1024 * 1024));
         } catch (NullPointerException e) {
            logger.debug("drive %s not found", input.getDriveUuid());
         } catch (UncheckedExecutionException e) {
            logger.warn(e, "error finding drive %s: %s", input.getDriveUuid(), e.getMessage());
         }
View Full Code Here

         if (!from.getBootDeviceIds().isEmpty()) {
            String bootDeviceId = Iterables.get(from.getBootDeviceIds(), 0);
            Device bootDevice = from.getDevices().get(bootDeviceId);
            if (bootDevice != null) {
               try {
                  DriveInfo drive = cache.getUnchecked(bootDevice.getDriveUuid());
                  imageId = drive.getName();
               } catch (NullPointerException e) {
                  logger.debug("drive %s not found", bootDevice.getDriveUuid());
               } catch (UncheckedExecutionException e) {
                  logger.warn(e, "error finding drive %s: %s", bootDevice.getDriveUuid(), e.getMessage());
               }
View Full Code Here

   @Test
   public void testCreateDrive() throws Exception {
      drive = client.createDrive(new CreateDriveRequest.Builder().name(prefix).size(driveSize).build());
      checkCreatedDrive();

      DriveInfo newInfo = client.getDriveInfo(drive.getUuid());
      checkDriveMatchesGet(newInfo);

   }
View Full Code Here

   }

   @Test(dependsOnMethods = "testCreateDrive")
   public void testSetDriveData() throws Exception {

      DriveInfo drive2 = client.setDriveData(drive.getUuid(), new DriveData.Builder().claimType(ClaimType.SHARED).name(
               "rediculous").readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff")).tags(
               ImmutableSet.of("networking", "security", "gateway")).userMetadata(ImmutableMap.of("foo", "bar"))
               .build());

      assertNotNull(drive2.getUuid(), drive.getUuid());
      assertEquals(drive2.getName(), "rediculous");
      assertEquals(drive2.getClaimType(), ClaimType.SHARED);
      assertEquals(drive2.getReaders(), ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"));
      assertEquals(drive2.getTags(), ImmutableSet.of("networking", "security", "gateway"));
      assertEquals(drive2.getUserMetadata(), ImmutableMap.of("foo", "bar"));
      drive = drive2;
   }
View Full Code Here

   public void testEmptyMapReturnsNull() {
      assertEquals(MAP_TO_DRIVE.apply(ImmutableMap.<String, String> of()), null);
   }

   public void testBasics() {
      DriveInfo expects = new DriveInfo.Builder().name("foo").size(100l).metrics(new DriveMetrics.Builder().build())
            .build();
      assertEquals(MAP_TO_DRIVE.apply(ImmutableMap.of("name", "foo", "size", "100")), expects);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.elasticstack.domain.DriveInfo

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.