Ejemplo n.º 1
0
 public T fromImage(Image in) {
   return super.fromResource(in)
       .id(in.getId())
       .name(in.getName())
       .progress(in.getProgress())
       .serverRef(in.getServerRef())
       .status(in.getStatus())
       .metadata(in.getMetadata())
       .created(in.getCreated())
       .updated(in.getUpdated());
 }
  public OperatingSystem apply(final org.jclouds.openstack.nova.domain.Image from) {
    OsFamily osFamily = null;
    String osName = null;
    String osArch = null;
    String osVersion = null;
    String osDescription = from.getName() != null ? from.getName() : "unspecified";

    String name = from.getName() != null ? from.getName() : "unspecified";
    boolean is64Bit = true;
    if (name.indexOf("Red Hat EL") != -1) {
      osFamily = OsFamily.RHEL;
    } else if (name.indexOf("Oracle EL") != -1) {
      osFamily = OsFamily.OEL;
    } else if (name.indexOf("Windows") != -1) {
      osFamily = OsFamily.WINDOWS;
      Matcher matcher = WINDOWS_PATTERN.matcher(from.getName());
      if (matcher.find()) {
        osVersion =
            ComputeServiceUtils.parseVersionOrReturnEmptyString(
                osFamily, matcher.group(1), osVersionMap);
        is64Bit = matcher.group(2).equals("x64");
      }
    } else {
      Matcher matcher = DEFAULT_PATTERN.matcher(name);
      if (matcher.find()) {
        try {
          osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());
        } catch (IllegalArgumentException e) {
          logger.debug("<< didn't match os(%s)", matcher.group(2));
        }
        osVersion =
            ComputeServiceUtils.parseVersionOrReturnEmptyString(
                osFamily, matcher.group(3), osVersionMap);
      }
    }
    return new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
  }