Package org.platformlayer.images.model

Examples of org.platformlayer.images.model.OperatingSystemRecipe


  @Inject
  HttpProxyHelper httpProxies;

  protected OperatingSystem getRequestedOperatingSystem(DiskImageRecipe recipe) {
    OperatingSystemRecipe operatingSystemRecipe = recipe.operatingSystem;
    if (operatingSystemRecipe == null) {
      operatingSystemRecipe = new OperatingSystemRecipe();
    }

    if (Strings.isNullOrEmpty(operatingSystemRecipe.distribution)) {
      return OperatingSystem.DebianSqueeze;
    }
View Full Code Here


        DiskImageRecipe recipe = null;
        if (request.recipeId != null) {
          recipe = platformLayerClient.getItem(request.recipeId, DiskImageRecipe.class);
        }

        OperatingSystemRecipe operatingSystem = null;
        if (recipe != null) {
          operatingSystem = recipe.getOperatingSystem();
        }

        log.info("Listing images to pick best image");
        Iterable<Image> images = computeClient.root().images().list();
        if (cloudBehaviours.isHpCloud()) {
          // TODO: We need a better solution here!!
          Set<String> imageNames = Sets.newHashSet("Debian Squeeze 6.0.3 Server 64-bit 20120123");
          log.warn("Hard coding image name (presuming HP cloud)");

          // TODO: Match OS
          for (Image image : images) {
            if (imageNames.contains(image.getName())) {
              foundImage = image;
              break;
            }
          }
        } else if (cloudBehaviours.isRackspaceCloud()) {
          if (operatingSystem == null) {
            operatingSystem = new OperatingSystemRecipe();
            operatingSystem.setDistribution("debian");
            operatingSystem.setVersion("squeeze");
          }

          for (Image image : images) {
            boolean matchesDistribution = false;
            boolean matchesVersion = false;

            for (Image.ImageMetadata.ImageMetadataItem item : image.getMetadata()) {
              // if (item.getKey().equals("platformlayer.org__type")) {
              // if (item.getValue().equals("base")) {
              // isMatch = true;
              // }
              // }

              if (item.getKey().equals("os_distro")) {
                if (operatingSystem != null && operatingSystem.getDistribution() != null) {
                  if (Comparisons
                      .equalsIgnoreCase(operatingSystem.getDistribution(), item.getValue())) {
                    matchesDistribution = true;
                  }
                }
              }

              if (item.getKey().equals("os_version")) {
                if (operatingSystem != null && operatingSystem.getVersion() != null) {
                  if (Comparisons.equalsIgnoreCase(operatingSystem.getVersion(), item.getValue())) {
                    matchesVersion = true;
                  } else if (Comparisons
                      .equalsIgnoreCase(operatingSystem.getDistribution(), "debian")) {

                    // Lenny is no longer getting security updates
                    // if (Strings.equalsIgnoreCase(operatingSystem.getVersion(), "lenny") &&
                    // Strings.equalsIgnoreCase(item.getValue(), "5")) {
                    // matchesVersion = true;
                    // } else

                    if (Comparisons.equalsIgnoreCase(operatingSystem.getVersion(), "squeeze")
                        && Comparisons.equalsIgnoreCase(item.getValue(), "6")) {
                      matchesVersion = true;
                    } else {
                      matchesVersion = false;
                    }
                  } else if (Comparisons
                      .equalsIgnoreCase(operatingSystem.getDistribution(), "ubuntu")) {
                    if (Comparisons.equalsIgnoreCase(operatingSystem.getVersion(), "lucid")
                        && Comparisons.equalsIgnoreCase(item.getValue(), "10.04LTS")) {
                      matchesVersion = true;
                    } else {
                      matchesVersion = false;
                    }
                  } else {
                    matchesVersion = false;
                  }
                }
              }
            }

            if (matchesDistribution && matchesVersion) {
              foundImage = image;
              break;
            }
          }
        } else {
          for (Image image : images) {
            boolean isMatch = false;

            for (Image.ImageMetadata.ImageMetadataItem item : image.getMetadata()) {
              // if (item.getKey().equals(Tag.IMAGE_TYPE)) {
              // if (item.getValue().equals("base")) {
              // isMatch = true;
              // }
              // }

              if (item.getKey().equals(Tag.IMAGE_OS_DISTRIBUTION)) {
                if (operatingSystem != null && operatingSystem.getDistribution() != null) {
                  if (!Comparisons.equalsIgnoreCase(operatingSystem.getDistribution(),
                      item.getValue())) {
                    isMatch = false;
                  }
                }
              }

              if (item.getKey().equals(Tag.IMAGE_OS_VERSION)) {
                if (operatingSystem != null && operatingSystem.getVersion() != null) {
                  if (!Comparisons.equalsIgnoreCase(operatingSystem.getVersion(), item.getValue())) {
                    isMatch = false;
                  }
                }
              }
            }
View Full Code Here

    addChild(instance);

    {
      RecipeOperatingSystem os = injected(RecipeOperatingSystem.class);
      os.operatingSystem = new OperatingSystemRecipe();
      os.operatingSystem.setDistribution("debian");
      os.operatingSystem.setVersion("wheezy");
      instance.addChild(os);
    }
View Full Code Here

        DiskImageRecipe recipe = null;
        if (request.recipeId != null) {
          recipe = platformLayerClient.getItem(request.recipeId, DiskImageRecipe.class);
        }

        OperatingSystemRecipe operatingSystem = null;
        if (recipe != null) {
          operatingSystem = recipe.getOperatingSystem();
        }

        log.info("Listing images to pick best image");
View Full Code Here

      recipe.getAddPackage().add("sun-java6-jre");
      if (addJdk) {
        recipe.getAddPackage().add("sun-java6-jdk");
      }
    } else if (version.equals("7")) {
      OperatingSystemRecipe operatingSystem = recipe.getOperatingSystem();
      if (operatingSystem == null) {
        operatingSystem = new OperatingSystemRecipe();
      }

      if (operatingSystem.getDistribution() == null) {
        operatingSystem.setDistribution("debian");
      }

      if (operatingSystem.getVersion() == null) {
        if (operatingSystem.getDistribution().equalsIgnoreCase("debian")) {
          operatingSystem.setVersion("wheezy");
        }
      }
      recipe.setOperatingSystem(operatingSystem);
    } else {
      throw new IllegalArgumentException("Unknown java version: " + version);
View Full Code Here

TOP

Related Classes of org.platformlayer.images.model.OperatingSystemRecipe

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.