Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.Image


            .<Hardware> of(c1_medium().build()));

      Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
      Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
      TemplateOptions defaultOptions = createMock(TemplateOptions.class);
      Image knownImage = createMock(Image.class);
      OperatingSystem os = createMock(OperatingSystem.class);

      expect(optionsProvider.get()).andReturn(defaultOptions);

      expect(knownImage.getId()).andReturn("us-east-1/ami").atLeastOnce();
      expect(knownImage.getLocation()).andReturn(region).atLeastOnce();
      expect(knownImage.getName()).andReturn(null).atLeastOnce();
      expect(knownImage.getDescription()).andReturn(null).atLeastOnce();
      expect(knownImage.getVersion()).andReturn(null).atLeastOnce();
      expect(knownImage.getProviderId()).andReturn("ami").atLeastOnce();

      expect(knownImage.getOperatingSystem()).andReturn(os).atLeastOnce();

      expect(os.getName()).andReturn(null).atLeastOnce();
      expect(os.getVersion()).andReturn(null).atLeastOnce();
      expect(os.getFamily()).andReturn(null).atLeastOnce();
      expect(os.getDescription()).andReturn(null).atLeastOnce();
View Full Code Here


            .<Hardware> of(c1_medium().build()));

      Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
      Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
      TemplateOptions defaultOptions = createMock(TemplateOptions.class);
      Image knownImage = createMock(Image.class);
      expect(knownImage.getId()).andReturn("region/ami").anyTimes();
      expect(knownImage.getProviderId()).andReturn("ami").anyTimes();
      expect(knownImage.getLocation()).andReturn(region).anyTimes();

      expect(optionsProvider.get()).andReturn(defaultOptions);

      replay(knownImage);
      replay(defaultOptions);
View Full Code Here

      Location defaultLocation = createMock(Location.class);
      Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
      Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
      TemplateOptions defaultOptions = createMock(TemplateOptions.class);
      Image knownImage = createMock(Image.class);
      expect(knownImage.getId()).andReturn("region/ami").anyTimes();
      expect(knownImage.getProviderId()).andReturn("ami").anyTimes();
      expect(knownImage.getLocation()).andReturn(region).anyTimes();

      expect(defaultLocation.getId()).andReturn("region");
      expect(optionsProvider.get()).andReturn(defaultOptions);

      replay(knownImage);
View Full Code Here

      Set<? extends Image> images = getImages();
      checkState(images.size() > 0, "no images present!");
      Set<? extends Hardware> hardwaresToSearch = hardwares.get();
      checkState(hardwaresToSearch.size() > 0, "no hardware profiles present!");

      Image image = null;
      if (imageId != null) {
         image = findImageWithId(images);
         if (currentLocationWiderThan(image.getLocation()))
            this.location = image.getLocation();
      }
     
      Hardware hardware = null;
      if (hardwareId != null) {
         hardware = findHardwareWithId(hardwaresToSearch);
         if (currentLocationWiderThan(hardware.getLocation()))
            this.location = hardware.getLocation();
      }
     
      // if the user hasn't specified a location id, or an image or hardware
      // with location, let's search scoped to the implicit one
      if (location == null)
         location = defaultLocation.get();
     
      if (image == null) {
         Iterable<? extends Image> supportedImages = findSupportedImages(images);
         if (hardware == null)
            hardware = resolveHardware(hardwaresToSearch, supportedImages);
         image = resolveImage(hardware, supportedImages);
      } else {
         if (hardware == null)
            hardware = resolveHardware(hardwaresToSearch, ImmutableSet.of(image));
      }

      logger.debug("<<   matched image(%s) hardware(%s) location(%s)", image.getId(), hardware.getId(),
            location.getId());
      return new TemplateImpl(image, hardware, location, options);
   }
View Full Code Here

   @Override
   public NodeMetadata apply(InstanceInZone instanceInZone) {
      Instance input = instanceInZone.getInstance();
      Map<URI, ? extends Image> imagesMap = images.get();
      Image image = checkNotNull(imagesMap.get(checkNotNull(input.getImage(), "image")),
              "no image for %s. images: %s", input.getImage(), imagesMap.values());

      return new NodeMetadataBuilder()
              .id(SlashEncodedIds.fromTwoIds(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()).getId(),
                      input.getName()).slashEncode())
              .name(input.getName())
              .providerId(input.getId())
              .hostname(input.getName())
              .imageId(image.getId())
              .location(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()))
              .hardware(checkNotNull(hardwares.get().get(input.getMachineType()), "hardware type for %s",
                      input.getMachineType().toString()))
              .operatingSystem(image.getOperatingSystem())
              .status(toPortableNodeStatus.get(input.getStatus()))
              .tags(input.getTags().getItems())
              .uri(input.getSelfLink())
              .userMetadata(input.getMetadata())
              .group(nodeNamingConvention.groupInUniqueNameOrNull(input.getName()))
View Full Code Here

      builder.imageId(instance.getRegion() + "/" + instance.getImageId());

      // extract the operating system from the image
      RegionAndName regionAndName = new RegionAndName(instance.getRegion(), instance.getImageId());
      try {
         Image image = imageMap.get().getUnchecked(regionAndName);
         if (image != null)
            builder.operatingSystem(image.getOperatingSystem());
      } catch (CacheLoader.InvalidCacheLoadException e) {
         logger.debug("image not found for %s: %s", regionAndName, e);
      } catch (UncheckedExecutionException e) {
         logger.debug("error getting image for %s: %s", regionAndName, e);
      }
View Full Code Here

   @Override
   protected Image resolveImage(Hardware size, Iterable<? extends Image> supportedImages) {
      try {
         return super.resolveImage(size, supportedImages);
      } catch (NoSuchElementException e) {
         Image returnVal = lazyImageProvider.get();
         if (returnVal != null)
            return returnVal;
         throw e;
      }
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   @Override
   protected Set<? extends Image> getImages() {
      if (imageId != null) {
         Image image = lazyImageProvider.get();
         return ImmutableSet.of(image);
      } else {
         return (Set<Image>) this.images.get();
      }
   }
View Full Code Here

      builder.ids(from.id + "");
      builder.name(from.name);
      builder.location(from(locations.get()).firstMatch(LocationPredicates.idEquals(from.datacenter)).orNull());
      builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.name));
      builder.imageId(from.imageId + "");
      Image image = from(images.get()).firstMatch(ImagePredicates.idEquals(from.imageId + "")).orNull();
      if (image != null)
         builder.operatingSystem(image.getOperatingSystem());
      builder.hardware(from(hardware.get()).firstMatch(HardwarePredicates.idEquals(from.hardwareId + "")).orNull());
      builder.status(serverStatusToNodeStatus.get(from.status));
      builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
      builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress));
      builder.credentials(LoginCredentials.fromCredentials(credentialStore.get(from.id + "")));
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.Image

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.