Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.ImageBuilder


@Singleton
public class CIMOperatingSystemToImage implements Function<CIMOperatingSystem, Image> {

   @Override
   public Image apply(CIMOperatingSystem from) {
      ImageBuilder builder = new ImageBuilder();
      builder.ids(from.getOsType().getCode() + "");
      builder.name(from.getName());
      builder.description(from.getDescription());
      builder.operatingSystem(from);
      builder.status(Status.AVAILABLE);
      return builder.build();
   }
View Full Code Here


   protected Logger logger = Logger.NULL;

   @Override
   public Image apply(DataSet from) {

      ImageBuilder builder = new ImageBuilder();
      builder.ids(from.getUuid() + "");
      builder.name(from.getUrn());
      builder.description(from.getUrn());
      builder.status(Image.Status.AVAILABLE);

      OsFamily family;
      try {
         family = OsFamily.SOLARIS;
         builder.operatingSystem(new OperatingSystem.Builder().name(from.getUrn()).description(from.getUrn())
                  .family(family).build());
      } catch (IllegalArgumentException e) {
         logger.debug("<< didn't match os(%s)", from);
      }
      return builder.build();
   }
View Full Code Here

   @Override
   public Image apply(DiskImage from) {
      checkNotNull(from, "disk image");

      ImageBuilder builder = new ImageBuilder();

      builder.ids(from.getId());
      builder.name(from.getName());
      builder.description(from.getDescription());
      // in fgcp, if the image is listed it is available
      builder.status(Status.AVAILABLE);
      OperatingSystem os = diskImageToOperatingSystem.apply(from);
      builder.operatingSystem(os);
      String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator" : "root";
      builder.defaultCredentials(LoginCredentials.builder().identity(user).noPassword().build());
      return builder.build();
   }
View Full Code Here

   @Override
   public Image apply(VAppTemplate from) {
      checkNotNull(from, "VAppTemplate");
      Envelope ovf = templateToEnvelope.apply(from);

      ImageBuilder builder = new ImageBuilder();
      builder.ids(from.getHref().toASCIIString());
      builder.uri(from.getHref());
      builder.name(from.getName());
      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.description(from.getDescription() != null ? from.getDescription() : from.getName());
      builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
      builder.status(toPortableImageStatus.get(from.getStatus()));
      return builder.build();
   }
View Full Code Here

      Set<org.jclouds.compute.domain.Image> result = convertImages("/greenqloud_images.xml");
      assertEquals(result.size(), 9);

      assertEquals(
            Iterables.get(result, 0).toString(),
            new ImageBuilder()
                  .operatingSystem(
                        OperatingSystem.builder().family(OsFamily.UBUNTU).version("10.04")
                              .description("Ubuntu Server 10.04 (64-bit)").is64Bit(true)
                              .arch("paravirtual").build())
                  .description("Ubuntu Server 10.04 (64-bit)")
                  .name("Ubuntu Server 10.04.3")
                  .defaultCredentials(LoginCredentials.builder().user("root").build())
                  .id("us-east-1/qmi-4e5b842f")
                  .providerId("qmi-4e5b842f")
                  .location(defaultLocation)
                  .userMetadata(
                        ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                              "paravirtual", "hypervisor", "xen"))
                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
      assertEquals(Iterables.get(result, 0).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);

