Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.HardwareBuilder


@Singleton
public class VMSpecToHardware implements Function<VMSpec, Hardware> {

   @Override
   public Hardware apply(VMSpec from) {
      HardwareBuilder builder = new HardwareBuilder();
      builder.ids(from.toString());
      for (int i = 0; i < from.getProcessorCount(); i++)
         builder.processor(new Processor(1, 3.0));
      builder.ram(from.getMemoryInGig() * 1024);
      builder.volume(new VolumeBuilder().type(Volume.Type.LOCAL).device(from.getBootDeviceName()).size(
               new Float(from.getBootDiskSize())).bootDevice(true).durable(true).build());
      for (Entry<String, Integer> disk : from.getDataDiskDeviceNameToSizeInGig().entrySet())
         builder.volume(new VolumeBuilder().type(Volume.Type.LOCAL).device(disk.getKey()).size(
                  new Float(disk.getValue())).durable(true).build());
      builder.hypervisor("VMware");
      return builder.build();
   }
View Full Code Here


   }

   @Override
   public Hardware apply(ServerType from) {
      checkNotNull(from, "ServerType");
      HardwareBuilder builder = new HardwareBuilder();

      builder.ids(from.getId());
      builder.name(from.getName());
      builder.ram((int) (1000d * Double.valueOf(from.getMemory().getSize())));
      builder.processor(cpuToProcessor.apply(from.getCpu()));
      builder.supportsImage(Predicates.<Image> alwaysTrue());
      // all servers are 64bit. The OS however may be 32 bit.
      builder.is64Bit(true);
      builder.volumes(Iterables.transform(from.getDisks(), diskToVolume));

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

@Singleton
public class VmSpecificationToHardware implements Function<VmSpecification, Hardware> {

   @Override
   public Hardware apply(VmSpecification from) {
      HardwareBuilder builder = new HardwareBuilder();
      builder.ids(from.getAlias());
      builder.name(from.getAlias());
      builder.processors(ImmutableList.of(new Processor(1, 1.0)));
      builder.ram(from.getMaxPhysicalMemory());
      // builder.volumes(ImmutableList.<Volume> of(new VolumeImpl(from.disk, true, false)));
      return builder.build();
   }
View Full Code Here

      if (ovf.getVirtualSystem().getVirtualHardwareSections().size() > 1) {
         logger.warn("multiple hardware choices found. using first", ovf);
      }
      VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getVirtualHardwareSections(), 0);
      HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
      Link vdc = Iterables.find(checkNotNull(from, "from").getLinks(), LinkPredicates.typeEquals(VCloudDirectorMediaType.VDC));
      if (vdc != null) {
         builder.location(findLocationForResource.apply(vdc));
      } else {
         // otherwise, it could be in a public catalog, which is not assigned to a VDC
      }
      builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
               ImagePredicates.idEquals(from.getHref().toASCIIString()));
      builder.hypervisor("VMware");
      return builder.build();

   }
View Full Code Here

      // TODO make this work with composite vApps
      if (from == null)
         return null;
     
      VirtualHardwareSection hardware = findVirtualHardwareSectionForVm.apply(from);
      HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
      builder.location(findLocationForResource.apply(Iterables.find(checkNotNull(from, "from").getLinks(),
            LinkPredicates.typeEquals(VCloudDirectorMediaType.VDC))));
      builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
               ImagePredicates.idEquals(from.getHref().toASCIIString()));
      builder.hypervisor("VMware");
      return builder.build();
   }
View Full Code Here

         GroupNamingConvention.Factory.class);

   @Test
   public void testWhenNoHardwareOrImageMatchImageIdIsStillSet() {

      Hardware existingHardware = new HardwareBuilder().id("us-sw-1/FOOOOOOOO").providerId("FOOOOOOOO").location(zone)
            .build();
      Image existingImage = new ImageBuilder().id("us-sw-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 testWhenHardwareAndImageMatchHardwareOperatingSystemAndImageIdAreSet() {

      Hardware existingHardware = new HardwareBuilder().id("us-sw-1/Small 1GB").providerId("Small 1GB").ram(1024)
            .volume(new VolumeImpl(Float.valueOf(61440), true, true)).location(zone).build();
      Image existingImage = new ImageBuilder().id("us-sw-1/sdc:sdc:centos-5.7:1.2.1")
            .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
            .providerId("sdc:sdc:centos-5.7:1.2.1").description("foobuntu").status(Image.Status.AVAILABLE)
            .location(zone).build();
View Full Code Here

   public Hardware apply(PackageInDatacenter pkgInDatacenter) {
      Location location = locationIndex.get().get(pkgInDatacenter.getDatacenter());
      checkState(location != null, "location %s not in locationIndex: %s", pkgInDatacenter.getDatacenter(),
            locationIndex.get());
      org.jclouds.joyent.cloudapi.v6_5.domain.Package pkg = pkgInDatacenter.get();
      return new HardwareBuilder().id(pkgInDatacenter.slashEncode()).providerId(pkg.getName()).name(pkg.getName())
            .ram(pkg.getMemorySizeMb())
            // TODO: no api call to get processors.. either hard-code or
            // calculate
            .processor(new Processor(1, 1.0)).volume(new VolumeImpl(Float.valueOf(pkg.getDiskSizeGb()), true, true))
            .location(location).build();
View Full Code Here

   }

   @Override
   public Iterable<Hardware> listHardwareProfiles() {
      Set<Hardware> hardware = Sets.newLinkedHashSet();
      hardware.add(new HardwareBuilder().ids("t1.micro").hypervisor("VirtualBox").name("t1.micro").ram(512).build());
      hardware.add(new HardwareBuilder().ids("m1.small").hypervisor("VirtualBox").name("m1.small").ram(1024).build());
      hardware.add(new HardwareBuilder().ids("m1.medium").hypervisor("VirtualBox").name("m1.medium").ram(3840).build());
      hardware.add(new HardwareBuilder().ids("m1.large").hypervisor("VirtualBox").name("m1.large").ram(7680).build());
      return hardware;
   }
View Full Code Here

*/
public class MachineTypeToHardware implements Function<MachineType, Hardware> {

   @Override
   public Hardware apply(MachineType input) {
      return new HardwareBuilder()
              .id(input.getName())
              .name(input.getName())
              .hypervisor("kvm")
              .processor(new Processor(input.getGuestCpus(), 1.0))
              .providerId(input.getId())
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.