Package org.jclouds.compute.domain.OperatingSystem

Examples of org.jclouds.compute.domain.OperatingSystem.Builder


   public DatasetToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap) {
      this.osVersionMap = osVersionMap;
   }

   public OperatingSystem apply(Dataset from) {
      Builder builder = OperatingSystem.builder();
      builder.name(from.getName());
      builder.description(from.getUrn());
      builder.is64Bit(true);// TODO: verify
      String os = from.getOs();
      OsFamily family = UNRECOGNIZED;
      String version = "";
      if (os.compareTo("smartos") == 0) {
          family = fromValue(os);
          version = from.getVersion();
      }
      else {
          List<String> pieces = ImmutableList.copyOf(Splitter.on(':').split(from.getUrn()));
          if (pieces.get(2).indexOf('-') != -1) {
             List<String> osFamVersion = ImmutableList.copyOf(Splitter.on('-').split(pieces.get(2)));
             family = fromValue(osFamVersion.get(0));
             if (family != UNRECOGNIZED)
                version = osFamVersion.get(1);
          } else {
             family = fromValue(pieces.get(2));
          }
      }
      builder.family(family);
      if (family != UNRECOGNIZED)
         version = parseVersionOrReturnEmptyString(family, version, osVersionMap);
      if ("".equals(version))
         version = from.getVersion();
      builder.version(version);
      return builder.build();
   }
View Full Code Here


   }

   @Override
   public OperatingSystem apply(String from) {
      checkNotNull(from, "vapp template name");
      Builder builder = new OperatingSystem.Builder();
      builder.description(from);
      if (from.equals("-Windows 2003 Std. R2 SQL 2005 Std. (x64)"))
         System.out.print(';');
      builder.is64Bit(from.indexOf("64") != -1);
      from = from.replace("Red Hat Enterprise Linux", "RHEL").replace("Sun Solaris", "SOLARIS").replace(
               " Server", "").replace("Std. ", "");
      Matcher matcher = OS_PATTERN.matcher(from);
      if (matcher.find()) {
         OsFamily osFamily = parseOsFamilyOrUnrecognized(matcher.group(1));
         builder.family(osFamily);
         String version = (matcher.group(3) != null) ? matcher.group(2) + matcher.group(3) : matcher.group(2);
         builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, version, osVersionMap));
      } else {
         OsFamily osFamily = parseOsFamilyOrUnrecognized(from);
         builder.family(osFamily);
      }
      return builder.build();
   }
View Full Code Here

   public DatasetToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap) {
      this.osVersionMap = osVersionMap;
   }

   public OperatingSystem apply(Dataset from) {
      Builder builder = OperatingSystem.builder();
      builder.name(from.getName());
      builder.description(from.getUrn());
      builder.is64Bit(true);// TODO: verify
      String os = from.getOs();
      OsFamily family = UNRECOGNIZED;
      String version = "";
      if (os.compareTo("smartos") == 0) {
          family = fromValue(os);
          version = from.getVersion();
      }
      else {
          List<String> pieces = ImmutableList.copyOf(Splitter.on(':').split(from.getUrn()));
          if (pieces.get(2).indexOf('-') != -1) {
             List<String> osFamVersion = ImmutableList.copyOf(Splitter.on('-').split(pieces.get(2)));
             family = fromValue(osFamVersion.get(0));
             if (family != UNRECOGNIZED)
                version = osFamVersion.get(1);
          } else {
             family = fromValue(pieces.get(2));
          }
      }
      builder.family(family);
      if (family != UNRECOGNIZED)
         version = parseVersionOrReturnEmptyString(family, version, osVersionMap);
      if ("".equals(version))
         version = from.getVersion();
      builder.version(version);
      return builder.build();
   }
