Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.ImageBuilder


      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


            .family(osFamily)
            .version(osVersion)
            .is64Bit(Objects.equal(bits, 64))
            .build();

      return new ImageBuilder()
            .ids(imageId().apply(productItem))
            .description(description)
            .operatingSystem(os)
            .status(Image.Status.AVAILABLE)
            .build();
View Full Code Here

   public void testTemplateChoiceForInstanceByImageIdDoesNotGetAllImages() throws Exception {
      @SuppressWarnings("unchecked")
      Supplier<Set<? extends Image>> images = createMock(Supplier.class);
      replay(images);
     
      final Image image = new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location)
               .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true))
               .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
               .status(Image.Status.AVAILABLE)
               .build();
      Map<RegionAndName, Image> imageMap = ImmutableMap.of(
View Full Code Here

      newTemplateBuilder().imageId("wrongregion/wrongimageid").build();
   }

   private TemplateBuilder newTemplateBuilder() {
      final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of(
               new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location)
                        .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true))
                        .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
                        .status(Image.Status.AVAILABLE)
                        .build(),
               new ImageBuilder().providerId("normal-image").name("image").id("us-east-1/normal-image").location(location)
                        .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "paravirtual", "ubuntu", true))
                        .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
                        .status(Image.Status.AVAILABLE)
                        .build()));
     
View Full Code Here

      final Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
            .<Location> of(region));
      final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
            .<Image> of(
                  new ImageBuilder()
                        .ids("Ubuntu 11.04 x64")
                        .name("Ubuntu 11.04 x64")
                        .description("Ubuntu 11.04 x64")
                        .location(region)
                        .status(Status.AVAILABLE)
                        .operatingSystem(
                              OperatingSystem.builder().name("Ubuntu 11.04 x64").description("Ubuntu 11.04 x64")
                                    .is64Bit(true).version("11.04").family(OsFamily.UBUNTU).build()).build(),
                  new ImageBuilder()
                        .ids("Ubuntu 11.04 64-bit")
                        .name("Ubuntu 11.04 64-bit")
                        .description("Ubuntu 11.04 64-bit")
                        .location(region)
                        .status(Status.AVAILABLE)
View Full Code Here

      final Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
            .<Location> of(region));
      final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
            .<Image> of(
                  new ImageBuilder()
                        .id("us-east-2/ami-ffff")
                        .providerId("ami-ffff")
                        .name("Ubuntu 11.04 x64")
                        .description("Ubuntu 11.04 x64")
                        .location(region2)
View Full Code Here

      final Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
            .<Location> of(region));
      final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
            .<Image> of(
                  new ImageBuilder()
                        .id("us-east-2/ami-ffff")
                        .providerId("ami-ffff")
                        .name("Ubuntu 11.04 x64")
                        .description("Ubuntu 11.04 x64")
                        .location(region2)
View Full Code Here

      Builder builder = OperatingSystem.builder();
      OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName());
      builder.name(drive.getName()).description(description)
            .is64Bit(drive.getBits() != null ? drive.getBits() == 64 : parsed.is64Bit).version(parsed.version)
            .family(parsed.family);
      return new ImageBuilder().ids(drive.getUuid())
            .userMetadata(ImmutableMap.<String, String> of("size", drive.getSize() / 1024 / 1024 / 1024 + ""))
            .location(locationSupplier.get()).name(drive.getName()).description(description)
            .operatingSystem(builder.build()).status(Status.AVAILABLE).version("").build();
   }
View Full Code Here

   @Override
   public Image apply(final org.jclouds.ec2.domain.Image from) {
      if (from.getImageType() != ImageType.MACHINE) {
         return null;
      }
      ImageBuilder builder = new ImageBuilder();
      builder.providerId(from.getId());
      builder.id(from.getRegion() + "/" + from.getId());
      builder.name(from.getName());
      builder.description(from.getDescription() != null ? from.getDescription() : from.getImageLocation());
      builder.userMetadata(ImmutableMap.<String, String> builder().put("owner", from.getImageOwnerId()).put(
               "rootDeviceType", from.getRootDeviceType().value()).put("virtualizationType",
               from.getVirtualizationType().value()).put("hypervisor", from.getHypervisor().value()).build());

      OperatingSystem.Builder osBuilder = OperatingSystem.builder();
      osBuilder.is64Bit(from.getArchitecture() == Architecture.X86_64);
      OsFamily family = parseOsFamily(from);
      osBuilder.family(family);
      osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, from.getImageLocation(),
               osVersionMap));
      osBuilder.description(from.getImageLocation());
      osBuilder.arch(from.getVirtualizationType().value());

      reviseParsedImage.reviseParsedImage(from, builder, family, osBuilder);

      builder.defaultCredentials(credentialProvider.apply(from));

      try {
         builder.location(Iterables.find(locations.get(), new Predicate<Location>() {

            @Override
            public boolean apply(Location input) {
               return input.getId().equals(from.getRegion());
            }

         }));
      } catch (NoSuchElementException e) {
         logger.error("unknown region %s for image %s; not in %s", from.getRegion(), from.getId(), locations);
         builder.location(new LocationBuilder().scope(LocationScope.REGION).id(from.getRegion()).description(
                  from.getRegion()).parent(defaultLocation.get()).build());
      }
      builder.operatingSystem(osBuilder.build());
      builder.status(toPortableImageStatus.get(from.getImageState()));
      builder.backendStatus(from.getRawState());
      return builder.build();
   }
View Full Code Here

      String instanceId = parts[1];

      String imageId = ec2Api.getAMIApi().get().createImageInRegion(region, cloneTemplate.getName(), instanceId,
            CreateImageOptions.NONE);

      final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
            .location(find(locations.get(), idEquals(region)))
            .id(region + "/" + imageId)
            .providerId(imageId)
            .description(cloneTemplate.getName())
            .operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
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.