Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.HardwareBuilder


   GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);

   @Test
   public void testWhenNoHardwareOrImageMatchServerScopedIdsImageIdIsStillSet() {

      Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/FOOOOOOOO").providerId("FOOOOOOOO")
            .location(zone).build();
      Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/FOOOOOOOO")
            .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
            .providerId("FOOOOOOOO").description("foobuntu").location(zone).status(Image.Status.AVAILABLE).build();
View Full Code Here


   }

   @Test
   public void testWhenNoHardwareAndImageMatchServerScopedIdsHardwareOperatingSystemAndImageIdAreSet() {

      Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
            .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
      Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
            .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
            .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
            .location(zone).build();
View Full Code Here

      Builder<Hardware> hardware = ImmutableSet.builder();
      for (double cpu : new double[] { 1000, 5000, 10000, 20000 })
         for (int ram : new int[] { 512, 1024, 2048, 4096, 8192 }) {
            final float size = (float) cpu / 1000;
            String id = String.format("cpu=%f,ram=%s,disk=%f", cpu, ram, size);
            hardware.add(new HardwareBuilder().supportsImage(new Predicate<Image>() {

               @Override
               public boolean apply(Image input) {
                  String toParse = input.getUserMetadata().get("size");
                  return toParse != null && new Float(toParse) <= size;
View Full Code Here

         Optional<? extends Image> image = FluentIterable.from(images.get()).firstMatch(idEquals(imageId));
         if (image.isPresent()) {
            builder.operatingSystem(image.get().getOperatingSystem());
         }
      }
      builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm")
            .processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
            .volumes(Iterables.transform(from.getDevices().values(), deviceToVolume)).build());
      builder.status(serverStatusToNodeStatus.get(from.getStatus()));
      builder.publicAddresses(ImmutableSet.<String> of(from.getNics().get(0).getDhcp()));
      builder.privateAddresses(ImmutableSet.<String> of());
View Full Code Here

      Builder<Hardware> hardware = ImmutableSet.builder();
      for (double cpu : new double[] { 1000, 5000, 10000, 20000 })
         for (int ram : new int[] { 512, 1024, 4 * 1024, 16 * 1024, 32 * 1024 }) {
            final float size = (float) cpu / 100;
            String id = String.format("cpu=%f,ram=%s,disk=%f", cpu, ram, size);
            hardware.add(new HardwareBuilder().supportsImage(new Predicate<Image>() {

               @Override
               public boolean apply(Image input) {
                  String toParse = input.getUserMetadata().get("size");
                  return toParse != null && new Float(toParse) <= size;
View Full Code Here

      if (image != null) {
         builder.imageId(image.getId());
         builder.operatingSystem(image.getOperatingSystem());
      }

      builder.hardware(new HardwareBuilder()
        .ids(from.getServiceOfferingId() + "")
        .name(from.getServiceOfferingName() + "")
         // .tags() TODO
        .processors(ImmutableList.of(new Processor(from.getCpuCount(), from.getCpuSpeed())))
        .ram((int)from.getMemory())//
View Full Code Here

@Singleton
public class SizeToHardware implements Function<Size, Hardware> {

   @Override
   public Hardware apply(Size input) {
      HardwareBuilder builder = new HardwareBuilder();
      builder.ids(String.valueOf(input.getId()));
      builder.name(input.getName());
      builder.ram(input.getMemory());
      // DigitalOcean does not provide the processor speed. We configure it to
      // make the bigger template the faster.
      builder.processor(new Processor(input.getCpu(), input.getCpu()));

      builder.volume(new VolumeBuilder()
            .size(Float.valueOf(input.getDisk()))
            .type(Type.LOCAL)
            .build());

      ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder();
      metadata.put("costPerHour", input.getCostPerHour());
      metadata.put("costPerMonth", input.getCostPerMonth());
      builder.userMetadata(metadata.build());

      return builder.build();
   }
View Full Code Here

      extNic = new ExternalIpDto();
      extNic.setIp("10.10.10.10");
      extNic.setMac("2a:6e:40:69:84:e2");

      hardware = new HardwareBuilder() //
            .ids("1") //
            .build();

      function = new VirtualMachineToNodeMetadata(templateToImage(), templateToHardware(), stateToNodeState(),
            virtualDatacenterToLocation());
View Full Code Here

   @Override
   public Hardware apply(final VirtualMachineTemplateInVirtualDatacenter templateInVirtualDatacenter) {
      VirtualMachineTemplate template = templateInVirtualDatacenter.getTemplate();
      VirtualDatacenter virtualDatacenter = templateInVirtualDatacenter.getZone();

      HardwareBuilder builder = new HardwareBuilder();
      builder.providerId(template.getId().toString());
      builder.id(template.getId().toString() + "/" + virtualDatacenter.getId());
      builder.uri(template.getURI());

      builder.name(template.getName());
      builder.processor(new Processor(template.getCpuRequired(), DEFAULT_CORE_SPEED));
      builder.ram(template.getRamRequired());

      // Location information
      builder.location(virtualDatacenterToLocation.apply(virtualDatacenter));
      builder.hypervisor(virtualDatacenter.getHypervisorType().name());
      builder.supportsImage(ImagePredicates.idEquals(template.getId().toString()));

      VolumeBuilder volumeBuilder = new VolumeBuilder();
      volumeBuilder.bootDevice(true);
      volumeBuilder.size(toGb(template.getHdRequired()));
      volumeBuilder.type(Volume.Type.LOCAL);
      volumeBuilder.durable(false);
      builder.volume(volumeBuilder.build());

      return builder.build();
   }
View Full Code Here

@Singleton
public class HardwareBuilderFromResourceAllocations implements
         Function<Iterable<? extends ResourceAllocationSettingData>, HardwareBuilder> {
   @Override
   public HardwareBuilder apply(Iterable<? extends ResourceAllocationSettingData> from) {
      HardwareBuilder builder = new HardwareBuilder();
      builder.volumes(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE,
               ResourceType.BASE_PARTITIONABLE_UNIT, ResourceType.PARTITIONABLE_UNIT)),
               new Function<ResourceAllocationSettingData, Volume>() {

                  @Override
                  public Volume apply(ResourceAllocationSettingData from) {
                     return HardwareBuilderFromResourceAllocations.this.apply(from);
                  }

               }));

      builder.ram((int) find(from, CIMPredicates.resourceTypeIn(ResourceType.MEMORY)).getVirtualQuantity().longValue());

      builder.processors(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)),
               new Function<ResourceAllocationSettingData, Processor>() {

                  @Override
                  public Processor apply(ResourceAllocationSettingData arg0) {
                     return new Processor(arg0.getVirtualQuantity().longValue(), 1);
View Full Code Here

TOP

Related Classes of org.jclouds.compute.domain.HardwareBuilder

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.