      assertEquals(
            Iterables.get(result, 1).toString(),
            new ImageBuilder()
                  .operatingSystem(
                        OperatingSystem.builder().family(OsFamily.UBUNTU).version("11.10")
                              .description("Ubuntu Server 11.10 (64-bit)").is64Bit(true)
                              .arch("paravirtual").build())
                  .description("Ubuntu Server 11.10 (64-bit)")
                  .name("Ubuntu Server 11.10")
                  .defaultCredentials(LoginCredentials.builder().user("root").build())
                  .id("us-east-1/qmi-9ac92558")
                  .providerId("qmi-9ac92558")
                  .location(defaultLocation)
                  .userMetadata(
                        ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                              "paravirtual", "hypervisor", "xen"))
                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
      assertEquals(Iterables.get(result, 1).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
     
      assertEquals(
               Iterables.get(result, 2).toString(),
               new ImageBuilder()
                  .operatingSystem(
                        OperatingSystem.builder().family(OsFamily.CENTOS).version("5.5")
                              .description("CentOS 5.5 Server 64-bit").is64Bit(true)
                              .arch("paravirtual").build())
                  .description("CentOS 5.5 Server 64-bit")
                  .name("CentOS 5.5 Server")
                  .defaultCredentials(LoginCredentials.builder().user("root").build())
                  .id("us-east-1/qmi-33a467aa")
                  .providerId("qmi-33a467aa")
                  .location(defaultLocation)
                  .userMetadata(
                        ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                              "paravirtual", "hypervisor", "xen"))
                  .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());              
         assertEquals(Iterables.get(result, 2).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);
        
