Exemple #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);
  }
Exemple #3
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((addresses == null) ? 0 : addresses.hashCode());
   result = prime * result + ((adminPass == null) ? 0 : adminPass.hashCode());
   result = prime * result + ((flavorRef == null) ? 0 : flavorRef.hashCode());
   result = prime * result + ((hostId == null) ? 0 : hostId.hashCode());
   result = prime * result + id;
   result = prime * result + ((imageRef == null) ? 0 : imageRef.hashCode());
   result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
   result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
   result = prime * result + ((name == null) ? 0 : name.hashCode());
   result = prime * result + ((flavor == null) ? 0 : flavor.hashCode());
   result = prime * result + ((image == null) ? 0 : image.hashCode());
   return result;
 }
Exemple #4
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Server other = (Server) obj;
   if (addresses == null) {
     if (other.addresses != null) return false;
   } else if (!addresses.equals(other.addresses)) return false;
   if (adminPass == null) {
     if (other.adminPass != null) return false;
   } else if (!adminPass.equals(other.adminPass)) return false;
   if (flavorRef == null) {
     if (other.flavorRef != null) return false;
   } else if (!flavorRef.equals(other.flavorRef)) return false;
   if (hostId == null) {
     if (other.hostId != null) return false;
   } else if (!hostId.equals(other.hostId)) return false;
   if (id != other.id) return false;
   if (imageRef == null) {
     if (other.imageRef != null) return false;
   } else if (!imageRef.equals(other.imageRef)) return false;
   if (metadata == null) {
     if (other.metadata != null) return false;
   } else if (!metadata.equals(other.metadata)) return false;
   if (uuid == null) {
     if (other.uuid != null) return false;
   } else if (!uuid.equals(other.uuid)) return false;
   if (name == null) {
     if (other.name != null) return false;
   } else if (!name.equals(other.name)) return false;
   if (flavor == null) {
     if (other.flavor != null) return false;
   } else if (!flavor.equals(other.flavor)) return false;
   if (image == null) {
     if (other.image != null) return false;
   } else if (!image.equals(other.image)) return false;
   return true;
 }