View Full Code Here

   @Override
   public Image apply(DriveInfo drive) {
      if (drive.getName() == null)
         return null;
      String description = drive.getDescription() != null ? drive.getDescription() : drive.getName();
      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(OSTemplate template) {
      checkNotNull(template, "template");
      OsFamilyVersion64Bit parsed = osParser.apply(template.getName());
      Builder builder = OperatingSystem.builder();
      builder.name(template.getName()).description(template.getName()).is64Bit(parsed.is64Bit).version(parsed.version)
               .family(parsed.family);
      return new ImageBuilder().ids(template.getName()).name(template.getName()).description(template.getName())
            .operatingSystem(builder.build()).status(Status.AVAILABLE).build();
   }
View Full Code Here

      this.osCategories = checkNotNull(osCategories, "osCategories");
      this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
   }

   public OperatingSystem apply(Template from) {
      Builder builder = OperatingSystem.builder().description(from.getOSType());

      OSType type = osTypes.get().get(from.getOSTypeId());
      if (type == null) {
         logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get());
         return builder.build();
      }
      builder.description(type.getDescription());
      builder.is64Bit(type.getDescription().indexOf("64-bit") != -1);
      String osCategory = osCategories.get().get(type.getOSCategoryId());
      if (osCategory == null) {
         logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get());
         return builder.build();
      }
      builder.name(osCategory);
      OsFamily family = OsFamily.fromValue(osCategory.toLowerCase());
      builder.family(family);
      Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription());
      if (matcher.find()) {
         builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap));
      }
      return builder.build();
   }
View Full Code Here

   }

   @Override
   public OperatingSystem apply(String from) {
      checkNotNull(from, "vapp template name");
      Builder builder = new OperatingSystem.Builder();
      builder.description(from);
      if (from.equals("-Windows 2003 Std. R2 SQL 2005 Std. (x64)"))
         System.out.print(';');
      builder.is64Bit(from.indexOf("64") != -1);
      from = from.replace("Red Hat Enterprise Linux", "RHEL").replace("Sun Solaris", "SOLARIS").replace(
               " Server", "").replace("Std. ", "");
      Matcher matcher = OS_PATTERN.matcher(from);
      if (matcher.find()) {
         OsFamily osFamily = parseOsFamilyOrUnrecognized(matcher.group(1));
         builder.family(osFamily);
         String version = (matcher.group(3) != null) ? matcher.group(2) + matcher.group(3) : matcher.group(2);
         builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, version, osVersionMap));
      } else {
         OsFamily osFamily = parseOsFamilyOrUnrecognized(from);
         builder.family(osFamily);
      }
      return builder.build();
   }
View Full Code Here

   @Override
   public Image apply(OSTemplate template) {
      checkNotNull(template, "template");
      OsFamilyVersion64Bit parsed = osParser.apply(template.getName());
      Builder builder = OperatingSystem.builder();
      builder.name(template.getName()).description(template.getName()).is64Bit(parsed.is64Bit).version(parsed.version)
               .family(parsed.family);
      return new ImageBuilder().ids(template.getName()).name(template.getName()).description(template.getName())
            .operatingSystem(builder.build()).status(Status.AVAILABLE).build();
   }
View Full Code Here

   @Override
   public Image apply(DriveInfo drive) {
      if (drive.getName() == null)
         return null;
      String description = drive.getDescription() != null ? drive.getDescription() : drive.getName();
      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

      this.osCategories = checkNotNull(osCategories, "osCategories");
      this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
   }

   public OperatingSystem apply(Template from) {
      Builder builder = OperatingSystem.builder().description(from.getOSType());

      OSType type = osTypes.get().get(from.getOSTypeId());
      if (type == null) {
         logger.warn("Template refers to OS type ID %s but this does not exist. Template=%s Known OS types=%s", from.getOSTypeId(), from, osTypes.get());
         return builder.build();
      }
      builder.description(type.getDescription());
      builder.is64Bit(type.getDescription().indexOf("64-bit") != -1);
      String osCategory = osCategories.get().get(type.getOSCategoryId());
      if (osCategory == null) {
         logger.warn("OS type refers to OS category ID %s but this does not exist. OS type=%s Known OS categories=%s", type.getOSCategoryId(), type, osCategories.get());
         return builder.build();
      }
      builder.name(osCategory);
      OsFamily family = OsFamily.fromValue(osCategory.toLowerCase());
      builder.family(family);
      Matcher matcher = DEFAULT_PATTERN.matcher(type.getDescription());
      if (matcher.find()) {
         builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(1), osVersionMap));
      }
      return builder.build();
   }
View Full Code Here

TOP

Related Classes of org.jclouds.compute.domain.OperatingSystem.Builder

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.