         assertEquals(
                  Iterables.get(result, 3).toString(),
                  new ImageBuilder()
                     .operatingSystem(
                           OperatingSystem.builder().family(OsFamily.DEBIAN).version("6.0")
                                 .description("Debian 6.0 (64-bit)").is64Bit(true)
                                 .arch("paravirtual").build())
                     .description("Debian 6.0 (64-bit)")
                     .name("Debian 6.0")
                     .defaultCredentials(LoginCredentials.builder().user("root").build())
                     .id("us-east-1/qmi-f2a9d2ba")
                     .providerId("qmi-f2a9d2ba")
                     .location(defaultLocation)
                     .userMetadata(
                           ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                                 "paravirtual", "hypervisor", "xen"))
                     .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());              
         assertEquals(Iterables.get(result, 3).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);        

         assertEquals(
                  Iterables.get(result, 4).toString(),
                  new ImageBuilder()
                     .operatingSystem(
                           OperatingSystem.builder().family(OsFamily.CENTOS).version("6.0")
                                 .description("CentOS 6.0 (64-bit)").is64Bit(true)
                                 .arch("paravirtual").build())
                     .description("CentOS 6.0 (64-bit)")
                     .name("CentOS 6.0")
                     .defaultCredentials(LoginCredentials.builder().user("root").build())
                     .id("us-east-1/qmi-96f82145")
                     .providerId("qmi-96f82145")
                     .location(defaultLocation)
                     .userMetadata(
                           ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                                 "paravirtual", "hypervisor", "xen"))
                     .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());              
            assertEquals(Iterables.get(result, 4).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);        

            assertEquals(
                     Iterables.get(result, 5).toString(),
                     new ImageBuilder()
                        .operatingSystem(
                              OperatingSystem.builder().family(OsFamily.CENTOS).version("6.0")
                                    .description("CentOS 6.0 GUI (64-bit)").is64Bit(true)
                                    .arch("paravirtual").build())
                        .description("CentOS 6.0 GUI (64-bit)")
                        .name("CentOS 6.0 GUI")
                        .defaultCredentials(LoginCredentials.builder().user("root").build())
                        .id("us-east-1/qmi-42e877f6")
                        .providerId("qmi-42e877f6")
                        .location(defaultLocation)
                        .userMetadata(
                              ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                                    "paravirtual", "hypervisor", "xen"))
                        .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());              
            assertEquals(Iterables.get(result, 5).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);     

            assertEquals(
                     Iterables.get(result, 6).toString(),
                     new ImageBuilder()
                           .operatingSystem(
                                 OperatingSystem.builder().family(OsFamily.UBUNTU).version("11.04")
                                       .description("Ubuntu Server 11.04 (64-bit)").is64Bit(true)
                                       .arch("paravirtual").build())
                           .description("Ubuntu Server 11.04 (64-bit)")
                           .name("Ubuntu Server 11.04")
                           .defaultCredentials(LoginCredentials.builder().user("root").build())
                           .id("us-east-1/qmi-eed8cea7")
                           .providerId("qmi-eed8cea7")
                           .location(defaultLocation)
                           .userMetadata(
                                 ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                                       "paravirtual", "hypervisor", "xen"))
                           .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());
            assertEquals(Iterables.get(result, 6).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);

            assertEquals(
                     Iterables.get(result, 7).toString(),
                     new ImageBuilder()
                        .operatingSystem(
                              // fedora is not in the image version map, yet
                              OperatingSystem.builder().family(OsFamily.FEDORA).version("")
                                    .description("Fedora 16 Server").is64Bit(false)
                                    .arch("paravirtual").build())
                        .description("Fedora 16 Server")
                        .name("Fedora 16 Server")
                        .defaultCredentials(LoginCredentials.builder().user("root").build())
                        .id("us-east-1/qmi-fa4bdae0")
                        .providerId("qmi-fa4bdae0")
                        .location(defaultLocation)
                        .userMetadata(
                              ImmutableMap.of("owner", "admin", "rootDeviceType", "ebs", "virtualizationType",
                                    "paravirtual", "hypervisor", "xen"))
                        .status(org.jclouds.compute.domain.Image.Status.AVAILABLE).backendStatus("available").build().toString());              
            assertEquals(Iterables.get(result, 7).getStatus(), org.jclouds.compute.domain.Image.Status.AVAILABLE);     
          
            assertEquals(
                     Iterables.get(result, 8).toString(),
                     new ImageBuilder()
                        .operatingSystem(
                              OperatingSystem.builder().family(OsFamily.CENTOS).version("5.6")
                                    .description("CentOS 5.6 Server GUI 64-bit").is64Bit(true)
                                    .arch("paravirtual").build())
                        .description("CentOS 5.6 Server GUI 64-bit")
View Full Code Here

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

      checkHardwareAndImageStatus(null, existingHardware, "us-sw-1/sdc:sdc:centos-5.7:1.2.1", null, existingImage);
   }
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();

      checkHardwareAndImageStatus(existingHardware, existingHardware, existingImage.getId(),
View Full Code Here

   public Image apply(DatasetInDatacenter datasetInDatacenter) {
      Location location = locationIndex.get().get(datasetInDatacenter.getDatacenter());
      checkState(location != null, "location %s not in locationIndex: %s", datasetInDatacenter.getDatacenter(),
            locationIndex.get());
      Dataset dataset = datasetInDatacenter.get();
      return new ImageBuilder()
            .id(datasetInDatacenter.slashEncode())
            // note that it is urn that is the expected value!
            .providerId(dataset.getUrn())
            .name(dataset.getName())
            .operatingSystem(imageToOs.apply(dataset))
View Full Code Here

public class GoogleComputeEngineImageToImage implements Function<Image, org.jclouds.compute.domain.Image> {


   @Override
   public org.jclouds.compute.domain.Image apply(Image image) {
      ImageBuilder builder = new ImageBuilder()
              .id(image.getName())
              .name(image.getName())
              .providerId(image.getId())
              .description(image.getDescription().orNull())
              .status(Status.AVAILABLE)
              .location(GOOGLE_PROVIDER_LOCATION)
              .uri(image.getSelfLink());

      List<String> splits = Lists.newArrayList(image.getName().split("-"));
      OperatingSystem.Builder osBuilder = defaultOperatingSystem(image);
      if (splits == null || splits.size() == 0 || splits.size() < 3) {
         return builder.operatingSystem(osBuilder.build()).build();
      }

      OsFamily family = OsFamily.fromValue(splits.get(0));
      if (family != OsFamily.UNRECOGNIZED) {
         osBuilder.family(family);
      }

      String version = on(".").join(limit(skip(splits, 1), splits.size() - 2));
      osBuilder.version(version);

      builder.version(getLast(splits));
      return builder.operatingSystem(osBuilder.build()).build();
   }
View Full Code Here

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

      checkHardwareAndImageStatus(null, existingHardware, "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54",
            null, existingImage);
View Full Code Here

TOP

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

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.