@Override
  public Image apply(VAppTemplate from) {
    checkNotNull(from, "VAppTemplate");
    Envelope ovf = templateToEnvelope.apply(from);

    ImageBuilder builder = new ImageBuilder();
    builder.ids(from.getHref().toASCIIString());
    builder.uri(from.getHref());
    builder.name(from.getName());
    if (from.getVDC() != null) {
      builder.location(findLocationForResource.apply(from.getVDC()));
    } else {
      // otherwise, it could be in a public catalog, which is not assigned to a VDC
    }
    builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
    builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
    builder.status(toPortableImageStatus.get(from.getStatus()));
    return builder.build();
  }
Пример #2
0
  @Override
  public Image apply(DiskImage from) {
    checkNotNull(from, "disk image");

    ImageBuilder builder = new ImageBuilder();

    builder.ids(from.getId());
    builder.name(from.getName());
    builder.description(from.getDescription());
    builder.location(Iterables.getOnlyElement(regionSupplier.get()));
    // in fgcp, if the image is listed it is available
    builder.status(Status.AVAILABLE);

    OperatingSystem os = diskImageToOperatingSystem.apply(from);
    builder.operatingSystem(os);
    String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator" : "root";
    builder.defaultCredentials(LoginCredentials.builder().identity(user).noPassword().build());

    return builder.build();
  }